embedded-opener.html (1176B)
1 <!doctype html> 2 <title>opener and embedded documents; using window.open()</title> 3 <script src=/resources/testharness.js></script> 4 <script src=/resources/testharnessreport.js></script> 5 <div id=log></div> 6 <iframe name=matchesastring></iframe> 7 <script> 8 async_test(t => { 9 const frame = document.querySelector("iframe"); 10 frame.onload = t.step_func(() => { 11 // Firefox and Chrome/Safari load differently 12 if (frame.contentWindow.location.href === "about:blank") { 13 return; 14 } 15 16 // Test bits 17 assert_equals(frame.contentWindow.opener, window, "opener before setting it to null"); 18 19 const openerDesc = Object.getOwnPropertyDescriptor(frame.contentWindow, "opener"), 20 openerGet = openerDesc.get; 21 22 assert_equals(openerGet(), window, "opener before setting it to null via directly invoking the getter"); 23 frame.contentWindow.opener = null; 24 frame.contentWindow.opener = "immaterial"; 25 assert_equals(openerGet(), null, "opener after setting it to null via directly invoking the getter"); 26 assert_equals(frame.contentWindow.opener, "immaterial"); 27 28 t.done(); 29 }); 30 window.open("/common/blank.html", "matchesastring"); 31 }); 32 </script>