Bug 1457434 [wpt PR 10679] - HTML: document.open() and quirks mode, a=testonly
authorAnne van Kesteren <annevk@annevk.nl>
Sat, 01 Sep 2018 00:39:11 +0000
changeset 434490 8b0337601145a221f5ec07c725f732ed1cb3e090
parent 434480 5e069742950476fd81c546df7b26384a51d6cd7b
child 434491 69b98c18efc11813724e690b26bd3b9852b2c0f4
push id34563
push userdvarga@mozilla.com
push dateMon, 03 Sep 2018 21:54:32 +0000
treeherdermozilla-central@d14aaf65a80b [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerstestonly
bugs1457434, 10679
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 1457434 [wpt PR 10679] - HTML: document.open() and quirks mode, a=testonly Automatic update from web-platform-testsHTML: document.open() and quirks mode For https://github.com/whatwg/html/pull/3966. -- wpt-commits: 5c0f55eea08d3f00dc761cff4ef1dbb9864bee29 wpt-pr: 10679
testing/web-platform/meta/MANIFEST.json
testing/web-platform/tests/html/webappapis/dynamic-markup-insertion/opening-the-input-stream/quirks.window.js
--- a/testing/web-platform/meta/MANIFEST.json
+++ b/testing/web-platform/meta/MANIFEST.json
@@ -365851,16 +365851,22 @@
     ]
    ],
    "html/webappapis/dynamic-markup-insertion/opening-the-input-stream/origin-check-in-document-open-same-origin-domain.sub.html": [
     [
      "/html/webappapis/dynamic-markup-insertion/opening-the-input-stream/origin-check-in-document-open-same-origin-domain.sub.html",
      {}
     ]
    ],
+   "html/webappapis/dynamic-markup-insertion/opening-the-input-stream/quirks.window.js": [
+    [
+     "/html/webappapis/dynamic-markup-insertion/opening-the-input-stream/quirks.window.html",
+     {}
+    ]
+   ],
    "html/webappapis/dynamic-markup-insertion/opening-the-input-stream/reload.window.js": [
     [
      "/html/webappapis/dynamic-markup-insertion/opening-the-input-stream/reload.window.html",
      {}
     ]
    ],
    "html/webappapis/dynamic-markup-insertion/opening-the-input-stream/tasks.window.js": [
     [
@@ -608316,16 +608322,20 @@
   "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"
   ],
+  "html/webappapis/dynamic-markup-insertion/opening-the-input-stream/quirks.window.js": [
+   "0ff0bb99443677b8f8844c8ecedef22c408f2bac",
+   "testharness"
+  ],
   "html/webappapis/dynamic-markup-insertion/opening-the-input-stream/reload.window.js": [
    "d6ff9dc7a45425cb688ed4b6c9ea2ab5c1c3ae5c",
    "testharness"
   ],
   "html/webappapis/dynamic-markup-insertion/opening-the-input-stream/resources/aborted-parser-async-frame.html": [
    "d5535630be05ddb466814c503ab086d7176ecbda",
    "support"
   ],
new file mode 100644
--- /dev/null
+++ b/testing/web-platform/tests/html/webappapis/dynamic-markup-insertion/opening-the-input-stream/quirks.window.js
@@ -0,0 +1,74 @@
+test(t => {
+  const frame = document.body.appendChild(document.createElement("iframe"));
+  t.add_cleanup(() => frame.contentDocument.close());
+  assert_equals(frame.contentDocument.compatMode, "BackCompat");
+  frame.contentDocument.open();
+  assert_equals(frame.contentDocument.compatMode, "CSS1Compat");
+  frame.contentDocument.close();
+  assert_equals(frame.contentDocument.compatMode, "BackCompat");
+}, "document.open() sets document to no-quirks mode (write no doctype)");
+
+test(t => {
+  const frame = document.body.appendChild(document.createElement("iframe"));
+  t.add_cleanup(() => frame.contentDocument.close());
+  assert_equals(frame.contentDocument.compatMode, "BackCompat");
+  frame.contentDocument.open();
+  assert_equals(frame.contentDocument.compatMode, "CSS1Compat");
+  frame.contentDocument.write("<!doctype html public");
+  assert_equals(frame.contentDocument.compatMode, "CSS1Compat");
+  frame.contentDocument.write(" \"-//IETF//DTD HTML 3//\"");
+  assert_equals(frame.contentDocument.compatMode, "CSS1Compat");
+  frame.contentDocument.write(">");
+  assert_equals(frame.contentDocument.compatMode, "BackCompat");
+  frame.contentDocument.close();
+  assert_equals(frame.contentDocument.compatMode, "BackCompat");
+}, "document.open() sets document to no-quirks mode (write old doctype)");
+
+test(t => {
+  const frame = document.body.appendChild(document.createElement("iframe"));
+  t.add_cleanup(() => frame.contentDocument.close());
+  assert_equals(frame.contentDocument.compatMode, "BackCompat");
+  frame.contentDocument.open();
+  assert_equals(frame.contentDocument.compatMode, "CSS1Compat");
+  frame.contentDocument.write("<!doctype html");
+  assert_equals(frame.contentDocument.compatMode, "CSS1Compat");
+  frame.contentDocument.write(">");
+  assert_equals(frame.contentDocument.compatMode, "CSS1Compat");
+  frame.contentDocument.close();
+  assert_equals(frame.contentDocument.compatMode, "CSS1Compat");
+}, "document.open() sets document to no-quirks mode (write new doctype)");
+
+// This tests the document.open() call in fact sets the document to no-quirks
+// mode, not limited-quirks mode. It is derived from
+// quirks/blocks-ignore-line-height.html in WPT, as there is no direct way to
+// distinguish between a no-quirks document and a limited-quirks document. It
+// assumes that the user agent passes the linked test, which at the time of
+// writing is all major web browsers.
+test(t => {
+  const frame = document.body.appendChild(document.createElement("iframe"));
+  t.add_cleanup(() => frame.contentDocument.close());
+  assert_equals(frame.contentDocument.compatMode, "BackCompat");
+  frame.contentDocument.open();
+  assert_equals(frame.contentDocument.compatMode, "CSS1Compat");
+
+  // Create the DOM tree manually rather than going through document.write() to
+  // bypass the parser, which resets the document mode.
+  const html = frame.contentDocument.appendChild(frame.contentDocument.createElement("html"));
+  const body = html.appendChild(frame.contentDocument.createElement("body"));
+  assert_equals(frame.contentDocument.body, body);
+  body.innerHTML = `
+    <style>#ref { display:block }</style>
+    <div id=test><font size=1>x</font></div>
+    <font id=ref size=1>x</font>
+    <div id=s_ref>x</div>
+  `;
+  assert_equals(frame.contentDocument.compatMode, "CSS1Compat");
+
+  const idTest = frame.contentDocument.getElementById("test");
+  const idRef = frame.contentDocument.getElementById("ref");
+  const idSRef = frame.contentDocument.getElementById("s_ref");
+  assert_equals(frame.contentWindow.getComputedStyle(idTest).height,
+                frame.contentWindow.getComputedStyle(idSRef).height);
+  assert_not_equals(frame.contentWindow.getComputedStyle(idTest).height,
+                    frame.contentWindow.getComputedStyle(idRef).height);
+}, "document.open() sets document to no-quirks mode, not limited-quirks mode");