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 535060 2c165cc039113c935d13a630528173f2e34cdfe2
parent 535059 57b5cbfc0d7a0857e896d0a41c366fc7a4d77da0
child 535061 7509dadbcbfe59ef39739d58bbc626c18b7bfa3e
push id2082
push userffxbld-merge
push dateMon, 01 Jul 2019 08:34:18 +0000
treeherdermozilla-release@2fb19d0466d2 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
bugs1545309, 1145439
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
deleted file mode 100644
--- a/testing/web-platform/meta/resize-observer/eventloop.html.ini
+++ /dev/null
@@ -1,7 +0,0 @@
-  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");
-  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" });