Bug 1458813 [wpt PR 10815] - HTML: document.open() and global variables, a=testonly
authorAnne van Kesteren <annevk@annevk.nl>
Wed, 22 Aug 2018 13:17:47 +0000
changeset 488188 bff723cc3832cb0b00fa13a8494ee3aa3bfe74fa
parent 488187 a340f8012724273c45f236d0d2adb1e489008dfb
child 488189 936e291dacf2ead85b5c640962618bc36df8d12d
push id9719
push userffxbld-merge
push dateFri, 24 Aug 2018 17:49:46 +0000
treeherdermozilla-beta@719ec98fba77 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerstestonly
bugs1458813, 10815
milestone63.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1458813 [wpt PR 10815] - HTML: document.open() and global variables, a=testonly Automatic update from web-platform-testsHTML: document.open() and global variables (#10815) For https://github.com/whatwg/html/pull/3918. Several tests were removed as they no longer apply after the change in HTML. The expectations were reversed and moved to the new no-new-global.window.js file. Co-authored-by: Timothy Gu <timothygu99@gmail.com> -- wpt-commits: 70c15a6e508f7460e1584bc8b122ac2cc8f9d6ea wpt-pr: 10815
testing/web-platform/meta/MANIFEST.json
testing/web-platform/tests/html/webappapis/dynamic-markup-insertion/opening-the-input-stream/001.html
testing/web-platform/tests/html/webappapis/dynamic-markup-insertion/opening-the-input-stream/008.html
testing/web-platform/tests/html/webappapis/dynamic-markup-insertion/opening-the-input-stream/009.https.html
testing/web-platform/tests/html/webappapis/dynamic-markup-insertion/opening-the-input-stream/015-1.html
testing/web-platform/tests/html/webappapis/dynamic-markup-insertion/opening-the-input-stream/015.html
testing/web-platform/tests/html/webappapis/dynamic-markup-insertion/opening-the-input-stream/document.open-03-frame.html
testing/web-platform/tests/html/webappapis/dynamic-markup-insertion/opening-the-input-stream/document.open-03.html
testing/web-platform/tests/html/webappapis/dynamic-markup-insertion/opening-the-input-stream/no-new-global.window.js
testing/web-platform/tests/html/webappapis/dynamic-markup-insertion/opening-the-input-stream/resources/global-variables-frame.html
--- a/testing/web-platform/meta/MANIFEST.json
+++ b/testing/web-platform/meta/MANIFEST.json
@@ -288814,16 +288814,21 @@
      {}
     ]
    ],
    "html/webappapis/dynamic-markup-insertion/opening-the-input-stream/resources/encoding-frame.html": [
     [
      {}
     ]
    ],
+   "html/webappapis/dynamic-markup-insertion/opening-the-input-stream/resources/global-variables-frame.html": [
+    [
+     {}
+    ]
+   ],
    "html/webappapis/dynamic-markup-insertion/opening-the-input-stream/resources/set-document-domain.html": [
     [
      {}
     ]
    ],
    "html/webappapis/dynamic-markup-insertion/opening-the-input-stream/type-argument-plaintext-subframe.txt": [
     [
      {}
@@ -364716,22 +364721,16 @@
     ]
    ],
    "html/webappapis/dynamic-markup-insertion/document-writeln/document.writeln-03.html": [
     [
      "/html/webappapis/dynamic-markup-insertion/document-writeln/document.writeln-03.html",
      {}
     ]
    ],
-   "html/webappapis/dynamic-markup-insertion/opening-the-input-stream/001.html": [
-    [
-     "/html/webappapis/dynamic-markup-insertion/opening-the-input-stream/001.html",
-     {}
-    ]
-   ],
    "html/webappapis/dynamic-markup-insertion/opening-the-input-stream/002.html": [
     [
      "/html/webappapis/dynamic-markup-insertion/opening-the-input-stream/002.html",
      {}
     ]
    ],
    "html/webappapis/dynamic-markup-insertion/opening-the-input-stream/004.html": [
     [
@@ -364746,28 +364745,16 @@
     ]
    ],
    "html/webappapis/dynamic-markup-insertion/opening-the-input-stream/006.html": [
     [
      "/html/webappapis/dynamic-markup-insertion/opening-the-input-stream/006.html",
      {}
     ]
    ],
