blob-popup.https.html (1669B)
1 <!doctype html> 2 <title>Cross-Origin-Opener-Policy and a blob URL popup</title> 3 <script src=/resources/testharness.js></script> 4 <script src=/resources/testharnessreport.js></script> 5 <script src=/common/get-host-info.sub.js></script> 6 <script src=/common/utils.js></script> 7 <script src=/common/dispatcher/dispatcher.js></script> 8 <script> 9 promise_test(async t => { 10 window.furtherPopup = null; 11 12 const responseToken = token(); 13 const iframeToken = token(); 14 15 const blobContents = `<script> 16 const w = window.open("${get_host_info().HTTPS_REMOTE_ORIGIN}/html/cross-origin-opener-policy/resources/coop-coep.py?coop=x&coep=x&responseToken=${responseToken}&iframeToken=${iframeToken}", "${responseToken}"); 17 window.opener.furtherPopup = w; 18 <\/script>`; 19 const blob = new Blob([blobContents], { type: "text/html" }); 20 const blobURL = URL.createObjectURL(blob); 21 const popup = window.open(blobURL); 22 t.add_cleanup(async () => { 23 // Close the popups once the test is complete. 24 // The browsing context of the second popup is closed hence use the 25 // broadcast channel to trigger the closure. 26 await send(iframeToken, "close"); 27 popup.close(); 28 }); 29 30 let popupOnloadHappened = false; 31 popup.onload = t.step_func(() => { 32 assert_equals(popup.opener, window); 33 assert_equals(popup.location.href, blobURL); 34 assert_equals(popup.document.URL, blobURL); 35 assert_equals(popup.origin, window.origin); 36 popupOnloadHappened = true; 37 }); 38 39 const data = JSON.parse(await receive(responseToken)); 40 41 assert_true(popupOnloadHappened); 42 assert_equals(data.name.length, 0); 43 assert_false(data.opener); 44 assert_true(furtherPopup.closed); 45 }); 46 </script>