Bug 1454077 [wpt PR 10422] - [cssom] Add tests for some recent CSSWG resolutions., a=testonly
authorEmilio Cobos Álvarez <emilio@crisal.io>
Sun, 22 Apr 2018 15:15:32 +0000
changeset 468883 de7ca81cd124d691b43c30172901697d04a3cdfe
parent 468882 1679673e1d64e59a265d8a08f5c883d9c3a78eb5
child 468884 c52b25482f97ad671966ca7890526afedef92484
push id9165
push userasasaki@mozilla.com
push dateThu, 26 Apr 2018 21:04:54 +0000
treeherdermozilla-beta@064c3804de2e [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerstestonly
bugs1454077, 10422
milestone61.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 1454077 [wpt PR 10422] - [cssom] Add tests for some recent CSSWG resolutions., a=testonly Automatic update from web-platform-testsMerge pull request #10422 from emilio/cssom-woes [cssom] Add tests for some recent CSSWG resolutions. -- wpt-commits: 0e0344a7c493cf47088b776cb55c75e5f1d015c8 wpt-pr: 10422
testing/web-platform/meta/MANIFEST.json
testing/web-platform/tests/css/cssom/getComputedStyle-detached-subtree.html
testing/web-platform/tests/css/cssom/getComputedStyle-dynamic-subdoc.html
testing/web-platform/tests/css/cssom/getComputedStyle-pseudo.html
--- a/testing/web-platform/meta/MANIFEST.json
+++ b/testing/web-platform/meta/MANIFEST.json
@@ -321776,16 +321776,22 @@
     ]
    ],
    "css/cssom/font-shorthand-serialization.html": [
     [
      "/css/cssom/font-shorthand-serialization.html",
      {}
     ]
    ],
