diff --git a/html/webappapis/dynamic-markup-insertion/opening-the-input-stream/001.html b/html/webappapis/dynamic-markup-insertion/opening-the-input-stream/001.html deleted file mode 100644 index f82d80be7b6b50..00000000000000 --- a/html/webappapis/dynamic-markup-insertion/opening-the-input-stream/001.html +++ /dev/null @@ -1,20 +0,0 @@ - -Replacement of window object after document.open - - -
- - diff --git a/html/webappapis/dynamic-markup-insertion/opening-the-input-stream/008.html b/html/webappapis/dynamic-markup-insertion/opening-the-input-stream/008.html deleted file mode 100644 index 36c0a3f3ea11b9..00000000000000 --- a/html/webappapis/dynamic-markup-insertion/opening-the-input-stream/008.html +++ /dev/null @@ -1,20 +0,0 @@ - -Replacement of document prototype object after document.open - - -
- - diff --git a/html/webappapis/dynamic-markup-insertion/opening-the-input-stream/009.https.html b/html/webappapis/dynamic-markup-insertion/opening-the-input-stream/009.https.html deleted file mode 100644 index 0d104c9569b373..00000000000000 --- a/html/webappapis/dynamic-markup-insertion/opening-the-input-stream/009.https.html +++ /dev/null @@ -1,34 +0,0 @@ - -document.open replacing singleton - - -
- - diff --git a/html/webappapis/dynamic-markup-insertion/opening-the-input-stream/015-1.html b/html/webappapis/dynamic-markup-insertion/opening-the-input-stream/015-1.html index dffbac0c04116c..c325bd08015fc6 100644 --- a/html/webappapis/dynamic-markup-insertion/opening-the-input-stream/015-1.html +++ b/html/webappapis/dynamic-markup-insertion/opening-the-input-stream/015-1.html @@ -5,7 +5,7 @@ parent.tests[0].step(function() {parent.assert_equals(document.open(), document)}); document.write(" diff --git a/html/webappapis/dynamic-markup-insertion/opening-the-input-stream/no-new-global.window.js b/html/webappapis/dynamic-markup-insertion/opening-the-input-stream/no-new-global.window.js new file mode 100644 index 00000000000000..d4a9296fca66d3 --- /dev/null +++ b/html/webappapis/dynamic-markup-insertion/opening-the-input-stream/no-new-global.window.js @@ -0,0 +1,57 @@ +// In an earlier version of the HTML Standard, document open steps created a +// new JavaScript realm and migrated the existing objects to use the new realm. +// Test that this no longer happens. + +async_test(t => { + const frame = document.body.appendChild(document.createElement("iframe")); + // Ensure a load event gets dispatched to unblock testharness + t.add_cleanup(() => frame.remove()); + frame.src = "resources/global-variables-frame.html"; + frame.onload = t.step_func_done(() => { + assert_equals(frame.contentWindow.hey, "You", "precondition"); + frame.contentDocument.open(); + assert_equals(frame.contentWindow.hey, "You", "actual check"); + }); +}, "Obtaining a variable from a global whose document had open() invoked"); + +function testIdentity(desc, frameToObject, frameToConstructor) { + async_test(t => { + const frame = document.body.appendChild(document.createElement("iframe")); + // Ensure a load event gets dispatched to unblock testharness + t.add_cleanup(() => frame.remove()); + frame.src = "/common/blank.html"; + frame.onload = t.step_func_done(() => { + const obj = frameToObject(frame); + frame.contentDocument.open(); + assert_equals(frameToObject(frame), obj); + }); + }, `${desc} maintains object identity through open()`); + + async_test(t => { + const frame = document.body.appendChild(document.createElement("iframe")); + // Ensure a load event gets dispatched to unblock testharness + t.add_cleanup(() => frame.remove()); + frame.src = "/common/blank.html"; + frame.onload = t.step_func_done(() => { + const obj = frameToObject(frame); + const origProto = Object.getPrototypeOf(obj); + const origCtor = frameToConstructor(frame); + const sym = Symbol(); + obj[sym] = "foo"; + frame.contentDocument.open(); + assert_equals(frameToObject(frame)[sym], "foo"); + assert_true(frameToObject(frame) instanceof origCtor); + assert_equals(Object.getPrototypeOf(frameToObject(frame)), origProto); + assert_equals(frameToConstructor(frame), origCtor); + }); + }, `${desc} maintains its prototype and properties through open()`); +} + +testIdentity("Document", frame => frame.contentDocument, frame => frame.contentWindow.Document); +testIdentity("WindowProxy", frame => frame.contentWindow, frame => frame.contentWindow.Window); +testIdentity("BarProp", frame => frame.contentWindow.locationbar, frame => frame.contentWindow.BarProp); +testIdentity("History", frame => frame.contentWindow.history, frame => frame.contentWindow.History); +testIdentity("localStorage", frame => frame.contentWindow.localStorage, frame => frame.contentWindow.Storage); +testIdentity("Location", frame => frame.contentWindow.location, frame => frame.contentWindow.Location); +testIdentity("sessionStorage", frame => frame.contentWindow.sessionStorage, frame => frame.contentWindow.Storage); +testIdentity("Navigator", frame => frame.contentWindow.navigator, frame => frame.contentWindow.Navigator); diff --git a/html/webappapis/dynamic-markup-insertion/opening-the-input-stream/resources/global-variables-frame.html b/html/webappapis/dynamic-markup-insertion/opening-the-input-stream/resources/global-variables-frame.html new file mode 100644 index 00000000000000..0fe189914c3727 --- /dev/null +++ b/html/webappapis/dynamic-markup-insertion/opening-the-input-stream/resources/global-variables-frame.html @@ -0,0 +1,4 @@ + +