From b0806cd76059dc970bebc40df7bf7699144b6854 Mon Sep 17 00:00:00 2001 From: Anne van Kesteren Date: Thu, 7 Mar 2019 13:58:52 +0100 Subject: [PATCH] HTML: test WindowProxy self references For https://github.com/whatwg/html/pull/4410. --- .../the-window-object/self-et-al.window.js | 26 +++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 html/browsers/the-window-object/self-et-al.window.js diff --git a/html/browsers/the-window-object/self-et-al.window.js b/html/browsers/the-window-object/self-et-al.window.js new file mode 100644 index 00000000000000..3deab0c3e02b75 --- /dev/null +++ b/html/browsers/the-window-object/self-et-al.window.js @@ -0,0 +1,26 @@ +[ + "frames", + "globalThis", + "self", + "window" +].forEach(windowProxySelfReference => { + test(() => { + const frame = document.body.appendChild(document.createElement("iframe")), + otherW = frame.contentWindow; + assert_equals(otherW[windowProxySelfReference], otherW); + frame.remove(); + assert_equals(otherW[windowProxySelfReference], otherW); + }, `iframeWindow.${windowProxySelfReference} before and after removal`); + + async_test(t => { + const otherW = window.open(); + assert_equals(otherW[windowProxySelfReference], otherW); + otherW.close(); + assert_equals(otherW[windowProxySelfReference], otherW); + t.step_timeout(() => { + assert_equals(otherW.opener, null); // Ensure browsing context is discarded + assert_equals(otherW[windowProxySelfReference], otherW); + t.done(); + }, 250); + }, `popupWindow.${windowProxySelfReference} before, after closing, and after discarding`) +});