-
Notifications
You must be signed in to change notification settings - Fork 3.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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
- Loading branch information
1 parent
0fbad78
commit 5aefe72
Showing
7 changed files
with
103 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
33 changes: 33 additions & 0 deletions
33
app-history/app-history-entry/no-referrer-dynamic-url-censored.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
<!doctype html> | ||
<script src="/resources/testharness.js"></script> | ||
<script src="/resources/testharnessreport.js"></script> | ||
<iframe id="i" src="/common/blank.html"></iframe> | ||
<script> | ||
promise_test(async (t) => { | ||
// Wait for after the load event so that the navigation doesn't get converted | ||
// into a replace navigation. | ||
await new Promise(r => window.onload = () => t.step_timeout(r, 0)); | ||
|
||
// The entry for the first document has a visible url. | ||
i.contentWindow.appHistory.navigate("/common/blank.html?2"); | ||
await new Promise(r => i.onload = () => t.step_timeout(r, 0)); | ||
assert_not_equals(i.contentWindow.appHistory.entries()[0].url, null); | ||
|
||
// Apply no-referrer, the url should now be censored when no longer on that document. | ||
i.contentWindow.appHistory.back(); | ||
await new Promise(r => i.onload = () => t.step_timeout(r, 0)); | ||
i.contentDocument.head.innerHTML = `<meta name="referrer" content="no-referrer">`; | ||
assert_not_equals(i.contentWindow.appHistory.entries()[0].url, null); | ||
i.contentWindow.appHistory.forward(); | ||
await new Promise(r => i.onload = () => t.step_timeout(r, 0)); | ||
assert_equals(i.contentWindow.appHistory.entries()[0].url, null); | ||
|
||
// Overwrite the referrer policy, the url should be visible again. | ||
i.contentWindow.appHistory.back(); | ||
await new Promise(r => i.onload = () => t.step_timeout(r, 0)); | ||
i.contentDocument.head.innerHTML = `<meta name="referrer" content="same-origin">`; | ||
i.contentWindow.appHistory.forward(); | ||
await new Promise(r => i.onload = () => t.step_timeout(r, 0)); | ||
assert_not_equals(i.contentWindow.appHistory.entries()[0].url, null); | ||
}, "The url of a document is censored by a no-referrer policy dynamically"); | ||
</script> |
32 changes: 32 additions & 0 deletions
32
app-history/app-history-entry/no-referrer-from-meta-url-censored.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
<!doctype html> | ||
<script src="/resources/testharness.js"></script> | ||
<script src="/resources/testharnessreport.js"></script> | ||
<iframe id="i" src="resources/no-referrer-meta.html"></iframe> | ||
<script> | ||
promise_test(async (t) => { | ||
// Wait for after the load event so that the navigation doesn't get converted | ||
// into a replace navigation. | ||
await new Promise(r => window.onload = () => t.step_timeout(r, 0)); | ||
|
||
await i.contentWindow.appHistory.navigate("#hash"); | ||
assert_equals(i.contentWindow.appHistory.entries().length, 2); | ||
|
||
// The entries for no-referrer.html should have the url censored. | ||
i.contentWindow.appHistory.navigate("/common/blank.html"); | ||
await new Promise(r => i.onload = () => t.step_timeout(r, 0)); | ||
assert_equals(i.contentWindow.appHistory.entries().length, 3); | ||
assert_equals(i.contentWindow.appHistory.current.index, 2); | ||
assert_equals(i.contentWindow.appHistory.entries()[0].url, null); | ||
assert_equals(i.contentWindow.appHistory.entries()[1].url, null); | ||
|
||
// Navigating back to no-referrer.html should uncensor the urls. | ||
i.contentWindow.appHistory.back(); | ||
await new Promise(r => i.onload = () => t.step_timeout(r, 0)); | ||
assert_equals(i.contentWindow.appHistory.entries().length, 3); | ||
assert_equals(i.contentWindow.appHistory.current.index, 1); | ||
assert_equals(new URL(i.contentWindow.appHistory.entries()[0].url).pathname, | ||
"/app-history/app-history-entry/resources/no-referrer-meta.html"); | ||
assert_equals(new URL(i.contentWindow.appHistory.entries()[1].url).pathname, | ||
"/app-history/app-history-entry/resources/no-referrer-meta.html"); | ||
}, "The url of a document with no-referrer referrer meta tag is censored in AppHistoryEntry"); | ||
</script> |
32 changes: 32 additions & 0 deletions
32
app-history/app-history-entry/no-referrer-url-censored.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
<!doctype html> | ||
<script src="/resources/testharness.js"></script> | ||
<script src="/resources/testharnessreport.js"></script> | ||
<iframe id="i" src="resources/no-referrer.html"></iframe> | ||
<script> | ||
promise_test(async (t) => { | ||
// Wait for after the load event so that the navigation doesn't get converted | ||
// into a replace navigation. | ||
await new Promise(r => window.onload = () => t.step_timeout(r, 0)); | ||
|
||
await i.contentWindow.appHistory.navigate("#hash"); | ||
assert_equals(i.contentWindow.appHistory.entries().length, 2); | ||
|
||
// The entries for no-referrer.html should have the url censored. | ||
i.contentWindow.appHistory.navigate("/common/blank.html"); | ||
await new Promise(r => i.onload = () => t.step_timeout(r, 0)); | ||
assert_equals(i.contentWindow.appHistory.entries().length, 3); | ||
assert_equals(i.contentWindow.appHistory.current.index, 2); | ||
assert_equals(i.contentWindow.appHistory.entries()[0].url, null); | ||
assert_equals(i.contentWindow.appHistory.entries()[1].url, null); | ||
|
||
// Navigating back to no-referrer.html should uncensor the urls. | ||
i.contentWindow.appHistory.back(); | ||
await new Promise(r => i.onload = () => t.step_timeout(r, 0)); | ||
assert_equals(i.contentWindow.appHistory.entries().length, 3); | ||
assert_equals(i.contentWindow.appHistory.current.index, 1); | ||
assert_equals(new URL(i.contentWindow.appHistory.entries()[0].url).pathname, | ||
"/app-history/app-history-entry/resources/no-referrer.html"); | ||
assert_equals(new URL(i.contentWindow.appHistory.entries()[1].url).pathname, | ||
"/app-history/app-history-entry/resources/no-referrer.html"); | ||
}, "The url of a document with no-referrer referrer policy is censored in AppHistoryEntry"); | ||
</script> |
2 changes: 2 additions & 0 deletions
2
app-history/app-history-entry/resources/no-referrer-meta.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
<meta name="referrer" content="no-referrer"> | ||
<body></body> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
<body></body> |
1 change: 1 addition & 0 deletions
1
app-history/app-history-entry/resources/no-referrer.html.headers
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Referrer-Policy: no-referrer |