Add layout test for DOM timers throttling and 0 height element with visible overflowi...
authorcdumez@apple.com <cdumez@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 19 Nov 2014 18:27:33 +0000 (18:27 +0000)
committercdumez@apple.com <cdumez@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 19 Nov 2014 18:27:33 +0000 (18:27 +0000)
https://bugs.webkit.org/show_bug.cgi?id=138873

Reviewed by Simon Fraser.

Add a layout test for verify that a DOM timer changing the style of a 0
height element with visible overflowing content does not get throttled.
If the implementation did not properly use the overflow rect to
determine if the element is visible, this test would fail.

This covers the case of the top scrolling banner on huffingtonpost.com.

* fast/dom/repeating-timer-element-overflow-throttling-expected.txt: Added.
* fast/dom/repeating-timer-element-overflow-throttling.html: Added.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@176323 268f45cc-cd09-0410-ab3c-d52691b4dbfc

LayoutTests/ChangeLog
LayoutTests/fast/dom/repeating-timer-element-overflow-throttling-expected.txt [new file with mode: 0644]
LayoutTests/fast/dom/repeating-timer-element-overflow-throttling.html [new file with mode: 0644]

index febf675..e5103c7 100644 (file)
@@ -1,3 +1,20 @@
+2014-11-19  Chris Dumez  <cdumez@apple.com>
+
+        Add layout test for DOM timers throttling and 0 height element with visible overflowing content
+        https://bugs.webkit.org/show_bug.cgi?id=138873
+
+        Reviewed by Simon Fraser.
+
+        Add a layout test for verify that a DOM timer changing the style of a 0
+        height element with visible overflowing content does not get throttled.
+        If the implementation did not properly use the overflow rect to
+        determine if the element is visible, this test would fail.
+
+        This covers the case of the top scrolling banner on huffingtonpost.com.
+
+        * fast/dom/repeating-timer-element-overflow-throttling-expected.txt: Added.
+        * fast/dom/repeating-timer-element-overflow-throttling.html: Added.
+
 2014-11-19  Chris Fleizach  <cfleizach@apple.com>
 
         AX: Safari fails to load a web page with VoiceOver
diff --git a/LayoutTests/fast/dom/repeating-timer-element-overflow-throttling-expected.txt b/LayoutTests/fast/dom/repeating-timer-element-overflow-throttling-expected.txt
new file mode 100644 (file)
index 0000000..a4c20c1
--- /dev/null
@@ -0,0 +1,17 @@
+Tests that a repeating timer changing the style of an element with 0 height and visible overflowing content does not get throttled.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS testElement.offsetHeight is 0
+The timer should initially not be throttled.
+PASS internals.isTimerThrottled(timeoutId) is false
+5th iteration, timer should not have been throttled.
+PASS wasThrottled is false
+6th iteration, timer should still be unthrottled.
+PASS internals.isTimerThrottled(timeoutId) is false
+PASS successfullyParsed is true
+
+TEST COMPLETE
+test1
+test2
diff --git a/LayoutTests/fast/dom/repeating-timer-element-overflow-throttling.html b/LayoutTests/fast/dom/repeating-timer-element-overflow-throttling.html
new file mode 100644 (file)
index 0000000..bf49986
--- /dev/null
@@ -0,0 +1,45 @@
+<!DOCTYPE html>
+<body>
+<script src="../../resources/js-test-pre.js"></script>
+<ul id="testElement" style="height: 0;">
+<li>test1</li>
+<li>test2</li>
+</ul>
+<script>
+description("Tests that a repeating timer changing the style of an element with 0 height and visible overflowing content does not get throttled.");
+jsTestIsAsync = true;
+
+var iterationCount = 0;
+var timeoutId;
+var testElement = document.getElementById("testElement");
+var wasThrottled = false;
+
+function timerCallback()
+{
+  ++iterationCount;
+  // Interact with the style of the element.
+  testElement.style["left"] = "" + iterationCount + "px";
+
+  // 5 iterations should suffice to throttle the timer.
+  if (iterationCount == 5) {
+    // Do not use shouldBeTrue() here because it would cause a DOM tree mutation and
+    // unthrottle the DOM Timer.
+    wasThrottled = internals.isTimerThrottled(timeoutId);
+  } else if (iterationCount == 6) {
+    debug("5th iteration, timer should not have been throttled.");
+    shouldBeFalse("wasThrottled");
+    debug("6th iteration, timer should still be unthrottled.");
+    shouldBeFalse("internals.isTimerThrottled(timeoutId)");
+    clearInterval(timeoutId);
+    finishJSTest();
+  }
+}
+
+shouldBe("testElement.offsetHeight", "0");
+
+timeoutId = setInterval(timerCallback, 0);
+debug("The timer should initially not be throttled.");
+shouldBeFalse("internals.isTimerThrottled(timeoutId)");
+</script>
+<script src="../../resources/js-test-post.js"></script>
+</body>