Bug 1016312 - Fix intermittent browser_fullscreen-window-open.js failures by removing arbitrary timeouts. r=jaws, a=test-only
authorTim Taubert <ttaubert@mozilla.com>
Thu, 26 Mar 2015 17:55:10 +0100
changeset 258229 e98a992238e2
parent 258228 3f7826efc5de
child 258230 b228af82453b
push id4623
push userryanvm@gmail.com
push date2015-04-03 01:49 +0000
treeherdermozilla-beta@9c755cdc241c [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjaws, test-only
bugs1016312
milestone38.0
Bug 1016312 - Fix intermittent browser_fullscreen-window-open.js failures by removing arbitrary timeouts. r=jaws, a=test-only
browser/base/content/test/general/browser_fullscreen-window-open.js
--- a/browser/base/content/test/general/browser_fullscreen-window-open.js
+++ b/browser/base/content/test/general/browser_fullscreen-window-open.js
@@ -176,24 +176,22 @@ function test_open_with_pref_to_disable_
 
 // Test for window.open() called from chrome context.
 function test_open_from_chrome() {
   waitForWindowOpenFromChrome({
     message: {
       title: "test_open_from_chrome",
       param: "",
     },
-    finalizeFn: function () {},
-    timeout: 10000,
+    finalizeFn: function () {}
   });
 }
 
 function waitForTabOpen(aOptions) {
   let start = Date.now();
-  let timeout = aOptions.timeout || 5000;
   let message = aOptions.message;
 
   if (!message.title) {
     ok(false, "Can't get message.title.");
     aOptions.finalizeFn();
     runNextTest();
     return;
   }
@@ -202,17 +200,16 @@ function waitForTabOpen(aOptions) {
 
   let onTabOpen = function onTabOpen(aEvent) {
     gBrowser.tabContainer.removeEventListener("TabOpen", onTabOpen, true);
 
     let tab = aEvent.target;
     tab.linkedBrowser.addEventListener("load", function onLoad(ev){
       let browser = ev.currentTarget;
       browser.removeEventListener("load", onLoad, true, true);
-      clearTimeout(onTimeout);
 
       is(browser.contentWindow.document.title, message.title,
          "Opened Tab is expected: " + message.title);
 
       if (aOptions.successFn) {
         aOptions.successFn();
       }
 
@@ -223,39 +220,30 @@ function waitForTabOpen(aOptions) {
   gBrowser.tabContainer.addEventListener("TabOpen", onTabOpen, true);
 
   let finalize = function () {
     aOptions.finalizeFn();
     info("Finished: " + message.title);
     runNextTest();
   };
 
-  let onTimeout = setTimeout(function(){
-    gBrowser.tabContainer.removeEventListener("TabOpen", onTabOpen, true);
-
-    ok(false, "Timeout: '"+message.title + "'.");
-    finalize();
-  }, timeout);
-
-
   const URI = "data:text/html;charset=utf-8,<!DOCTYPE html><html><head><title>"+
               message.title +
               "<%2Ftitle><%2Fhead><body><%2Fbody><%2Fhtml>";
 
   executeWindowOpenInContent({
     uri: URI,
     title: message.title,
     option: message.param,
   });
 }
 
 
 function waitForWindowOpen(aOptions) {
   let start = Date.now();
-  let timeout = aOptions.timeout || 10000;
   let message = aOptions.message;
   let url = aOptions.url || getBrowserURL();
 
   if (!message.title) {
     ok(false, "Can't get message.title");
     aOptions.finalizeFn();
     runNextTest();
     return;
@@ -265,26 +253,18 @@ function waitForWindowOpen(aOptions) {
 
   let onFinalize = function () {
     aOptions.finalizeFn();
 
     info("Finished: " + message.title);
     runNextTest();
   };
 
-  let onTimeout = setTimeout(function(){
-    Services.wm.removeListener(listener);
-    ok(false, "Fail: '"+message.title + "'.");
-
-    onFinalize();
-  }, timeout);
-
   let listener = new WindowListener(message.title, url, {
     onSuccess: aOptions.successFn,
-    onTimeout: onTimeout,
     onFinalize: onFinalize,
   });
   Services.wm.addListener(listener);
 
   const URI = aOptions.url || "about:blank";
 
   executeWindowOpenInContent({
     uri: URI,
@@ -298,17 +278,16 @@ function executeWindowOpenInContent(aPar
   var testElm = testWindow.document.getElementById("test");
 
   testElm.setAttribute("data-test-param", JSON.stringify(aParam));
   EventUtils.synthesizeMouseAtCenter(testElm, {}, testWindow);
 }
 
 function waitForWindowOpenFromChrome(aOptions) {
   let start = Date.now();
-  let timeout = aOptions.timeout || 10000;
   let message = aOptions.message;
   let url = aOptions.url || getBrowserURL();
 
   if (!message.title) {
     ok(false, "Can't get message.title");
     aOptions.finalizeFn();
     runNextTest();
     return;
@@ -318,66 +297,54 @@ function waitForWindowOpenFromChrome(aOp
 
   let onFinalize = function () {
     aOptions.finalizeFn();
 
     info("Finished: " + message.title);
     runNextTest();
   };
 
-  let onTimeout = setTimeout(function(){
-    Services.wm.removeListener(listener);
-    ok(false, "Fail: '"+message.title + "'.");
-
-    testWindow.close();
-    onFinalize();
-  }, timeout);
-
   let listener = new WindowListener(message.title, url, {
     onSuccess: aOptions.successFn,
-    onTimeout: onTimeout,
     onFinalize: onFinalize,
   });
   Services.wm.addListener(listener);
 
 
   const URI = aOptions.url || "about:blank";
 
   let testWindow = window.open(URI, message.title, message.option);
 }
 
 function WindowListener(aTitle, aUrl, aCallBackObj) {
   this.test_title = aTitle;
   this.test_url = aUrl;
   this.callback_onSuccess = aCallBackObj.onSuccess;
-  this.callBack_onTimeout = aCallBackObj.onTimeout;
   this.callBack_onFinalize = aCallBackObj.onFinalize;
 }
 WindowListener.prototype = {
 
   test_title: null,
   test_url: null,
   callback_onSuccess: null,
-  callBack_onTimeout: null,
   callBack_onFinalize: null,
 
   onOpenWindow: function(aXULWindow) {
     Services.wm.removeListener(this);
 
     let domwindow = aXULWindow.QueryInterface(Ci.nsIInterfaceRequestor)
                     .getInterface(Ci.nsIDOMWindow);
     domwindow.addEventListener("load", function onLoad(aEvent) {
       is(domwindow.document.location.href, this.test_url,
         "Opened Window is expected: "+ this.test_title);
       if (this.callback_onSuccess) {
         this.callback_onSuccess();
       }
 
       domwindow.removeEventListener("load", onLoad, true);
-      clearTimeout(this.callBack_onTimeout);
 
       // wait for trasition to fullscreen on OSX Lion later
       if (isOSX) {
         setTimeout(function(){
           domwindow.close();
           executeSoon(this.callBack_onFinalize);
         }.bind(this), 3000);
       }