no-referrer-url-censored.html (1970B)
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.navigation.navigate("#hash"); 12 assert_equals(i.contentWindow.navigation.entries().length, 2); 13 14 // The entries for no-referrer.html should have the url censored. 15 i.contentWindow.navigation.navigate("/common/blank.html"); 16 await new Promise(r => i.onload = () => t.step_timeout(r, 0)); 17 assert_equals(i.contentWindow.navigation.entries().length, 3); 18 assert_equals(i.contentWindow.navigation.currentEntry.index, 2); 19 assert_equals(i.contentWindow.navigation.entries()[0].url, null); 20 assert_equals(i.contentWindow.navigation.entries()[1].url, null); 21 assert_equals(i.contentWindow.navigation.activation.from.url, null); 22 23 // Navigating back to no-referrer.html should uncensor the urls. 24 i.contentWindow.navigation.back(); 25 await new Promise(r => i.onload = () => t.step_timeout(r, 0)); 26 assert_equals(i.contentWindow.navigation.entries().length, 3); 27 assert_equals(i.contentWindow.navigation.currentEntry.index, 1); 28 assert_equals(new URL(i.contentWindow.navigation.entries()[0].url).pathname, 29 "/navigation-api/navigation-history-entry/resources/no-referrer.html"); 30 assert_equals(new URL(i.contentWindow.navigation.entries()[1].url).pathname, 31 "/navigation-api/navigation-history-entry/resources/no-referrer.html"); 32 assert_equals(new URL(i.contentWindow.navigation.activation.entry.url).pathname, 33 "/navigation-api/navigation-history-entry/resources/no-referrer.html"); 34 }, "The url of a document with no-referrer referrer policy is censored in NavigationHistoryEntry"); 35 </script>