Title: [176330] trunk/LayoutTests
Revision
176330
Author
[email protected]
Date
2014-11-19 12:46:36 -0800 (Wed, 19 Nov 2014)

Log Message

Add layout test for DOM timer throttling and element moving into view after layout
https://bugs.webkit.org/show_bug.cgi?id=138874

Reviewed by Simon Fraser.

Add a layout test to make sure we unthrottle a DOM timer changing the
style of an element outside viewport if the element ends up inside
the viewport after layout.

* fast/dom/timer-unthrottle-on-layout-expected.txt: Added.
* fast/dom/timer-unthrottle-on-layout.html: Added.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (176329 => 176330)


--- trunk/LayoutTests/ChangeLog	2014-11-19 19:16:23 UTC (rev 176329)
+++ trunk/LayoutTests/ChangeLog	2014-11-19 20:46:36 UTC (rev 176330)
@@ -1,5 +1,19 @@
 2014-11-19  Chris Dumez  <[email protected]>
 
+        Add layout test for DOM timer throttling and element moving into view after layout
+        https://bugs.webkit.org/show_bug.cgi?id=138874
+
+        Reviewed by Simon Fraser.
+
+        Add a layout test to make sure we unthrottle a DOM timer changing the
+        style of an element outside viewport if the element ends up inside
+        the viewport after layout.
+
+        * fast/dom/timer-unthrottle-on-layout-expected.txt: Added.
+        * fast/dom/timer-unthrottle-on-layout.html: Added.
+
+2014-11-19  Chris Dumez  <[email protected]>
+
         Add layout test for DOM timers throttling and 0 height element with visible overflowing content
         https://bugs.webkit.org/show_bug.cgi?id=138873
 

Added: trunk/LayoutTests/fast/dom/timer-unthrottle-on-layout-expected.txt (0 => 176330)


--- trunk/LayoutTests/fast/dom/timer-unthrottle-on-layout-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/fast/dom/timer-unthrottle-on-layout-expected.txt	2014-11-19 20:46:36 UTC (rev 176330)
@@ -0,0 +1,19 @@
+Tests that a repeating timer changing the style of an element outside viewport gets unthrottled if the elements is inside the viewport after layout.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS internals.isTimerThrottled(timeoutId) is false
+5th iteration, timer should be throttled as the element is outside the viewport.
+PASS wasThrottled is true
+Timer should still be throttled before layout.
+PASS internals.isTimerThrottled(timeoutId) is true
+Forcing layout
+Timer should no longer be throttled
+PASS internals.isTimerThrottled(timeoutId) is false
+6th iteration, timer should still be unthrottled.
+PASS internals.isTimerThrottled(timeoutId) is false
+PASS successfullyParsed is true
+
+TEST COMPLETE
+

Added: trunk/LayoutTests/fast/dom/timer-unthrottle-on-layout.html (0 => 176330)


--- trunk/LayoutTests/fast/dom/timer-unthrottle-on-layout.html	                        (rev 0)
+++ trunk/LayoutTests/fast/dom/timer-unthrottle-on-layout.html	2014-11-19 20:46:36 UTC (rev 176330)
@@ -0,0 +1,60 @@
+<!DOCTYPE html>
+<body>
+<script src=""
+<div style="position: relative; width: 1600px; height: 2400px; background-color: green;">
+  <div id="parentDiv" style="position:absolute; left: 600px; top: 800px;"> <input id="textbox" type="text"></div>
+</div>
+<script>
+description("Tests that a repeating timer changing the style of an element outside viewport gets unthrottled if the elements is inside the viewport after layout.");
+jsTestIsAsync = true;
+
+var testElement = document.getElementById('textbox');
+var iterationCount = 0;
+var wasThrottled = false;
+var wasThrottledBeforeScroll = false;
+var timeoutId;
+
+function moveElementInsideViewport()
+{
+  debug("5th iteration, timer should be throttled as the element is outside the viewport.");
+  shouldBeTrue("wasThrottled");
+
+  var parentDiv = document.getElementById("parentDiv");
+  parentDiv.style["top"] = "100px";
+
+  debug("Timer should still be throttled before layout.");
+  shouldBeTrue("internals.isTimerThrottled(timeoutId)");
+
+  debug("Forcing layout");
+  parentDiv.offsetTop;
+
+  debug("Timer should no longer be throttled");
+  shouldBeFalse("internals.isTimerThrottled(timeoutId)");
+}
+
+function timerCallback()
+{
+  ++iterationCount;
+  // Change the style of the element while it is outside viewport.
+  testElement.style["opacity"] = "" + (iterationCount / 10.);
+
+  // 5 iterations should be sufficient to throttle the timer.
+  if (iterationCount == 5) {
+    // Do not use shouldBeTrue() because it would cause a DOM tree mutation
+    // and unthrottle the timer.
+    wasThrottled = internals.isTimerThrottled(timeoutId);
+    setTimeout(moveElementInsideViewport, 0);
+  } else if (iterationCount == 6) {
+    debug("6th iteration, timer should still be unthrottled.");
+    shouldBeFalse("internals.isTimerThrottled(timeoutId)");
+
+    clearInterval(timeoutId);
+    finishJSTest();
+  }
+}
+
+timeoutId = setInterval(timerCallback, 0);
+shouldBeFalse("internals.isTimerThrottled(timeoutId)");
+</script>
+<script src=""
+</body>
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to