Bug 1358759. Fix intermittent failures of layout/base/tests/test_bug114649.html. r=dholbert, a=test-only
authorJonathan Watt <jwatt@jwatt.org>
Mon, 01 Apr 2019 20:05:07 +0100
changeset 526051 ba272d4ecc9a70414ac50890f2f772afbdfe1b36
parent 526050 c0312564e277208e3693e46ce69f7998d3673c56
child 526052 6fb04d1496a957a936558913a2a6dcca38e28537
push id2032
push userffxbld-merge
push dateMon, 13 May 2019 09:36:57 +0000
treeherdermozilla-release@455c1065dcbe [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersdholbert, test-only
bugs1358759, 114649
milestone67.0
Bug 1358759. Fix intermittent failures of layout/base/tests/test_bug114649.html. r=dholbert, a=test-only Differential Revision: https://phabricator.services.mozilla.com/D25655
layout/base/tests/test_bug114649.html
--- a/layout/base/tests/test_bug114649.html
+++ b/layout/base/tests/test_bug114649.html
@@ -15,53 +15,64 @@ https://bugzilla.mozilla.org/show_bug.cg
 <script type="application/javascript">
 
 /** Test for Bug 114649 **/
 
 var gIFrame;
 var gCurrentWidth = 500;
 var gGotEventsAt = [];
 var gInterval;
+var gFinished = false;
 
 function run() {
     SimpleTest.waitForExplicitFinish();
-    SimpleTest.requestFlakyTimeout("untriaged");
+    SimpleTest.requestFlakyTimeout("Simulating dragging to resize a window");
 
     gIFrame = document.getElementById("display");
 
     var subdoc = gIFrame.contentDocument;
     subdoc.open();
-    subdoc.write("<body onresize='window.parent.handle_child_resize()'>");
+    subdoc.write("<body onresize='window.parent.handle_resize_event()'>");
     subdoc.close();
 
-    gInterval = window.setInterval(do_a_resize, 50);
+    setTimeout(do_a_resize, 50);
 }
 
 function do_a_resize()
 {
     // decrease the width by 10 until we hit 400, then stop
     gCurrentWidth -= 10;
     gIFrame.style.width = gCurrentWidth + "px";
 
+    if (gCurrentWidth > 400) {
+        setTimeout(do_a_resize, 50);
+    }
+}
+
+function handle_resize_event()
+{
+    gGotEventsAt.push(gCurrentWidth);
+
     if (gCurrentWidth == 400) {
-        window.clearInterval(gInterval);
-        window.setTimeout(check_for_resize_events, 250);
-        return;
+        check_resize_events();
     }
 }
 
-function handle_child_resize()
+function check_resize_events()
 {
-    gGotEventsAt.push(gCurrentWidth);
-}
-
-function check_for_resize_events()
-{
-	ok(gGotEventsAt.length >= 2, "got continuous events");
-	isnot(gGotEventsAt[0], 400, "got continuous events");
-	is(gGotEventsAt[gGotEventsAt.length - 1], 400, "got last event");
-	SimpleTest.finish();
+    if (gFinished) {
+        // We can get here when the browser can't process the resizes and
+        // dispatch resize events as fast as we're doing the resizing.  We can
+        // then end up with multiple resize events queued up after we set our
+        // final size.  This return makes sure that in that case we avoid
+        // calling SimpleTest.finish() more than once.
+        return;
+    }
+    gFinished = true;
+    ok(gGotEventsAt.length >= 2, "We should get more than one event");
+    isnot(gGotEventsAt[0], 400, "The first event shouldn't be for the final size");
+    SimpleTest.finish();
 }
 
 </script>
 </pre>
 </body>
 </html>