Skip to content

Commit

Permalink
Fetch Metadata: Add a test for <embed> navigated after loading.
Browse files Browse the repository at this point in the history
@annevk noted in whatwg/fetch#948 (comment)
that it was possible to navigate an `<embed>` after it loads. I think
we should probably figure out how to make that navigation show up with a
destination of `embed` and a mode of `no-cors`.

Surprisingly, that seems to be what we're sending via Fetch Metadata.
I suspect it's not what the underlying `fetch()` API would show in a
service worker.

Bug: 1011763
Change-Id: I0156b2b1b467c914b15f6af50dfa37ce74db6c62
  • Loading branch information
mikewest authored and chromium-wpt-export-bot committed Oct 7, 2019
1 parent 238225a commit 947f55e
Showing 1 changed file with 72 additions and 0 deletions.
72 changes: 72 additions & 0 deletions fetch/metadata/embed.tentative.https.sub.html
Original file line number Diff line number Diff line change
Expand Up @@ -65,4 +65,76 @@
document.body.appendChild(e);
})
}, "Cross-Site embed");

promise_test(t => {
return new Promise((resolve, reject) => {
let key = "post-embed-same-origin" + nonce;

let e = document.createElement('embed');
e.src = "/common/blank.html";
e.addEventListener("load", _ => {
e.addEventListener("load", e => {
let expected = {"dest":"embed", "site":"same-origin", "user":"", "mode":"no-cors"};
fetch("/fetch/metadata/resources/record-header.py?retrieve=true&file=" + key)
.then(response => response.text())
.then(text => assert_header_equals(text, expected))
.then(_ => resolve())
.catch(e => reject(e));
}, { once: true });

// Navigate the existing `<embed>`
window.frames[window.length - 1].location = "https://{{host}}:{{ports[https][0]}}/fetch/metadata/resources/record-header.py?file=" + key;
}, { once: true });

document.body.appendChild(e);
})
}, "Navigate to same-origin embed");

promise_test(t => {
return new Promise((resolve, reject) => {
let key = "post-embed-same-origin" + nonce;

let e = document.createElement('embed');
e.src = "/common/blank.html";
e.addEventListener("load", _ => {
e.addEventListener("load", e => {
let expected = {"dest":"embed", "site":"same-site", "user":"", "mode":"no-cors"};
fetch("/fetch/metadata/resources/record-header.py?retrieve=true&file=" + key)
.then(response => response.text())
.then(text => assert_header_equals(text, expected))
.then(_ => resolve())
.catch(e => reject(e));
}, { once: true });

// Navigate the existing `<embed>`
window.frames[window.length - 1].location = "https://{{hosts[][www]}}:{{ports[https][0]}}/fetch/metadata/resources/record-header.py?file=" + key;
}, { once: true });

document.body.appendChild(e);
})
}, "Navigate to same-site embed");

promise_test(t => {
return new Promise((resolve, reject) => {
let key = "post-embed-same-origin" + nonce;

let e = document.createElement('embed');
e.src = "/common/blank.html";
e.addEventListener("load", _ => {
e.addEventListener("load", e => {
let expected = {"dest":"embed", "site":"cross-site", "user":"", "mode":"no-cors"};
fetch("/fetch/metadata/resources/record-header.py?retrieve=true&file=" + key)
.then(response => response.text())
.then(text => assert_header_equals(text, expected))
.then(_ => resolve())
.catch(e => reject(e));
}, { once: true });

// Navigate the existing `<embed>`
window.frames[window.length - 1].location = "https://{{hosts[alt][www]}}:{{ports[https][0]}}/fetch/metadata/resources/record-header.py?file=" + key;
}, { once: true });

document.body.appendChild(e);
})
}, "Navigate to cross-site embed");
</script>

0 comments on commit 947f55e

Please sign in to comment.