Bug 1197642 - Add time gap between subtests of fullscreen-api-race test. draft
authorXidorn Quan <quanxunzhen@gmail.com>
Mon, 04 Jan 2016 11:13:38 +1100
changeset 318557 f2174be4bb5569e849112678395b65d96340d0c6
parent 318556 9c94951b44fb118c2566603d1dd35c4825f606ba
child 512459 637f8ba199e1ca4e4f460d4b70d078ea80a62dd8
push id8877
push userxquan@mozilla.com
push dateMon, 04 Jan 2016 05:25:00 +0000
bugs1197642
milestone46.0a1
Bug 1197642 - Add time gap between subtests of fullscreen-api-race test.
dom/html/test/test_fullscreen-api-race.html
--- a/dom/html/test/test_fullscreen-api-race.html
+++ b/dom/html/test/test_fullscreen-api-race.html
@@ -11,16 +11,25 @@
 
 function Deferred() {
   this.promise = new Promise(resolve => {
     this.resolve = resolve;
   });
 }
 
 SimpleTest.waitForExplicitFinish();
+// XXX This actually exposes a true race condition, but it could rarely
+// happen in real world, because it only happens when requestFullscreen
+// is called immediately after exiting fullscreen in certain condition,
+// and in real life, requestFullscreen can only be called inside a user
+// event handler. But we want to fix this race condition at some point,
+// via queuing all exiting request as well as entering request together
+// which we may eventually need to do for bug 1188256.
+SimpleTest.requestFlakyTimeout(
+  "Need to wait for potential fullscreen transition");
 addLoadEvent(function () {
   SpecialPowers.pushPrefEnv({
     "set": [["full-screen-api.allow-trusted-requests-only", false]]
   }, next);
 });
 
 const OPEN_WINDOW_FUNCS = [
   function openNewTab() {
@@ -127,17 +136,19 @@ function next() {
   if (test) {
     runTest(test).catch(() => {
       return new Promise(resolve => {
         SimpleTest.waitForFocus(resolve);
       }).then(() => runTest(test));
     }).catch(() => {
       ok(false, "Fail to run test " +
          `${test.openWinFunc.name}, ${test.actionFunc.name}`);
-    }).then(() => SimpleTest.waitForFocus(next));
+    }).then(() => {
+      setTimeout(() => SimpleTest.waitForFocus(next), 1000);
+    });
   } else {
     SimpleTest.finish();
     return;
   }
 }
 
 </script>
 </body>