Skip to content

Commit 5aefe72

Browse files
natechapinchromium-wpt-export-bot
authored andcommitted
Allow appHistory entries that are cross-site-instance, censor the url of entries that are noreferrer
While this allows appHistory entries (including URLs) to be sent across renderer processes on a BrowsingContextGroup switch, it still omits the URL in cases where a page has expressed that the URL may be sensitive and shouldn't be exposed (via ReferrerPolicy). This follows WICG/navigation-api#71 Fixed: 1280010 Change-Id: I07e7ff1376dd9eca34b4493a06a658f1b72da027
1 parent 0fbad78 commit 5aefe72

7 files changed

+103
-2
lines changed

app-history/app-history-entry/entry-after-detach.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,12 @@
77
window.onload = t.step_func_done(() => {
88
let i_entry = i.contentWindow.appHistory.current;
99
assert_true(i_entry.sameDocument);
10-
assert_not_equals(i_entry.url, "");
10+
assert_not_equals(i_entry.url, null);
1111
assert_not_equals(i_entry.key, "");
1212
assert_not_equals(i_entry.id, "");
1313
i.remove();
1414
assert_false(i_entry.sameDocument);
15-
assert_equals(i_entry.url, "");
15+
assert_equals(i_entry.url, null);
1616
assert_equals(i_entry.key, "");
1717
assert_equals(i_entry.id, "");
1818
});
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
<!doctype html>
2+
<script src="/resources/testharness.js"></script>
3+
<script src="/resources/testharnessreport.js"></script>
4+
<iframe id="i" src="/common/blank.html"></iframe>
5+
<script>
6+
promise_test(async (t) => {
7+
// Wait for after the load event so that the navigation doesn't get converted
8+
// into a replace navigation.
9+
await new Promise(r => window.onload = () => t.step_timeout(r, 0));
10+
11+
// The entry for the first document has a visible url.
12+
i.contentWindow.appHistory.navigate("/common/blank.html?2");
13+
await new Promise(r => i.onload = () => t.step_timeout(r, 0));
14+
assert_not_equals(i.contentWindow.appHistory.entries()[0].url, null);
15+
16+
// Apply no-referrer, the url should now be censored when no longer on that document.
17+
i.contentWindow.appHistory.back();
18+
await new Promise(r => i.onload = () => t.step_timeout(r, 0));
19+
i.contentDocument.head.innerHTML = `<meta name="referrer" content="no-referrer">`;
20+
assert_not_equals(i.contentWindow.appHistory.entries()[0].url, null);
21+
i.contentWindow.appHistory.forward();
22+
await new Promise(r => i.onload = () => t.step_timeout(r, 0));
23+
assert_equals(i.contentWindow.appHistory.entries()[0].url, null);
24+
25+
// Overwrite the referrer policy, the url should be visible again.
26+
i.contentWindow.appHistory.back();
27+
await new Promise(r => i.onload = () => t.step_timeout(r, 0));
28+
i.contentDocument.head.innerHTML = `<meta name="referrer" content="same-origin">`;
29+
i.contentWindow.appHistory.forward();
30+
await new Promise(r => i.onload = () => t.step_timeout(r, 0));
31+
assert_not_equals(i.contentWindow.appHistory.entries()[0].url, null);
32+
}, "The url of a document is censored by a no-referrer policy dynamically");
33+
</script>
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
<!doctype html>
2+
<script src="/resources/testharness.js"></script>
3+
<script src="/resources/testharnessreport.js"></script>
4+
<iframe id="i" src="resources/no-referrer-meta.html"></iframe>
5+
<script>
6+
promise_test(async (t) => {
7+
// Wait for after the load event so that the navigation doesn't get converted
8+
// into a replace navigation.
9+
await new Promise(r => window.onload = () => t.step_timeout(r, 0));
10+
11+
await i.contentWindow.appHistory.navigate("#hash");
12+
assert_equals(i.contentWindow.appHistory.entries().length, 2);
13+
14+
// The entries for no-referrer.html should have the url censored.
15+
i.contentWindow.appHistory.navigate("/common/blank.html");
16+
await new Promise(r => i.onload = () => t.step_timeout(r, 0));
17+
assert_equals(i.contentWindow.appHistory.entries().length, 3);
18+
assert_equals(i.contentWindow.appHistory.current.index, 2);
19+
assert_equals(i.contentWindow.appHistory.entries()[0].url, null);
20+
assert_equals(i.contentWindow.appHistory.entries()[1].url, null);
21+
22+
// Navigating back to no-referrer.html should uncensor the urls.
23+
i.contentWindow.appHistory.back();
24+
await new Promise(r => i.onload = () => t.step_timeout(r, 0));
25+
assert_equals(i.contentWindow.appHistory.entries().length, 3);
26+
assert_equals(i.contentWindow.appHistory.current.index, 1);
27+
assert_equals(new URL(i.contentWindow.appHistory.entries()[0].url).pathname,
28+
"/app-history/app-history-entry/resources/no-referrer-meta.html");
29+
assert_equals(new URL(i.contentWindow.appHistory.entries()[1].url).pathname,
30+
"/app-history/app-history-entry/resources/no-referrer-meta.html");
31+
}, "The url of a document with no-referrer referrer meta tag is censored in AppHistoryEntry");
32+
</script>
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
<!doctype html>
2+
<script src="/resources/testharness.js"></script>
3+
<script src="/resources/testharnessreport.js"></script>
4+
<iframe id="i" src="resources/no-referrer.html"></iframe>
5+
<script>
6+
promise_test(async (t) => {
7+
// Wait for after the load event so that the navigation doesn't get converted
8+
// into a replace navigation.
9+
await new Promise(r => window.onload = () => t.step_timeout(r, 0));
10+
11+
await i.contentWindow.appHistory.navigate("#hash");
12+
assert_equals(i.contentWindow.appHistory.entries().length, 2);
13+
14+
// The entries for no-referrer.html should have the url censored.
15+
i.contentWindow.appHistory.navigate("/common/blank.html");
16+
await new Promise(r => i.onload = () => t.step_timeout(r, 0));
17+
assert_equals(i.contentWindow.appHistory.entries().length, 3);
18+
assert_equals(i.contentWindow.appHistory.current.index, 2);
19+
assert_equals(i.contentWindow.appHistory.entries()[0].url, null);
20+
assert_equals(i.contentWindow.appHistory.entries()[1].url, null);
21+
22+
// Navigating back to no-referrer.html should uncensor the urls.
23+
i.contentWindow.appHistory.back();
24+
await new Promise(r => i.onload = () => t.step_timeout(r, 0));
25+
assert_equals(i.contentWindow.appHistory.entries().length, 3);
26+
assert_equals(i.contentWindow.appHistory.current.index, 1);
27+
assert_equals(new URL(i.contentWindow.appHistory.entries()[0].url).pathname,
28+
"/app-history/app-history-entry/resources/no-referrer.html");
29+
assert_equals(new URL(i.contentWindow.appHistory.entries()[1].url).pathname,
30+
"/app-history/app-history-entry/resources/no-referrer.html");
31+
}, "The url of a document with no-referrer referrer policy is censored in AppHistoryEntry");
32+
</script>
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
<meta name="referrer" content="no-referrer">
2+
<body></body>
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
<body></body>
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Referrer-Policy: no-referrer

0 commit comments

Comments
 (0)