-
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, forbid ones th…
…at are noreferrer This follows WICG/navigation-api#71 Change-Id: I07e7ff1376dd9eca34b4493a06a658f1b72da027
- Loading branch information
1 parent
9a88be4
commit 87793b9
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. | ||
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">`; | ||
await new Promise(r => t.step_timeout(r, 1000)); | ||
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 |