From 5afa7f6c3321e6435f6e4e119214f7c826dd8bae Mon Sep 17 00:00:00 2001 From: Mike West Date: Tue, 15 Oct 2019 08:11:55 -0700 Subject: [PATCH] Fetch Metadata: Add a test for `` navigated after loading. @annevk noted in https://github.com/whatwg/fetch/pull/948#discussion_r331921654 that it was possible to navigate an `` after it loads. In this case, it seems safest to ensure that this navigation shows up with a destination of `embed` and a mode of `no-cors`. That seems to be what we're sending today via Fetch Metadata, so let's lock it in via this patch's tests. I suspect it's not what the underlying `fetch()` API would show in a service worker, but we can deal with that in a separate patch. Bug: 1011763 Change-Id: I0156b2b1b467c914b15f6af50dfa37ce74db6c62 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1844996 Commit-Queue: Mike West Reviewed-by: Daniel Vogelheim Cr-Commit-Position: refs/heads/master@{#705518} --- fetch/metadata/embed.tentative.https.sub.html | 106 ++++++++---------- fetch/metadata/resources/helper.js | 13 +++ 2 files changed, 61 insertions(+), 58 deletions(-) diff --git a/fetch/metadata/embed.tentative.https.sub.html b/fetch/metadata/embed.tentative.https.sub.html index aae61e0ff42649..77042e85de9f26 100644 --- a/fetch/metadata/embed.tentative.https.sub.html +++ b/fetch/metadata/embed.tentative.https.sub.html @@ -7,62 +7,52 @@ diff --git a/fetch/metadata/resources/helper.js b/fetch/metadata/resources/helper.js index eac176a49871c9..d9b00ed8b94b59 100644 --- a/fetch/metadata/resources/helper.js +++ b/fetch/metadata/resources/helper.js @@ -2,6 +2,19 @@ function wrap_by_tag(tag, text) { return tag ? `${tag}: ${text}`: text; } +function validate_expectations(key, expected, tag) { + return fetch("/fetch/metadata/resources/record-header.py?retrieve=true&file=" + key) + .then(response => response.text()) + .then(text => { + assert_not_equals(text, "No header has been recorded"); + let value = JSON.parse(text); + test(t => assert_equals(value.dest, expected.dest), `${tag}: sec-fetch-dest`); + test(t => assert_equals(value.mode, expected.mode), `${tag}: sec-fetch-mode`); + test(t => assert_equals(value.site, expected.site), `${tag}: sec-fetch-site`); + test(t => assert_equals(value.user, expected.user), `${tag}: sec-fetch-user`); + }); +}; + /** * @param {object} value * @param {object} expected