+   "css/cssom/getComputedStyle-detached-subtree.html": [
+    [
+     "/css/cssom/getComputedStyle-detached-subtree.html",
+     {}
+    ]
+   ],
    "css/cssom/getComputedStyle-dynamic-subdoc.html": [
     [
      "/css/cssom/getComputedStyle-dynamic-subdoc.html",
      {}
     ]
    ],
    "css/cssom/getComputedStyle-pseudo.html": [
     [
@@ -537659,22 +537665,26 @@
   "css/cssom/escape.html": [
    "c9ed57c7ef7a035c25feff4ea60547a57d727f31",
    "testharness"
   ],
   "css/cssom/font-shorthand-serialization.html": [
    "9d0bce1c0d74bf90aca1eb8ee6aa2e2ed2b92b30",
    "testharness"
   ],
+  "css/cssom/getComputedStyle-detached-subtree.html": [
+   "72b04b3245851e5a5ac26429986074e07ad369d9",
+   "testharness"
+  ],
   "css/cssom/getComputedStyle-dynamic-subdoc.html": [
-   "45d94c17f0a88877a8218135c94d331afcdf7df4",
+   "3f379487727d9730de9e3569b26632c35d602d9d",
    "testharness"
   ],
   "css/cssom/getComputedStyle-pseudo.html": [
-   "a2033405d6852cdeb4c3b8cf628f7c1d8f7cd1aa",
+   "d3ef09fb6092078562f8923879b9ece97938df47",
    "testharness"
   ],
   "css/cssom/historical.html": [
    "02b135e62439d775d7e8de7ca94c831a8d00e077",
    "testharness"
   ],
   "css/cssom/inline-style-001.html": [
    "4c58b6153eabe796749dcaf181e03d7dce2c9c07",
new file mode 100644
--- /dev/null
+++ b/testing/web-platform/tests/css/cssom/getComputedStyle-detached-subtree.html
@@ -0,0 +1,44 @@
+<!doctype html>
+<meta charset="utf-8">
+<title>CSSOM: getComputedStyle returns no style for elements not in the tree</title>
+<link rel="help" href="https://drafts.csswg.org/cssom/#dom-window-getcomputedstyle">
+<link rel="author" title="Emilio Cobos Álvarez" href="mailto:emilio@crisal.io">
+<script src=/resources/testharness.js></script>
+<script src=/resources/testharnessreport.js></script>
+<div id="host">
+  <div id="non-slotted">
+    <div id="non-slotted-descendant"></div>
+  </div>
+</div>
+<iframe srcdoc="<html></html>" style="display: none"></iframe>
+<script>
+function testNoComputedStyle(element, description) {
+  test(function() {
+    assert_true(!!element);
+    let style = getComputedStyle(element);
+    assert_true(!!style);
+    assert_equals(style.length, 0);
+    assert_equals(style.color, "");
+  }, `getComputedStyle returns no style for ${description}`);
+}
+
+let detached = document.createElement('div');
+testNoComputedStyle(detached, "detached element");
+
+testNoComputedStyle(document.querySelector('iframe').contentDocument.documentElement,
+                    "element in non-rendered iframe (display: none)");
+
+host.attachShadow({ mode: "open" });
+testNoComputedStyle(document.getElementById('non-slotted'),
+                    "element outside the flat tree");
+
+testNoComputedStyle(document.getElementById('non-slotted-descendant'),
+                    "descendant outside the flat tree");
+
+let shadowRoot = detached.attachShadow({ mode: "open" });
+shadowRoot.innerHTML = `
+  <div id="detached-shadow-tree-descendant"></div>
+`;
+testNoComputedStyle(shadowRoot.getElementById('detached-shadow-tree-descendant'),
+                    "shadow tree outside of flattened tree");
+</script>
--- a/testing/web-platform/tests/css/cssom/getComputedStyle-dynamic-subdoc.html
+++ b/testing/web-platform/tests/css/cssom/getComputedStyle-dynamic-subdoc.html
@@ -1,19 +1,15 @@
 <!doctype html>
 <meta charset="utf-8">
 <title>CSSOM: getComputedStyle cross-doc properly reflects media query changes</title>
 <link rel="help" href="https://drafts.csswg.org/cssom/#dom-window-getcomputedstyle">
 <link rel="author" title="Emilio Cobos Álvarez" href="mailto:emilio@crisal.io">
 <script src=/resources/testharness.js></script>
 <script src=/resources/testharnessreport.js></script>
-<!--
-  NOTE: The way this test is written doesn't match the spec, but matches all
-  implementations, see https://github.com/w3c/csswg-drafts/issues/2403
--->
 <iframe id="frm" style="width: 100px; height: 100px"></iframe>
 <script>
 test(function() {
   let frm = document.getElementById('frm');
   let frmDoc = frm.contentWindow.document;
   frmDoc.open();
   frmDoc.write('<style>body { color: red } @media all and (min-width: 101px) { body { color: green } }</style><body>Should be green</body>');
   frmDoc.close();
--- a/testing/web-platform/tests/css/cssom/getComputedStyle-pseudo.html
+++ b/testing/web-platform/tests/css/cssom/getComputedStyle-pseudo.html
@@ -104,9 +104,14 @@ test(function() {
     assert_equals(getComputedStyle(contentsPseudos, pseudo).display, "contents",
                   "display: contents in " + pseudo + " should get reflected on CSSOM");
     assert_equals(getComputedStyle(contentsPseudos, pseudo).width, "auto",
                   pseudo + " with display: contents should have no box");
     assert_equals(getComputedStyle(contentsPseudos, pseudo).position, "absolute",
                   "display: contents in " + pseudo + " should reflect other non-inherited properties in CSSOM");
   });
 }, "display: contents on pseudo-elements");
+test(function() {
+  var div = document.getElementById('test');
+  assert_throws(new TypeError(), () => getComputedStyle(div, "totallynotapseudo"),
+                "getComputedStyle with an unknown pseudo-element throws");
+}, "Unknown pseudo-elements throw");
 </script>