-   "html/webappapis/dynamic-markup-insertion/opening-the-input-stream/008.html": [
-    [
-     "/html/webappapis/dynamic-markup-insertion/opening-the-input-stream/008.html",
-     {}
-    ]
-   ],
-   "html/webappapis/dynamic-markup-insertion/opening-the-input-stream/009.https.html": [
-    [
-     "/html/webappapis/dynamic-markup-insertion/opening-the-input-stream/009.https.html",
-     {}
-    ]
-   ],
    "html/webappapis/dynamic-markup-insertion/opening-the-input-stream/010.html": [
     [
      "/html/webappapis/dynamic-markup-insertion/opening-the-input-stream/010.html",
      {}
     ]
    ],
    "html/webappapis/dynamic-markup-insertion/opening-the-input-stream/011.html": [
     [
@@ -364884,16 +364871,22 @@
     ]
    ],
    "html/webappapis/dynamic-markup-insertion/opening-the-input-stream/mutation-events.window.js": [
     [
      "/html/webappapis/dynamic-markup-insertion/opening-the-input-stream/mutation-events.window.html",
      {}
     ]
    ],
+   "html/webappapis/dynamic-markup-insertion/opening-the-input-stream/no-new-global.window.js": [
+    [
+     "/html/webappapis/dynamic-markup-insertion/opening-the-input-stream/no-new-global.window.html",
+     {}
+    ]
+   ],
    "html/webappapis/dynamic-markup-insertion/opening-the-input-stream/origin-check-in-document-open-basic.html": [
     [
      "/html/webappapis/dynamic-markup-insertion/opening-the-input-stream/origin-check-in-document-open-basic.html",
      {}
     ]
    ],
    "html/webappapis/dynamic-markup-insertion/opening-the-input-stream/origin-check-in-document-open-same-origin-domain.sub.html": [
     [
@@ -605283,44 +605276,32 @@
   "html/webappapis/dynamic-markup-insertion/document-writeln/document.writeln-03.html": [
    "df9a7a15c22d635960112a12db8d18324821863e",
    "testharness"
   ],
   "html/webappapis/dynamic-markup-insertion/document-writeln/original-id.json": [
    "0cc32be6a2368591de06759c92223941f380f9c2",
    "support"
   ],
-  "html/webappapis/dynamic-markup-insertion/opening-the-input-stream/001.html": [
-   "f82d80be7b6b50608699b73a6f8d1b592e0a55c6",
-   "testharness"
-  ],
   "html/webappapis/dynamic-markup-insertion/opening-the-input-stream/002.html": [
    "5584bf9afbff034f5ea68d769afa648e31fe1aaf",
    "testharness"
   ],
   "html/webappapis/dynamic-markup-insertion/opening-the-input-stream/004.html": [
    "3fb443a99314aa26e230fe63d7f58a78141b0a71",
    "testharness"
   ],
   "html/webappapis/dynamic-markup-insertion/opening-the-input-stream/005.html": [
    "e849c31560e8fc55afef26023d80b7ef0886ba85",
    "testharness"
   ],
   "html/webappapis/dynamic-markup-insertion/opening-the-input-stream/006.html": [
    "1dcb92615d085b28d3c9d2a22d744be849158d18",
    "testharness"
   ],
-  "html/webappapis/dynamic-markup-insertion/opening-the-input-stream/008.html": [
-   "36c0a3f3ea11b9f96522cbba22f1006ba42900bb",
-   "testharness"
-  ],
-  "html/webappapis/dynamic-markup-insertion/opening-the-input-stream/009.https.html": [
-   "0d104c9569b37355c24d60fdcad0ca9ed792dcd0",
-   "testharness"
-  ],
   "html/webappapis/dynamic-markup-insertion/opening-the-input-stream/010-1.html": [
    "317e13691d4a94e5861bbb85d7367591d7d1c624",
    "support"
   ],
   "html/webappapis/dynamic-markup-insertion/opening-the-input-stream/010-2.html": [
    "ea537fcd6018fab07cb58132a2523d82cb8783de",
    "support"
   ],
@@ -605356,21 +605337,21 @@
    "0e978081166e241baa6fc9737d10920040de54e9",
    "support"
   ],
   "html/webappapis/dynamic-markup-insertion/opening-the-input-stream/014.html": [
    "b4e4b17cf4f88d95727d943b00515f284807c30f",
    "testharness"
   ],
   "html/webappapis/dynamic-markup-insertion/opening-the-input-stream/015-1.html": [
-   "dffbac0c04116c67492bca5fee606e2c958afbae",
+   "c325bd08015fc66b0fe7a95a13da6fe461a9afa7",
    "support"
   ],
   "html/webappapis/dynamic-markup-insertion/opening-the-input-stream/015.html": [
-   "5ef06176ba0a1f253da0afe28fc0ea68e745ec30",
+   "cce9e65d4c30a13e11c334b89ff225cac45fbd39",
    "testharness"
   ],
   "html/webappapis/dynamic-markup-insertion/opening-the-input-stream/016-1.html": [
    "12990a560703a5fec869674b4a12027cb07292cc",
    "support"
   ],
   "html/webappapis/dynamic-markup-insertion/opening-the-input-stream/016.html": [
    "1c70fce591a38dd7917e1fffbd1d9ebab46e8b7f",
@@ -605408,21 +605389,21 @@
    "974702ae8cbdbd45704d325d5d7e1e649535bd09",
    "testharness"
   ],
   "html/webappapis/dynamic-markup-insertion/opening-the-input-stream/document.open-02.html": [
    "b56e3a836f46ebe3d902bcbcbca91ac50a6d697d",
    "testharness"
   ],
   "html/webappapis/dynamic-markup-insertion/opening-the-input-stream/document.open-03-frame.html": [
-   "b5252dceab6b63bed93f4c0f6fd23d61097fe7a4",
+   "a4b370cea41fb2d379b0350639aaeec4f169191d",
    "support"
   ],
   "html/webappapis/dynamic-markup-insertion/opening-the-input-stream/document.open-03.html": [
-   "fc325d54db239d729a4b762367576494c9e93490",
+   "e446d7021992cfcac2752f5a63e5821f3d51b022",
    "testharness"
   ],
   "html/webappapis/dynamic-markup-insertion/opening-the-input-stream/encoding.window.js": [
    "f0d133a5329017814f21b206934a554955d15f88",
    "testharness"
   ],
   "html/webappapis/dynamic-markup-insertion/opening-the-input-stream/event-listeners.window.js": [
    "58ec08f9ff110a458f02660ba18e97513f569173",
@@ -605431,16 +605412,20 @@
   "html/webappapis/dynamic-markup-insertion/opening-the-input-stream/ignore-opens-during-unload.window.js": [
    "43506a22a46da53885a2b5a0888095bc52b460ca",
    "testharness"
   ],
   "html/webappapis/dynamic-markup-insertion/opening-the-input-stream/mutation-events.window.js": [
    "4efbb863c6372a3ee04d11f38d7ee56a44a2ac7d",
    "testharness"
   ],
+  "html/webappapis/dynamic-markup-insertion/opening-the-input-stream/no-new-global.window.js": [
+   "d4a9296fca66d3017c267a8d8951bef2dcbee238",
+   "testharness"
+  ],
   "html/webappapis/dynamic-markup-insertion/opening-the-input-stream/origin-check-in-document-open-basic.html": [
    "118be71af19c88d5fed0a1efe010bbd6868eae9c",
    "testharness"
   ],
   "html/webappapis/dynamic-markup-insertion/opening-the-input-stream/origin-check-in-document-open-same-origin-domain.sub.html": [
    "5e5ca80781809cc509a8eade7ea91e74de92f9a8",
    "testharness"
   ],
@@ -605459,16 +605444,20 @@
   "html/webappapis/dynamic-markup-insertion/opening-the-input-stream/resources/document-open-side-effects.js": [
    "7cb86dcba0236d1e161989e95de172ebbf7852e0",
    "support"
   ],
   "html/webappapis/dynamic-markup-insertion/opening-the-input-stream/resources/encoding-frame.html": [
    "843c3a2c7988be0b9595bc69887fc75a5a7b304c",
    "support"
   ],
+  "html/webappapis/dynamic-markup-insertion/opening-the-input-stream/resources/global-variables-frame.html": [
+   "0fe189914c3727f8071c4eaaa6cc740aeb7aab93",
+   "support"
+  ],
   "html/webappapis/dynamic-markup-insertion/opening-the-input-stream/resources/set-document-domain.html": [
    "a92a7ae39f8351f97cd865dca5ebe8d4260aa229",
    "support"
   ],
   "html/webappapis/dynamic-markup-insertion/opening-the-input-stream/type-argument-plaintext-subframe.txt": [
    "3e715502b971d4f8282d1e05a8ccfad6f7037910",
    "support"
   ],
deleted file mode 100644
--- a/testing/web-platform/tests/html/webappapis/dynamic-markup-insertion/opening-the-input-stream/001.html
+++ /dev/null
@@ -1,20 +0,0 @@
-<!doctype html>
-<title>Replacement of window object after document.open</title>
-<script src="/resources/testharness.js"></script>
-<script src="/resources/testharnessreport.js"></script>
-<div id="log"></div>
-<iframe></iframe>
-<script>
-var t = async_test();
-
-onload = t.step_func(function() {
-  var iframe = document.getElementsByTagName("iframe")[0];
-  iframe.contentWindow.state = 1;
-  var handle = iframe.contentWindow;
-  iframe.contentDocument.open();
-  assert_false("state" in iframe.contentWindow, "Variables are not preserved after document.open");
-  assert_equals(iframe.contentWindow.state, undefined, "Variables are not preserved after document.open");
-  assert_equals(iframe.contentWindow, handle);
-  t.done();
-});
-</script>
deleted file mode 100644
--- a/testing/web-platform/tests/html/webappapis/dynamic-markup-insertion/opening-the-input-stream/008.html
+++ /dev/null
@@ -1,20 +0,0 @@
-<!doctype html>
-<title>Replacement of document prototype object after document.open</title>
-<script src="/resources/testharness.js"></script>
-<script src="/resources/testharnessreport.js"></script>
-<div id="log"></div>
-<iframe src="/common/blank.html"></iframe>
-<script>
-var t = async_test();
-var iframe;
-onload = t.step_func(function() {
-  var iframe = document.getElementsByTagName("iframe")[0];
-  var handle = Object.getPrototypeOf(iframe.contentDocument);
-  handle.test_state = 1;
-  assert_equals(iframe.contentDocument.open(), iframe.contentDocument);
-  var new_handle = Object.getPrototypeOf(iframe.contentDocument);
-  assert_equals(new_handle.test_state, undefined);
-  assert_not_equals(new_handle, handle);
-  t.done();
-});
-</script>
deleted file mode 100644
--- a/testing/web-platform/tests/html/webappapis/dynamic-markup-insertion/opening-the-input-stream/009.https.html
+++ /dev/null
@@ -1,34 +0,0 @@
-<!doctype html>
-<title>document.open replacing singleton</title>
-<script src="/resources/testharness.js"></script>
-<script src="/resources/testharnessreport.js"></script>
-<div id="log"></div>
-<iframe src="/common/blank.html"></iframe>
-<script>
-var iframe = document.getElementsByTagName("iframe")[0];
-var steps;
-iframe.onload = function() {
-steps = ["window", "location", "history", "navigator", "applicationCache", "sessionStorage", "localStorage", "locationbar"].map(
-function(x) {
-  var t = async_test(document.title + " " + x);
-  var handle = iframe.contentWindow[x];
-  handle.test_state = 1;
-  return t.step_func(
-      function() {
-        var new_handle = iframe.contentWindow[x];
-        assert_equals(new_handle.test_state, undefined);
-        if (x !== "window") {
-          assert_not_equals(new_handle, handle);
-        } else {
-          assert_equals(new_handle, handle);
-        }
-        t.done();
-      });
-  }
-);
-}
-onload = function() {
-  assert_equals(iframe.contentDocument.open(), iframe.contentDocument);
-  steps.forEach(function(x) {x()});
-}
-</script>
--- a/testing/web-platform/tests/html/webappapis/dynamic-markup-insertion/opening-the-input-stream/015-1.html
+++ b/testing/web-platform/tests/html/webappapis/dynamic-markup-insertion/opening-the-input-stream/015-1.html
@@ -1,16 +1,16 @@
 <script>
 onload = function() {
   window.test_prop = 1;
   parent.tests[0].step(function() {parent.assert_equals(test_prop, 1)});
   parent.tests[0].step(function() {parent.assert_equals(document.open(), document)});
   document.write("<script>test_prop = 2;<\/script>");
   document.close();
-  parent.tests[0].step(function() {parent.assert_equals(test_prop, 1)});
+  parent.tests[0].step(function() {parent.assert_equals(test_prop, 2)});
   parent.tests[1].step(function() {parent.assert_equals(window.test_prop, 2)});
   parent.tests[2].step(function() {parent.assert_equals(get_this(), window)});
   parent.tests_done();
 };
 
 function get_this() {
   return this;
 }
--- a/testing/web-platform/tests/html/webappapis/dynamic-markup-insertion/opening-the-input-stream/015.html
+++ b/testing/web-platform/tests/html/webappapis/dynamic-markup-insertion/opening-the-input-stream/015.html
@@ -1,14 +1,14 @@
 <!doctype html>
 <title>Window vs global scope after document.open</title>
 <script src="/resources/testharness.js"></script>
 <script src="/resources/testharnessreport.js"></script>
 <div id="log"></div>
 <script>
 var tests = [async_test("global scope unchanged"),
-             async_test("window object changed"),
+             async_test("window object unchanged"),
              async_test("this is the window object")];
 function tests_done() {
   tests.forEach(function(t) {t.done()});
 }
 </script>
 <iframe src="015-1.html"></iframe>
--- a/testing/web-platform/tests/html/webappapis/dynamic-markup-insertion/opening-the-input-stream/document.open-03-frame.html
+++ b/testing/web-platform/tests/html/webappapis/dynamic-markup-insertion/opening-the-input-stream/document.open-03-frame.html
@@ -1,10 +1,10 @@
 <!DOCTYPE html>
 <script>
 onload = function() {
   document.open();
   document.close();
-  parent.report(window.setTimeout === setTimeout, false, "setTimeout");
+  parent.report(window.setTimeout === setTimeout, true, "setTimeout");
   parent.report(window === this, true, "this");
   parent.done();
 }
 </script>
--- a/testing/web-platform/tests/html/webappapis/dynamic-markup-insertion/opening-the-input-stream/document.open-03.html
+++ b/testing/web-platform/tests/html/webappapis/dynamic-markup-insertion/opening-the-input-stream/document.open-03.html
@@ -1,10 +1,10 @@
 <!DOCTYPE html>
-<title>document.open and singleton replacement</title>
+<title>document.open and no singleton replacement</title>
 <link rel="author" title="Ms2ger" href="mailto:ms2ger@gmail.com">
 <link rel="help" href="https://html.spec.whatwg.org/multipage/#dom-document-open">
 <script src="/resources/testharness.js"></script>
 <script src="/resources/testharnessreport.js"></script>
 <div id="log"></div>
 <script>
 var t = async_test();
 function report(actual, expected, message) {
new file mode 100644
--- /dev/null
+++ b/testing/web-platform/tests/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);
new file mode 100644
--- /dev/null
+++ b/testing/web-platform/tests/html/webappapis/dynamic-markup-insertion/opening-the-input-stream/resources/global-variables-frame.html
@@ -0,0 +1,4 @@
+<!doctype html>
+<script>
+hey = "You";
+</script>