Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Send Sec-Fetch-User only for user-activated, navigational requests. #16148

Merged
merged 1 commit into from
Mar 30, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions fetch/sec-metadata/embed.tentative.https.sub.html
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
let e = document.createElement('embed');
e.src = "https://{{host}}:{{ports[https][0]}}/fetch/sec-metadata/resources/record-header.py?file=" + key;
e.onload = e => {
let expected = {"dest":"embed", "site":"same-origin", "user":"?F", "mode":"no-cors"};
let expected = {"dest":"embed", "site":"same-origin", "user":"", "mode":"no-cors"};
fetch("/fetch/sec-metadata/resources/record-header.py?retrieve=true&file=" + key)
.then(response => response.text())
.then(text => assert_header_equals(text, expected))
Expand All @@ -35,7 +35,7 @@
let e = document.createElement('embed');
e.src = "https://{{hosts[][www]}}:{{ports[https][0]}}/fetch/sec-metadata/resources/record-header.py?file=" + key;
e.onload = e => {
let expected = {"dest":"embed", "site":"same-site", "user":"?F", "mode":"no-cors"};
let expected = {"dest":"embed", "site":"same-site", "user":"", "mode":"no-cors"};
fetch("/fetch/sec-metadata/resources/record-header.py?retrieve=true&file=" + key)
.then(response => response.text())
.then(text => assert_header_equals(text, expected))
Expand All @@ -54,7 +54,7 @@
let e = document.createElement('embed');
e.src = "https://{{hosts[alt][www]}}:{{ports[https][0]}}/fetch/sec-metadata/resources/record-header.py?file=" + key;
e.onload = e => {
let expected = {"dest":"embed", "site":"cross-site", "user":"?F", "mode":"no-cors"};
let expected = {"dest":"embed", "site":"cross-site", "user":"", "mode":"no-cors"};
fetch("/fetch/sec-metadata/resources/record-header.py?retrieve=true&file=" + key)
.then(response => response.text())
.then(text => assert_header_equals(text, expected))
Expand Down
12 changes: 6 additions & 6 deletions fetch/sec-metadata/fetch.tentative.https.sub.html
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
assert_header_equals(j, {
"dest": "empty",
"site": "same-origin",
"user": "?F",
"user": "",
"mode": "cors",
});
});
Expand All @@ -24,7 +24,7 @@
assert_header_equals(j, {
"dest": "empty",
"site": "same-site",
"user": "?F",
"user": "",
"mode": "cors",
});
});
Expand All @@ -37,7 +37,7 @@
assert_header_equals(j, {
"dest": "empty",
"site": "cross-site",
"user": "?F",
"user": "",
"mode": "cors",
});
});
Expand All @@ -51,7 +51,7 @@
assert_header_equals(j, {
"dest": "empty",
"site": "same-origin",
"user": "?F",
"user": "",
"mode": "same-origin",
});
});
Expand All @@ -64,7 +64,7 @@
assert_header_equals(j, {
"dest": "empty",
"site": "same-origin",
"user": "?F",
"user": "",
"mode": "cors",
});
});
Expand All @@ -77,7 +77,7 @@
assert_header_equals(j, {
"dest": "empty",
"site": "same-origin",
"user": "?F",
"user": "",
"mode": "no-cors",
});
});
Expand Down
6 changes: 3 additions & 3 deletions fetch/sec-metadata/font.tentative.https.sub.html
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
promise_test(t => {
return new Promise((resolve, reject) => {
let key = "font-same-origin";
let expected = {"dest":"font", "site":"same-origin", "user":"?F", "mode": "cors"};
let expected = {"dest":"font", "site":"same-origin", "user":"", "mode": "cors"};
fetch("/fetch/sec-metadata/resources/record-header.py?retrieve=true&file=" + key)
.then(response => response.text())
.then(text => assert_header_equals(text, expected))
Expand All @@ -58,7 +58,7 @@
promise_test(t => {
return new Promise((resolve, reject) => {
let key = "font-same-site";
let expected = {"dest":"font", "site":"same-site", "user":"?F", "mode": "cors"};
let expected = {"dest":"font", "site":"same-site", "user":"", "mode": "cors"};
fetch("/fetch/sec-metadata/resources/record-header.py?retrieve=true&file=" + key)
.then(response => response.text())
.then(text => assert_header_equals(text, expected))
Expand All @@ -70,7 +70,7 @@
promise_test(t => {
return new Promise((resolve, reject) => {
let key = "font-cross-site";
let expected = {"dest":"font", "site":"cross-site", "user":"?F", "mode": "cors"};
let expected = {"dest":"font", "site":"cross-site", "user":"", "mode": "cors"};
fetch("/fetch/sec-metadata/resources/record-header.py?retrieve=true&file=" + key)
.then(response => response.text())
.then(text => assert_header_equals(text, expected))
Expand Down
134 changes: 78 additions & 56 deletions fetch/sec-metadata/iframe.tentative.https.sub.html
Original file line number Diff line number Diff line change
@@ -1,63 +1,85 @@
<!DOCTYPE html>
<script src=/resources/testharness.js></script>
<script src=/resources/testharnessreport.js></script>
<script src=/resources/testdriver.js></script>
<script src=/resources/testdriver-vendor.js></script>
<script src=/fetch/sec-metadata/resources/helper.js></script>
<script src=/common/utils.js></script>
<body>
<script>
async_test(t => {
let i = document.createElement('iframe');
i.src = "https://{{host}}:{{ports[https][0]}}/fetch/sec-metadata/resources/post-to-owner.py";
window.addEventListener('message', t.step_func(e => {
if (e.source != i.contentWindow)
return;

assert_header_equals(e.data, {
"dest": "nested-document",
"site": "same-origin",
"user": "?F",
"mode": "nested-navigate"
});
t.done();
}));

document.body.appendChild(i);
}, "Same-origin iframe");

async_test(t => {
let i = document.createElement('iframe');
i.src = "https://{{hosts[][www]}}:{{ports[https][0]}}/fetch/sec-metadata/resources/post-to-owner.py";
window.addEventListener('message', t.step_func(e => {
if (e.source != i.contentWindow)
return;

assert_header_equals(e.data, {
"dest": "nested-document",
"site": "same-site",
"user": "?F",
"mode": "nested-navigate"
});
t.done();
}));

document.body.appendChild(i);
}, "Same-site iframe");

async_test(t => {
let i = document.createElement('iframe');
i.src = "https://{{hosts[alt][www]}}:{{ports[https][0]}}/fetch/sec-metadata/resources/post-to-owner.py";
window.addEventListener('message', t.step_func(e => {
if (e.source != i.contentWindow)
return;

assert_header_equals(e.data, {
"dest": "nested-document",
"site": "cross-site",
"user": "?F",
"mode": "nested-navigate"
});
t.done();
}));

document.body.appendChild(i);
}, "Cross-site iframe");
const USER = true;
const FORCED = false;

function create_test(host, user_activated, expectations) {
async_test(t => {
let i = document.createElement('iframe');
window.addEventListener('message', t.step_func(e => {
if (e.source != i.contentWindow)
return;

assert_header_equals(e.data, expectations);
t.done();
}));

let url = `https://${host}/fetch/sec-metadata/resources/post-to-owner.py`;
if (user_activated == FORCED) {
i.src = url;
document.body.appendChild(i);
} else if (user_activated == USER) {
let uuid = token();
i.name = uuid;
let a = document.createElement('a');
a.href = url;
a.target = uuid;
a.text = "This is a link!";

document.body.appendChild(i);
document.body.appendChild(a);

test_driver.click(a);
}
}, `{{host}} -> ${host} iframe: ${user_activated ? "user-activated" : "forced"}`);
}

create_test("{{host}}:{{ports[https][0]}}", FORCED, {
"dest": "nested-document",
"site": "same-origin",
"user": "",
"mode": "nested-navigate"
});

create_test("{{hosts[][www]}}:{{ports[https][0]}}", FORCED, {
"dest": "nested-document",
"site": "same-site",
"user": "",
"mode": "nested-navigate"
});

create_test("{{hosts[alt][www]}}:{{ports[https][0]}}", FORCED, {
"dest": "nested-document",
"site": "cross-site",
"user": "",
"mode": "nested-navigate"
});

create_test("{{host}}:{{ports[https][0]}}", USER, {
"dest": "nested-document",
"site": "same-origin",
"user": "?T",
"mode": "nested-navigate"
});

create_test("{{hosts[][www]}}:{{ports[https][0]}}", USER, {
"dest": "nested-document",
"site": "same-site",
"user": "?T",
"mode": "nested-navigate"
});

create_test("{{hosts[alt][www]}}:{{ports[https][0]}}", USER, {
"dest": "nested-document",
"site": "cross-site",
"user": "?T",
"mode": "nested-navigate"
});
</script>
12 changes: 9 additions & 3 deletions fetch/sec-metadata/img.tentative.https.sub.html
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,9 @@
assert_header_equals(got, {
"dest": "image",
"site": "same-origin",
"user": "?F",
// Note that we're using `undefined` here, as opposed to "" elsewhere because of the way
// that `image.py` encodes data.
"user": undefined,
"mode": "cors", // Because `loadImageInWindow` tacks on `crossorigin`
});
}),
Expand All @@ -45,7 +47,9 @@
assert_header_equals(got, {
"dest": "image",
"site": "same-site",
"user": "?F",
// Note that we're using `undefined` here, as opposed to "" elsewhere because of the way
// that `image.py` encodes data.
"user": undefined,
"mode": "cors", // Because `loadImageInWindow` tacks on `crossorigin`
});
}),
Expand All @@ -67,7 +71,9 @@
assert_header_equals(got, {
"dest": "image",
"site": "cross-site",
"user": "?F",
// Note that we're using `undefined` here, as opposed to "" elsewhere because of the way
// that `image.py` encodes data.
"user": undefined,
"mode": "cors", // Because `loadImageInWindow` tacks on `crossorigin`
});
}),
Expand Down
6 changes: 3 additions & 3 deletions fetch/sec-metadata/object.tentative.https.sub.html
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
let e = document.createElement('object');
e.data = "https://{{host}}:{{ports[https][0]}}/fetch/sec-metadata/resources/record-header.py?file=" + key;
e.onload = e => {
let expected = {"dest":"object", "site":"same-origin", "user":"?F", "mode":"no-cors"};
let expected = {"dest":"object", "site":"same-origin", "user":"", "mode":"no-cors"};
fetch("/fetch/sec-metadata/resources/record-header.py?retrieve=true&file=" + key)
.then(response => response.text())
.then(text => assert_header_equals(text, expected))
Expand All @@ -35,7 +35,7 @@
let e = document.createElement('object');
e.data = "https://{{hosts[][www]}}:{{ports[https][0]}}/fetch/sec-metadata/resources/record-header.py?file=" + key;
e.onload = e => {
let expected = {"dest":"object", "site":"same-site", "user":"?F", "mode":"no-cors"};
let expected = {"dest":"object", "site":"same-site", "user":"", "mode":"no-cors"};
fetch("/fetch/sec-metadata/resources/record-header.py?retrieve=true&file=" + key)
.then(response => response.text())
.then(text => assert_header_equals(text, expected))
Expand All @@ -54,7 +54,7 @@
let e = document.createElement('object');
e.data = "https://{{hosts[alt][www]}}:{{ports[https][0]}}/fetch/sec-metadata/resources/record-header.py?file=" + key;
e.onload = e => {
let expected = {"dest":"object", "site":"cross-site", "user":"?F", "mode":"no-cors"};
let expected = {"dest":"object", "site":"cross-site", "user":"", "mode":"no-cors"};
fetch("/fetch/sec-metadata/resources/record-header.py?retrieve=true&file=" + key)
.then(response => response.text())
.then(text => assert_header_equals(text, expected))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

let e = document.createElement('img');
e.src = "https://{{hosts[alt][www]}}:{{ports[https][0]}}/xhr/resources/redirect.py?location=https://{{host}}:{{ports[https][0]}}/fetch/sec-metadata/resources/record-header.py?file=" + key;
let expected = {"dest":"image", "site":"cross-site", "user":"?F", "mode": "no-cors"};
let expected = {"dest":"image", "site":"cross-site", "user":"", "mode": "no-cors"};
e.onload = e => {
fetch("/fetch/sec-metadata/resources/record-header.py?retrieve=true&file=" + key)
.then(response => response.text())
Expand All @@ -41,7 +41,7 @@

let e = document.createElement('img');
e.src = "https://{{hosts[alt][www]}}:{{ports[https][0]}}/xhr/resources/redirect.py?location=https://{{hosts[][www]}}:{{ports[https][0]}}/fetch/sec-metadata/resources/record-header.py?file=" + key;
let expected = {"dest":"image", "site":"cross-site", "user":"?F", "mode": "no-cors"};
let expected = {"dest":"image", "site":"cross-site", "user":"", "mode": "no-cors"};
e.onload = e => {
fetch("/fetch/sec-metadata/resources/record-header.py?retrieve=true&file=" + key)
.then(response => response.text())
Expand All @@ -67,7 +67,7 @@

let e = document.createElement('img');
e.src = "https://{{hosts[alt][www]}}:{{ports[https][0]}}/xhr/resources/redirect.py?location=https://{{hosts[alt][www]}}:{{ports[https][0]}}/fetch/sec-metadata/resources/record-header.py?file=" + key;
let expected = {"dest":"image", "site":"cross-site", "user":"?F", "mode": "no-cors"};
let expected = {"dest":"image", "site":"cross-site", "user":"", "mode": "no-cors"};
e.onload = e => {
fetch("/fetch/sec-metadata/resources/record-header.py?retrieve=true&file=" + key)
.then(response => response.text())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
e.src = "https://{{host}}:{{ports[https][0]}}/xhr/resources/redirect.py?location=" +// same-origin
"https://{{hosts[alt][www]}}:{{ports[https][0]}}/xhr/resources/redirect.py?location=" +// cross-site
"https://{{host}}:{{ports[https][0]}}/fetch/sec-metadata/resources/record-header.py?file=" + key;// same-origin
let expected = {"dest":"image", "site":"cross-site", "user":"?F", "mode": "no-cors"};
let expected = {"dest":"image", "site":"cross-site", "user":"", "mode": "no-cors"};

e.onload = e => {
fetch("/fetch/sec-metadata/resources/record-header.py?retrieve=true&file=" + key)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
e.src = "https://{{host}}:{{ports[https][0]}}/xhr/resources/redirect.py?location=" +// same-origin
"https://{{hosts[][www]}}:{{ports[https][0]}}/xhr/resources/redirect.py?location=" +// same-site
"https://{{host}}:{{ports[https][0]}}/fetch/sec-metadata/resources/record-header.py?file=" + key;// same-origin
let expected = {"dest":"image", "site":"same-site", "user":"?F", "mode": "no-cors"};
let expected = {"dest":"image", "site":"same-site", "user":"", "mode": "no-cors"};

e.onload = e => {
fetch("/fetch/sec-metadata/resources/record-header.py?retrieve=true&file=" + key)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

let e = document.createElement('img');
e.src = "/xhr/resources/redirect.py?location=https://{{host}}:{{ports[https][0]}}/fetch/sec-metadata/resources/record-header.py?file=" + key;
let expected = {"dest":"image", "site":"same-origin", "user":"?F", "mode": "no-cors"};
let expected = {"dest":"image", "site":"same-origin", "user":"", "mode": "no-cors"};

e.onload = e => {
fetch("/fetch/sec-metadata/resources/record-header.py?retrieve=true&file=" + key)
Expand All @@ -42,7 +42,7 @@

let e = document.createElement('img');
e.src = "/xhr/resources/redirect.py?location=https://{{hosts[][www]}}:{{ports[https][0]}}/fetch/sec-metadata/resources/record-header.py?file=" + key;
let expected = {"dest":"image", "site":"same-site", "user":"?F", "mode": "no-cors"};
let expected = {"dest":"image", "site":"same-site", "user":"", "mode": "no-cors"};

e.onload = e => {
fetch("/fetch/sec-metadata/resources/record-header.py?retrieve=true&file=" + key)
Expand All @@ -69,7 +69,7 @@

let e = document.createElement('img');
e.src = "/xhr/resources/redirect.py?location=https://{{hosts[alt][www]}}:{{ports[https][0]}}/fetch/sec-metadata/resources/record-header.py?file=" + key;
let expected = {"dest":"image", "site":"cross-site", "user":"?F", "mode": "no-cors"};
let expected = {"dest":"image", "site":"cross-site", "user":"", "mode": "no-cors"};

e.onload = e => {
fetch("/fetch/sec-metadata/resources/record-header.py?retrieve=true&file=" + key)
Expand Down
Loading