Bug 1180574 - Retry once if we open a window in fullscreen mode in fullscree-api-race test. r=smaug, a=test-only
authorXidorn Quan <quanxunzhen@gmail.com>
Fri, 21 Aug 2015 09:17:18 +1000
changeset 288857 e5032ab3cf698b44000f1ab3a83eafcc471da785
parent 288856 646d235db57d6b8386b7c99fddb0cb2c73050c02
child 288858 76c987fe2b25ec4e75b926e678a831cc5f255ded
push id5067
push userraliiev@mozilla.com
push dateMon, 21 Sep 2015 14:04:52 +0000
treeherdermozilla-beta@14221ffe5b2f [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssmaug, test-only
bugs1180574
milestone42.0a2
Bug 1180574 - Retry once if we open a window in fullscreen mode in fullscree-api-race test. r=smaug, a=test-only
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
@@ -67,56 +67,31 @@ const ACTION_FUNCS = [
   function exitAndClose(win) {
     info("About to cancel fullscreen and close the window");
     win.document.mozCancelFullScreen();
     win.close();
     return Promise.resolve();
   }
 ];
 
-const DISABLE_LIST = [
-  // Bug 1180574
-  { openWinFunc: "openNewWindow",
-    actionFunc: "navigate",
-    platform: "Linux i686" }
-];
-
 function* testGenerator() {
   for (var openWinFunc of OPEN_WINDOW_FUNCS) {
     for (var actionFunc of ACTION_FUNCS) {
-      var skipTest = false;
-      for (var disabledItem of DISABLE_LIST) {
-        if (openWinFunc.name == disabledItem.openWinFunc &&
-            actionFunc.name == disabledItem.actionFunc &&
-            navigator.platform == disabledItem.platform) {
-          skipTest = true;
-          break;
-        }
-      }
-      if (!skipTest) {
-        info(`Testing ${openWinFunc.name}, ${actionFunc.name}`);
-        yield { openWinFunc: openWinFunc, actionFunc: actionFunc };
-      }
+      info(`Testing ${openWinFunc.name}, ${actionFunc.name}`);
+      yield { openWinFunc: openWinFunc, actionFunc: actionFunc };
     }
   }
 }
 
-var tests = testGenerator();
-
-function next() {
-  var test = tests.next().value;
-  if (!test) {
-    SimpleTest.finish();
-    return;
-  }
+function runTest(test) {
   var win = test.openWinFunc();
-  new Promise(resolve => {
+  return new Promise(resolve => {
     SimpleTest.waitForFocus(resolve, win, true);
   }).then(() => {
-    return new Promise(resolve => {
+    return new Promise((resolve, reject) => {
       var retried = false;
       function listener(evt) {
         if (!retried && evt.type == "mozfullscreenerror") {
           todo(false, "Failed to enter fullscreen, but try again");
           retried = true;
           SimpleTest.waitForFocus(() => {
             win.document.documentElement.mozRequestFullScreen();
           }, win, true);
@@ -124,22 +99,46 @@ function next() {
         }
         win.removeEventListener("mozfullscreenchange", listener);
         win.removeEventListener("mozfullscreenerror", listener);
         is(evt.type, "mozfullscreenchange", "Should get fullscreenchange");
         ok(win.document.mozFullScreen, "Should have entered fullscreen");
         ok(win.fullScreen, "The window should be in fullscreen");
         test.actionFunc(win).then(resolve);
       }
+      if (win.fullScreen) {
+        todo(false, "Should not open in fullscreen mode");
+        win.close();
+        reject();
+        return;
+      }
       info("About to enter fullscreen");
       win.addEventListener("mozfullscreenchange", listener);
       win.addEventListener("mozfullscreenerror", listener);
       win.document.documentElement.mozRequestFullScreen();
     });
   }).then(() => {
     ok(win.closed, "The window should have been closed");
-    SimpleTest.waitForFocus(next);
   });
 }
 
+var tests = testGenerator();
+
+function next() {
+  var test = tests.next().value;
+  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));
+  } else {
+    SimpleTest.finish();
+    return;
+  }
+}
+
 </script>
 </body>
 </html>