Bug 1330375 - P3: Add WPT test to ensure innerText works with dynamic changes. r?heycam draft
authorDan Glastonbury <dan.glastonbury@gmail.com>
Thu, 12 Jul 2018 13:25:56 +1000
changeset 821879 136f510174446c969de7a6077a31c105b8a92a8a
parent 821878 580bf0dab38832046663ac9598d68229344e4945
child 821880 9a4a3e55464fbf3c98b2279fbe5270eca3809734
push id117207
push userbmo:dglastonbury@mozilla.com
push dateTue, 24 Jul 2018 05:13:45 +0000
reviewersheycam
bugs1330375
milestone63.0a1
Bug 1330375 - P3: Add WPT test to ensure innerText works with dynamic changes. r?heycam To check that changes in P1 still work when layout is required. MozReview-Commit-ID: ArqwDQXQwnR
testing/web-platform/meta/MANIFEST.json
testing/web-platform/tests/html/dom/elements/the-innertext-idl-attribute/dynamic-getter.html
--- a/testing/web-platform/meta/MANIFEST.json
+++ b/testing/web-platform/meta/MANIFEST.json
@@ -184506,16 +184506,28 @@
       [
        "/svg/linking/reftests/use-descendant-combinator-ref.html",
        "=="
       ]
      ],
      {}
     ]
    ],
+   "svg/linking/reftests/use-descendant-combinator-003.html": [
+    [
+     "/svg/linking/reftests/use-descendant-combinator-003.html",
+     [
+      [
+       "/svg/linking/reftests/use-descendant-combinator-ref.html",
+       "=="
+      ]
+     ],
+     {}
+    ]
+   ],
    "svg/painting/currentColor-override-pserver-fallback.svg": [
     [
      "/svg/painting/currentColor-override-pserver-fallback.svg",
      [
       [
        "/svg/painting/currentColor-override-pserver-fallback-ref.svg",
        "=="
       ]
@@ -184542,28 +184554,16 @@
       [
        "/svg/painting/currentColor-override-pserver-stroke-ref.svg",
        "=="
       ]
      ],
      {}
     ]
    ],
