Skip to content
This repository was archived by the owner on Mar 19, 2021. It is now read-only.

Commit 9fffe21

Browse files
iVanlIshchromium-wpt-export-bot
authored andcommitted
Fetch Metadata: split up document destination.
As discussed in w3c/webappsec-fetch-metadata#45, We have decided to shift the model around nested navigations from exposure via the request's `mode` to its `destination`. This patch splits the existing `document` destination into three parts: - `document` for top-level navigations and, for the moment, <portals>. - `iframe` for <iframe> navigations. - `frame` for <frame> navigations. Subsequent patch will remove the `nested-document` mode when we're ready to ship `Sec-Fetch-Dest`. Bug: 1011724 Change-Id: I23f23922fb49523aa050f59cbf13aabc086600bb Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1847295 Reviewed-by: Arthur Sonzogni <[email protected]> Reviewed-by: Mike West <[email protected]> Commit-Queue: Yifan Luo <[email protected]> Cr-Commit-Position: refs/heads/master@{#705527}
1 parent e6ca5a0 commit 9fffe21

File tree

4 files changed

+124
-7
lines changed

4 files changed

+124
-7
lines changed
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
<!DOCTYPE html>
2+
<script src=/resources/testharness.js></script>
3+
<script src=/resources/testharnessreport.js></script>
4+
<script src=/resources/testdriver.js></script>
5+
<script src=/resources/testdriver-vendor.js></script>
6+
<script src=/fetch/metadata/resources/helper.js></script>
7+
<script src=/common/utils.js></script>
8+
<body>
9+
<script>
10+
const USER = true;
11+
const FORCED = false;
12+
13+
function create_test(host, user_activated, expectations) {
14+
async_test(t => {
15+
let i = document.createElement('frame');
16+
window.addEventListener('message', t.step_func(e => {
17+
if (e.source != i.contentWindow)
18+
return;
19+
20+
assert_header_dest_equals(e.data, expectations);
21+
t.done();
22+
}));
23+
24+
let url = `https://${host}/fetch/metadata/resources/post-to-owner.py`;
25+
if (user_activated == FORCED) {
26+
i.src = url;
27+
document.body.appendChild(i);
28+
} else if (user_activated == USER) {
29+
let uuid = token();
30+
i.name = uuid;
31+
let a = document.createElement('a');
32+
a.href = url;
33+
a.target = uuid;
34+
a.text = "This is a link!";
35+
36+
document.body.appendChild(i);
37+
document.body.appendChild(a);
38+
39+
test_driver.click(a);
40+
}
41+
}, `{{host}} -> ${host} iframe: ${user_activated ? "user-activated" : "forced"}`);
42+
}
43+
44+
create_test("{{host}}:{{ports[https][0]}}", FORCED, "frame");
45+
46+
create_test("{{hosts[][www]}}:{{ports[https][0]}}", FORCED, "frame");
47+
48+
create_test("{{hosts[alt][www]}}:{{ports[https][0]}}", FORCED, "frame");
49+
50+
create_test("{{host}}:{{ports[https][0]}}", USER, "frame");
51+
52+
create_test("{{hosts[][www]}}:{{ports[https][0]}}", USER, "frame");
53+
54+
create_test("{{hosts[alt][www]}}:{{ports[https][0]}}", USER, "frame");
55+
</script>
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
<!DOCTYPE html>
2+
<script src=/resources/testharness.js></script>
3+
<script src=/resources/testharnessreport.js></script>
4+
<script src=/fetch/metadata/resources/helper.js></script>
5+
<body>
6+
<script>
7+
async_test(t => {
8+
let i = document.createElement('frame');
9+
i.src = "http://{{host}}:{{ports[http][0]}}/fetch/metadata/resources/post-to-owner.py";
10+
window.addEventListener('message', t.step_func(e => {
11+
if (e.source != i.contentWindow)
12+
return;
13+
14+
assert_header_dest_equals(e.data, "");
15+
t.done();
16+
}));
17+
18+
document.body.appendChild(i);
19+
}, "Non-secure same-origin iframe => No headers");
20+
21+
async_test(t => {
22+
let i = document.createElement('frame');
23+
i.src = "http://{{hosts[][www]}}:{{ports[http][0]}}/fetch/metadata/resources/post-to-owner.py";
24+
window.addEventListener('message', t.step_func(e => {
25+
if (e.source != i.contentWindow)
26+
return;
27+
28+
assert_header_dest_equals(e.data, "");
29+
t.done();
30+
}));
31+
32+
document.body.appendChild(i);
33+
}, "Non-secure same-site iframe => No headers");
34+
35+
async_test(t => {
36+
let i = document.createElement('frame');
37+
i.src = "http://{{hosts[alt][www]}}:{{ports[http][0]}}/fetch/metadata/resources/post-to-owner.py";
38+
window.addEventListener('message', t.step_func(e => {
39+
if (e.source != i.contentWindow)
40+
return;
41+
42+
assert_header_dest_equals(e.data, "");
43+
t.done();
44+
}));
45+
46+
document.body.appendChild(i);
47+
}, "Non-secure cross-site iframe => No headers.");
48+
49+
async_test(t => {
50+
let i = document.createElement('frame');
51+
i.src = "https://{{host}}:{{ports[https][0]}}/fetch/metadata/resources/post-to-owner.py";
52+
window.addEventListener('message', t.step_func(e => {
53+
if (e.source != i.contentWindow)
54+
return;
55+
56+
assert_header_dest_equals(e.data, "frame");
57+
t.done();
58+
}));
59+
60+
document.body.appendChild(i);
61+
}, "Secure, cross-site (cross-scheme, same-host) frame");
62+
</script>

fetch/metadata/sec-fetch-dest/iframe.tentative.https.sub.html

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -41,15 +41,15 @@
4141
}, `{{host}} -> ${host} iframe: ${user_activated ? "user-activated" : "forced"}`);
4242
}
4343

44-
create_test("{{host}}:{{ports[https][0]}}", FORCED, "nested-document");
44+
create_test("{{host}}:{{ports[https][0]}}", FORCED, "iframe");
4545

46-
create_test("{{hosts[][www]}}:{{ports[https][0]}}", FORCED, "nested-document");
46+
create_test("{{hosts[][www]}}:{{ports[https][0]}}", FORCED, "iframe");
4747

48-
create_test("{{hosts[alt][www]}}:{{ports[https][0]}}", FORCED, "nested-document");
48+
create_test("{{hosts[alt][www]}}:{{ports[https][0]}}", FORCED, "iframe");
4949

50-
create_test("{{host}}:{{ports[https][0]}}", USER, "nested-document");
50+
create_test("{{host}}:{{ports[https][0]}}", USER, "iframe");
5151

52-
create_test("{{hosts[][www]}}:{{ports[https][0]}}", USER, "nested-document");
52+
create_test("{{hosts[][www]}}:{{ports[https][0]}}", USER, "iframe");
5353

54-
create_test("{{hosts[alt][www]}}:{{ports[https][0]}}", USER, "nested-document");
54+
create_test("{{hosts[alt][www]}}:{{ports[https][0]}}", USER, "iframe");
5555
</script>

fetch/metadata/sec-fetch-dest/iframe.tentative.sub.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@
5353
if (e.source != i.contentWindow)
5454
return;
5555

56-
assert_header_dest_equals(e.data, "nested-document");
56+
assert_header_dest_equals(e.data, "iframe");
5757
t.done();
5858
}));
5959

0 commit comments

Comments
 (0)