Bug 1330375 - P4: GetInnerText perf regression test. r?heycam draft
authorDan Glastonbury <dan.glastonbury@gmail.com>
Thu, 19 Jul 2018 17:34:48 +1000
changeset 821880 9a4a3e55464fbf3c98b2279fbe5270eca3809734
parent 821879 136f510174446c969de7a6077a31c105b8a92a8a
push id117207
push userbmo:dglastonbury@mozilla.com
push dateTue, 24 Jul 2018 05:13:45 +0000
reviewersheycam
bugs1330375
milestone63.0a1
Bug 1330375 - P4: GetInnerText perf regression test. r?heycam Mochitest to ensure that that zero reflows occur while iterating table calling innerText and setting `display:none`. MozReview-Commit-ID: K5vrsj3ogWy
layout/style/test/mochitest.ini
layout/style/test/test_bug1330375.html
--- a/layout/style/test/mochitest.ini
+++ b/layout/style/test/mochitest.ini
@@ -147,16 +147,17 @@ support-files = file_bug829816.css
 [test_bug1055933.html]
 support-files = file_bug1055933_circle-xxl.png
 [test_bug1089417.html]
 support-files = file_bug1089417_iframe.html
 [test_bug1112014.html]
 [test_bug1203766.html]
 [test_bug1232829.html]
 [test_bug1292447.html]
+[test_bug1330375.html]
 [test_bug1371488.html]
 [test_bug1375944.html]
 support-files = file_bug1375944.html Ahem.ttf
 [test_bug1382568.html]
 support-files = bug1382568-iframe.html
 [test_bug1394302.html]
 [test_bug1443344-1.html]
 scheme = https
new file mode 100644
--- /dev/null
+++ b/layout/style/test/test_bug1330375.html
@@ -0,0 +1,59 @@
+<!DOCTYPE html>
+<!-- https://bugzil.la/1330375 -->
+<meta charset="utf-8">
+<title>Test for Bug 1330375</title>
+<script src="/tests/SimpleTest/SimpleTest.js"></script>
+<link rel="stylesheet" type="text/css" href="/tests/SimpleTest.css"/>
+<body>
+    <div id="content">
+        <table>
+            <tbody>
+                <tr><td>lorem ipsum</td><td>dolor sit</td><td>amet</td><td>consectetur adipsicing</td><td>elit.</td></tr>
+                <tr><td>lorem ipsum</td><td>dolor sit</td><td>amet</td><td>consectetur adipsicing</td><td>elit.</td></tr>
+                <tr><td>lorem ipsum</td><td>dolor sit</td><td>amet</td><td>consectetur adipsicing</td><td>elit.</td></tr>
+                <tr><td>lorem ipsum</td><td>dolor sit</td><td>amet</td><td>consectetur adipsicing</td><td>elit.</td></tr>
+                <tr><td>lorem ipsum</td><td>dolor sit</td><td>amet</td><td>consectetur adipsicing</td><td>elit.</td></tr>
+                <tr><td>lorem ipsum</td><td>dolor sit</td><td>amet</td><td>consectetur adipsicing</td><td>elit.</td></tr>
+                <tr><td>lorem ipsum</td><td>dolor sit</td><td>amet</td><td>consectetur adipsicing</td><td>elit.</td></tr>
+                <tr><td>lorem ipsum</td><td>dolor sit</td><td>amet</td><td>consectetur adipsicing</td><td>elit.</td></tr>
+                <tr><td>lorem ipsum</td><td>dolor sit</td><td>amet</td><td>consectetur adipsicing</td><td>elit.</td></tr>
+                <tr><td>lorem ipsum</td><td>dolor sit</td><td>amet</td><td>consectetur adipsicing</td><td>elit.</td></tr>
+            </tbody>
+        </table>
+    </div>
+</body>
+<script>
+"use strict";
+
+const gUtils = SpecialPowers.getDOMWindowUtils(window);
+
+function flush_layout(element) {
+  (element || document.documentElement).offsetHeight;
+}
+
+SimpleTest.waitForExplicitFinish();
+
+window.onload = function() {
+  flush_layout(document.getElementById("content"));
+
+  let before = {
+      framesConstructed: gUtils.framesConstructed,
+      framesReflowed: gUtils.framesReflowed,
+  };
+
+  // Begin test
+  let rows = document.getElementsByTagName("tr");
+  for (var r = 0; r < rows.length; r++) {
+    let row = rows[r];
+    row.innerText;
+    // Cause potential invalidation of layout:
+    row.style.display = "none";
+  }
+
+  is(gUtils.framesConstructed, before.framesConstructed, "Frames constructed should be 0");
+  is(gUtils.framesReflowed, before.framesReflowed, "Frames reflowed should be 0");
+
+  SimpleTest.finish();
+}
+</script>
+