fragment-navigation.https.html (1815B)
1 <!DOCTYPE html> 2 <title>Test that embedder-initiated fragment navigations are forced to be cross-document.</title> 3 <script src="/resources/testharness.js"></script> 4 <script src="/resources/testharnessreport.js"></script> 5 <script src="/common/utils.js"></script> 6 <script src="/common/dispatcher/dispatcher.js"></script> 7 <script src="resources/utils.js"></script> 8 9 <body> 10 <script> 11 async function runTest(first_url_opaque, second_url_opaque) { 12 const frame = await attachFencedFrameContext({generator_api: 'fledge'}); 13 let base_url = frame.src; 14 let fragment_url = base_url + "#foo"; 15 16 if (first_url_opaque) { 17 base_url = await generateURNFromFledge(base_url, []); 18 } 19 20 if (second_url_opaque) { 21 fragment_url = await generateURNFromFledge(fragment_url, []); 22 } 23 24 // Start the fenced frame at about:blank. 25 await frame.execute(() => { 26 window.executor.suspend(() => { location.href = "about:blank"; }); 27 }); 28 29 // Navigate the fenced frame to the base url from the embedder, and then 30 // suspend the remote executor. 31 frame.src = base_url; 32 await frame.execute(() => { window.executor.suspend(() => {}); }); 33 34 // Navigate the fenced frame to the fragment url from the embedder. Now 35 // the remote executor will only exist if the navigation wasn't considered 36 // same-document. 37 frame.src = fragment_url; 38 await frame.execute(() => {}); 39 } 40 41 promise_test(async () => { await runTest(true, true); }, 42 "opaque to opaque fragment navigation"); 43 promise_test(async () => { await runTest(true, false); }, 44 "opaque to transparent fragment navigation"); 45 promise_test(async () => { await runTest(false, true); }, 46 "transparent to opaque fragment navigation"); 47 promise_test(async () => { await runTest(false, false); }, 48 "transparent to transparent fragment navigation"); 49 </script> 50 </body>