Skip to content

Commit

Permalink
Allow appHistory entries that are cross-site-instance, forbid ones th…
Browse files Browse the repository at this point in the history
…at are noreferrer

This follows WICG/navigation-api#71

Change-Id: I07e7ff1376dd9eca34b4493a06a658f1b72da027
  • Loading branch information
natechapin authored and chromium-wpt-export-bot committed Nov 17, 2021
1 parent 2662731 commit 6539d70
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 0 deletions.
32 changes: 32 additions & 0 deletions app-history/app-history-entry/no-referrer-url-censored.html
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, "");
assert_equals(i.contentWindow.appHistory.entries()[1].url, "");

// 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>
1 change: 1 addition & 0 deletions app-history/app-history-entry/resources/no-referrer.html
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<body></body>
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Referrer-Policy: no-referrer

0 comments on commit 6539d70

Please sign in to comment.