Bug 1413817 - Add a function to check detect whether have conformant Promise handling and set the flag to represent it. r?birtles draft
authorHiroyuki Ikezoe <hikezoe@mozilla.com>
Thu, 09 Nov 2017 08:06:37 +0900
changeset 695301 85eb455aa259b21caae27e05f178f449ee5d4abb
parent 695300 d6e4cef9742070e1adfe8f2aceba7cf447d006dd
child 695302 c6d142f1289b19e68e18ef7191f7c5334625d17c
push id88383
push userhikezoe@mozilla.com
push dateThu, 09 Nov 2017 00:26:11 +0000
reviewersbirtles
bugs1413817
milestone58.0a1
Bug 1413817 - Add a function to check detect whether have conformant Promise handling and set the flag to represent it. r?birtles MozReview-Commit-ID: FbzaUBKQ47F
dom/animation/test/mozilla/file_restyles.html
--- a/dom/animation/test/mozilla/file_restyles.html
+++ b/dom/animation/test/mozilla/file_restyles.html
@@ -106,28 +106,56 @@ function waitForPaintsAndFrame() {
 }
 
 var omtaEnabled = isOMTAEnabled();
 
 var isAndroid = !!navigator.userAgent.includes("Android");
 var isServo = isStyledByServo();
 var offscreenThrottlingEnabled =
   SpecialPowers.getBoolPref('dom.animations.offscreen-throttling');
+var hasConformantPromiseHandling;
 
 function add_task_if_omta_enabled(test) {
   if (!omtaEnabled) {
     info(test.name + " is skipped because OMTA is disabled");
     return;
   }
   add_task(test);
 }
 
 // We need to wait for all paints before running tests to avoid contaminations
 // from styling of this document itself.
 waitForAllPaints(() => {
+  // Drop this once we have the conformant Promise handling(bug 1193394).
+  add_task(async function check_conformant_promise_handling() {
+    var div = addDiv(null, { style: 'animation: background-color 100s' });
+
+    var timeAtAnimationStart;
+    var eventPromise = new Promise(resolve => {
+      div.addEventListener('animationstart', () => {
+        timeAtAnimationStart = document.timeline.currentTime;
+        resolve();
+      });
+    });
+
+    var animation = div.getAnimations()[0];
+
+    await eventPromise;
+    await waitForFrame();
+
+    // If we have the conformant Promise handling, |eventPromise| is fulfilled
+    // just after the 'animationstart' callback and Promise in waitForFrame()
+    // is also fulfilled right after requestAnimationFrame callback, so
+    // both happen on the same tick.
+    hasConformantPromiseHandling =
+      (document.timeline.currentTime == timeAtAnimationStart);
+
+    await ensureElementRemoval(div);
+  });
+
   add_task(async function restyling_for_main_thread_animations() {
     var div = addDiv(null, { style: 'animation: background-color 100s' });
     var animation = div.getAnimations()[0];
 
     await waitForPaintsAndFrame();
 
     ok(!SpecialPowers.wrap(animation).isRunningOnCompositor);