Bug 1545309 - Run ResizeObserver eventloop test after loading successfully. r=dholbert
authorBoris Chiou <boris.chiou@gmail.com>
Mon, 06 May 2019 22:53:09 +0000
changeset 531993 2c165cc039113c935d13a630528173f2e34cdfe2
parent 531992 57b5cbfc0d7a0857e896d0a41c366fc7a4d77da0
child 531994 7509dadbcbfe59ef39739d58bbc626c18b7bfa3e
push id11265
push userffxbld-merge
push dateMon, 13 May 2019 10:53:39 +0000
treeherdermozilla-beta@77e0fe8dbdd3 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersdholbert
bugs1545309, 1145439
milestone68.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1545309 - Run ResizeObserver eventloop test after loading successfully. r=dholbert In test0(), we use the callback of `requestAnimationFrame` to know in which eventloop (i.e. `Tick()`) we are. However, we may not trigger the callback of `requestAnimationFrame` if we are not visible. This is an optimization in Bug 1145439. Detail: We use `Document::ShouldThrottleFrameRequests()` to check if we should throttle the frame requests in the current `Tick()`. This function returns true if we didn't get painted during the last paint, so we are not visible, so throttle the frame requests. Note that because we have to paint this document at least once to unthrottle it, we will drop one `requestAnimationFrame` frame when a document that previously wasn't visible scrolls into view. Therefore, we should make sure we got the first paint before running test0(). Using onload is not perfect, but we don't have other better choose for now. Differential Revision: https://phabricator.services.mozilla.com/D29772
testing/web-platform/meta/resize-observer/eventloop.html.ini
testing/web-platform/tests/resize-observer/eventloop.html
deleted file mode 100644
--- a/testing/web-platform/meta/resize-observer/eventloop.html.ini
+++ /dev/null
@@ -1,7 +0,0 @@
-[eventloop.html]
-  disabled: https://bugzilla.mozilla.org/show_bug.cgi?id=1545309
-  [guard]
-    expected: NOTRUN
-  [test0: multiple notifications inside same event loop]
-    expected: FAIL
-
--- a/testing/web-platform/tests/resize-observer/eventloop.html
+++ b/testing/web-platform/tests/resize-observer/eventloop.html
@@ -81,17 +81,34 @@ function test0() {
       notify: (entries, observer) => {
         assert_equals(entries.length, 2, "2 notifications");
         assert_equals(helper.rafCount, 1, "new loop");
         assert_equals(onErrorCalled, true, "error was fired");
         observer.disconnect();
       }
     }
   ]);
-  return helper.start(() => t1.remove());
+
+  return new Promise((resolve, reject) => {
+    // This test uses requestAnimationFrame() to check the count of event loop,
+    // but on some browsers, the FrameRequestCallback may be throttled (i.e.
+    // simply fired after some extra time) in cases where this test is running
+    // in an iframe that hasn't yet been painted (i.e. we're not visible).
+    // This may result in some intermittent failures if this test didn't get a
+    // first paint (and hence may not have started firing FrameRequestCallbacks)
+    // by the time the test starts expecting helper.rafCount to have changed.
+    //
+    // Therefore, we don't start the test logic until body.onload has fired.
+    // This increases the likelihood that this testcase will have gotten a
+    // chance to paint when we start invoking requestAnimationFrame, and that
+    // its rAF callbacks will fire when the test logic expects them to.
+    document.body.onload = () => resolve();
+  }).then(() => {
+    return helper.start(() => t1.remove());
+  });
 }
 
 function test1() {
   let t1 = createAndAppendElement("div");
   t1.style.width = '100px';
   let t2 = createAndAppendElement("div", t1);
   let t3 = createAndAppendElement("div", t2);
   let shadow = t3.attachShadow({ mode: "open" });