self-et-al.window.js (1928B)
1 function delayed_assert_done(t, w, windowProxySelfReference) { 2 // Let's make sure nobody is being sneaky 3 t.step_timeout(() => { 4 t.step_timeout(() => { 5 assert_equals(w[windowProxySelfReference], w, `${windowProxySelfReference} got cleared after some time`); 6 t.done(); 7 }, 0); 8 }, 0); 9 } 10 11 [ 12 "frames", 13 "globalThis", 14 "self", 15 "window" 16 ].forEach(windowProxySelfReference => { 17 async_test(t => { 18 const frame = document.body.appendChild(document.createElement("iframe")), 19 otherW = frame.contentWindow; 20 assert_equals(otherW[windowProxySelfReference], otherW, `${windowProxySelfReference} is broken`); 21 frame.remove(); 22 assert_equals(otherW[windowProxySelfReference], otherW, `${windowProxySelfReference} got cleared after browsing context removal`); 23 assert_true(otherW.closed); 24 25 delayed_assert_done(t, otherW, windowProxySelfReference); 26 }, `iframeWindow.${windowProxySelfReference} before and after removal`); 27 28 async_test(t => { 29 const otherW = window.open(); 30 assert_equals(otherW[windowProxySelfReference], otherW, `${windowProxySelfReference} is broken`); 31 otherW.onpagehide = t.step_func(() => { 32 assert_equals(otherW[windowProxySelfReference], otherW, `${windowProxySelfReference} got cleared after browsing context pagehide`); 33 t.step_timeout(() => { 34 assert_equals(otherW.opener, null); // Ensure browsing context is discarded 35 assert_equals(otherW[windowProxySelfReference], otherW, `${windowProxySelfReference} got cleared after browsing context removal`); 36 delayed_assert_done(t, otherW, windowProxySelfReference); 37 }, 0); 38 }); 39 otherW.close(); 40 assert_equals(otherW[windowProxySelfReference], otherW, `${windowProxySelfReference} got cleared after browsing context closure`); 41 assert_true(otherW.closed); 42 }, `popupWindow.${windowProxySelfReference} before, after closing, and after discarding`) 43 });