-   "svg/linking/reftests/use-descendant-combinator-003.html": [
-    [
-     "/svg/linking/reftests/use-descendant-combinator-003.html",
-     [
-      [
-       "/svg/linking/reftests/use-descendant-combinator-ref.html",
-       "=="
-      ]
-     ],
-     {}
-    ]
-   ],
    "svg/painting/reftests/paint-context-001.svg": [
     [
      "/svg/painting/reftests/paint-context-001.svg",
      [
       [
        "/svg/painting/reftests/paint-context-001-ref.svg",
        "=="
       ]
@@ -342491,16 +342491,22 @@
     ]
    ],
    "html/dom/elements/global-attributes/the-translate-attribute-012.html": [
     [
      "/html/dom/elements/global-attributes/the-translate-attribute-012.html",
      {}
     ]
    ],
+   "html/dom/elements/the-innertext-idl-attribute/dynamic-getter.html": [
+    [
+     "/html/dom/elements/the-innertext-idl-attribute/dynamic-getter.html",
+     {}
+    ]
+   ],
    "html/dom/elements/the-innertext-idl-attribute/getter.html": [
     [
      "/html/dom/elements/the-innertext-idl-attribute/getter.html",
      {}
     ]
    ],
    "html/dom/elements/the-innertext-idl-attribute/multiple-text-nodes.window.js": [
     [
@@ -439003,17 +439009,17 @@
    "ff8d1c26701d15164bcb549d42937825e1f0edd0",
    "testharness"
   ],
   "content-security-policy/securitypolicyviolation/idl.html": [
    "266180135d8167bc47d6c7a73798e87aa1082bee",
    "testharness"
   ],
   "content-security-policy/securitypolicyviolation/img-src-redirect-upgrade-reporting.https.html": [
-   "e338e94ea726419db64ed5b98c95b862c394409e",
+   "f6623c80b2b4be3fd9dd0f5dc0a6417652f1b797",
    "testharness"
   ],
   "content-security-policy/securitypolicyviolation/img-src-redirect-upgrade-reporting.https.html.headers": [
    "960ee8a9f7ccf33ea435890e2eae0e68399f32ed",
    "support"
   ],
   "content-security-policy/securitypolicyviolation/inside-dedicated-worker.html": [
    "46d18c97d554716b714856c00bdc49388d211868",
@@ -439055,17 +439061,17 @@
    "b2d6d11fc189d78f5ea623c52e1d1f64fe53a772",
    "testharness"
   ],
   "content-security-policy/securitypolicyviolation/style-sample.html": [
    "e570217f560f6e7a8917e79266ac9d2e8ea078f6",
    "testharness"
   ],
   "content-security-policy/securitypolicyviolation/support/inside-worker.sub.js": [
-   "f425a7ae6c167bfe9857f08f460897e16bf6ca95",
+   "d94662579190653a3b3e9d076b79d7b0f01f2dc7",
    "support"
   ],
   "content-security-policy/securitypolicyviolation/support/inside-worker.sub.js.headers": [
    "ac19897e2693ba3228640d03c770cd5a33c51381",
    "support"
   ],
   "content-security-policy/securitypolicyviolation/support/testharness-helper.sub.js": [
    "71244cc74fa8f8ee8082c876264e053348905fbd",
@@ -576686,16 +576692,20 @@
   "html/dom/elements/requirements-relating-to-bidirectional-algorithm-formatting-characters/reference/dir-isolation-009b-ref.html": [
    "355953f8ebb44f79bfe3cad728bcaaa3ec04e4bb",
    "support"
   ],
   "html/dom/elements/the-innertext-idl-attribute/META.yml": [
    "45472ac8906e7b383d80ab0b92ecddd6b900f726",
    "support"
   ],
+  "html/dom/elements/the-innertext-idl-attribute/dynamic-getter.html": [
+   "68d7f1a50956a99ac6724aef2f0b4abed3a78bb5",
+   "testharness"
+  ],
   "html/dom/elements/the-innertext-idl-attribute/getter-tests.js": [
    "0ffc6d2bf3011a376f85b45090c63de07ac023d5",
    "support"
   ],
   "html/dom/elements/the-innertext-idl-attribute/getter.html": [
    "bfcd91955e1645278f7825d472bcce03dbc8f773",
    "testharness"
   ],
@@ -619078,16 +619088,20 @@
   "svg/linking/reftests/use-descendant-combinator-001.html": [
    "323fde648ee2d065bfd945a2c4d5be86f1c308ff",
    "reftest"
   ],
   "svg/linking/reftests/use-descendant-combinator-002.html": [
    "3d51ca0fc007d52147e7ea03493cac7ee1bb7903",
    "reftest"
   ],
+  "svg/linking/reftests/use-descendant-combinator-003.html": [
+   "d9155d3b92ecf0735f82ed9a0f2a8fd3fc380d55",
+   "reftest"
+  ],
   "svg/linking/reftests/use-descendant-combinator-ref.html": [
    "fb8aec792684b97151d2964b85d1e70829e141ad",
    "support"
   ],
   "svg/linking/scripted/href-animate-element.html": [
    "c224f6b609079f31c256625417e4677b21b5f71a",
    "testharness"
   ],
@@ -622183,17 +622197,17 @@
    "c95130e1f0226d18fcdd9dc9d5795395d6de586f",
    "support"
   ],
   "webaudio/README.md": [
    "230684ec60fd2e408f9b6014417f3eddfe2dc95a",
    "support"
   ],
   "webaudio/historical.html": [
-   "93068df297042344669093ce899f0230c87ebf54",
+   "c6e3c7d6751731c708edfb0f4e32df8a6a3b80b0",
    "testharness"
   ],
   "webaudio/idlharness.https.html": [
    "0403de985b3346240ba1d4b465a8e0838f3860bc",
    "testharness"
   ],
   "webaudio/js/buffer-loader.js": [
    "4d564eae0b3d7d1045626d1f144cd2638dba64e5",
new file mode 100644
--- /dev/null
+++ b/testing/web-platform/tests/html/dom/elements/the-innertext-idl-attribute/dynamic-getter.html
@@ -0,0 +1,87 @@
+<!DOCTYPE html>
+<title>innerText getter test with dynamic style changes</title>
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<div id="container"></div>
+<script>
+let container = document.querySelector('#container');
+
+function testText(html, expectedPlain, msg, mutate) {
+  test(function() {
+    container.innerHTML = html;
+
+    // Cause a flush of style and layout
+    document.body.offsetTop;
+
+    mutate();
+
+    var e = document.getElementById('target');
+    if (!e) {
+      e = container.firstChild;
+    }
+    assert_equals(e.innerText, expectedPlain);
+    container.textContext = '';
+  }, msg + ' (' + format_value(html) + ')');
+}
+
+function setStyle(id, attr, value) {
+  let el = document.getElementById(id);
+  if (el) {
+    el.style[attr] = value;
+  }
+}
+
+testText("<div id='target'><div id='child'>abc", "ABC",
+         "text-transform applied to child element", function() {
+           setStyle("child", "text-transform", "uppercase");
+         });
+testText("<div id='parent'><div id='target'>abc", "ABC",
+         "text-transform applied to parent element", function() {
+           setStyle("parent", "text-transform", "uppercase");
+         });
+
+testText("<div id='target'>abc<div id='child'>def", "abc",
+         "display: none applied to child element", function() {
+           setStyle("child", "display", "none");
+         });
+testText("<div id='parent'>invisible<div id='target'>abc", "abc",
+         "display: none applied to parent element", function() {
+           setStyle("parent", "display", "none");
+         });
+
+testText("<div id='target'>abc", "abc\ndef",
+         "insert node into sub-tree", function() {
+           let el = document.getElementById("target");
+           if (el) {
+             let c = document.createTextNode("def");
+             let d = document.createElement("div");
+             d.appendChild(c);
+             el.appendChild(d);
+           }
+         });
+
+testText("<div id='target'>abc<div id='remove'>def", "abc",
+         "remove node from sub-tree", function() {
+           let el = document.getElementById("target");
+           let victim = document.getElementById("remove");
+           if (el && victim) {
+             el.removeChild(victim);
+           }
+         });
+
+testText("<div id='target'>", "abcdef",
+         "insert whole sub-tree", function() {
+           var el = document.getElementById("target");
+           if (el) {
+             var def = document.createTextNode("def");
+             var s = document.createElement("span");
+             s.appendChild(def);
+
+             var abc = document.createTextNode("abc");
+             var d = document.createElement("div");
+             d.appendChild(abc);
+             d.appendChild(s);
+             el.appendChild(d);
+           }
+         });
+</script>