Bug 647007 - Intermittent Failure in browser_tabview_bug595436.js [f=raymond, r=ian]
authorTim Taubert <tim.taubert@gmx.de>
Thu, 14 Apr 2011 06:04:13 +0200
changeset 68171 91e04bb4308f48861b1484b421d3e824f6a5df87
parent 68170 b1fc69fab8b2a08ec85025a5e6e16d9fa76a7a31
child 68172 3b690b386210031535984dd956afb6da9e193a01
push id19528
push usereakhgari@mozilla.com
push dateFri, 15 Apr 2011 13:35:33 +0000
treeherdermozilla-central@754e793c647e [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersian
bugs647007, 595436
milestone6.0a1
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 647007 - Intermittent Failure in browser_tabview_bug595436.js [f=raymond, r=ian]
browser/base/content/test/tabview/browser_tabview_bug595436.js
--- a/browser/base/content/test/tabview/browser_tabview_bug595436.js
+++ b/browser/base/content/test/tabview/browser_tabview_bug595436.js
@@ -1,67 +1,54 @@
 /* Any copyright is dedicated to the Public Domain.
    http://creativecommons.org/publicdomain/zero/1.0/ */
 
 function test() {
-  waitForExplicitFinish();
-  
-  window.addEventListener('tabviewshown', onTabViewWindowLoaded, false);
-  TabView.toggle();
-}
+  let cw, search, searchButton;
+
+  let assertSearchIsEnabled = function () {
+    isnot(search.style.display, "none", "search is enabled");
+  }
 
-function onTabViewWindowLoaded() {
-  window.removeEventListener('tabviewshown', onTabViewWindowLoaded, false);
-  
-  let contentWindow = document.getElementById('tab-view').contentWindow;
-  let search = contentWindow.document.getElementById('search');
-  let searchButton = contentWindow.document.getElementById('searchbutton');
-  
-  let isSearchEnabled = function () {
-    return 'none' != search.style.display;
+  let assertSearchIsDisabled = function () {
+    is(search.style.display, "none", "search is disabled");
   }
-  
-  let assertSearchIsEnabled = function () {
-    ok(isSearchEnabled(), 'search is enabled');
-  }
-  
-  let assertSearchIsDisabled = function () {
-    ok(!isSearchEnabled(), 'search is disabled');
-  }
-  
+
   let testSearchInitiatedByKeyPress = function () {
-    EventUtils.synthesizeKey('a', {});
+    EventUtils.synthesizeKey("a", {}, cw);
     assertSearchIsEnabled();
-    
-    EventUtils.synthesizeKey('VK_BACK_SPACE', {});
+
+    EventUtils.synthesizeKey("VK_BACK_SPACE", {}, cw);
     assertSearchIsDisabled();
   }
-  
+
   let testSearchInitiatedByMouseClick = function () {
-    EventUtils.sendMouseEvent({type: 'mousedown'}, searchButton, contentWindow);
+    EventUtils.sendMouseEvent({type: "mousedown"}, searchButton, cw);
     assertSearchIsEnabled();
-    
-    EventUtils.synthesizeKey('a', {});
-    EventUtils.synthesizeKey('VK_BACK_SPACE', {});
-    EventUtils.synthesizeKey('VK_BACK_SPACE', {});
+
+    EventUtils.synthesizeKey("a", {}, cw);
+    EventUtils.synthesizeKey("VK_BACK_SPACE", {}, cw);
+    EventUtils.synthesizeKey("VK_BACK_SPACE", {}, cw);
     assertSearchIsEnabled();
-    
-    EventUtils.synthesizeKey('VK_ESCAPE', {});
+
+    EventUtils.synthesizeKey("VK_ESCAPE", {}, cw);
     assertSearchIsDisabled();
   }
-  
-  let finishTest = function () {
-    let onTabViewHidden = function () {
-      window.removeEventListener('tabviewhidden', onTabViewHidden, false);
+
+  waitForExplicitFinish();
+
+  newWindowWithTabView(function (win) {
+    registerCleanupFunction(function () win.close());
+
+    cw = win.TabView.getContentWindow();
+    search = cw.document.getElementById("search");
+    searchButton = cw.document.getElementById("searchbutton");
+
+    SimpleTest.waitForFocus(function () {
+      assertSearchIsDisabled();
+
+      testSearchInitiatedByKeyPress();
+      testSearchInitiatedByMouseClick();
+
       finish();
-    }
-    
-    window.addEventListener('tabviewhidden', onTabViewHidden, false);
-    TabView.hide();
-  }
-  
-  assertSearchIsDisabled();
-  
-  testSearchInitiatedByKeyPress();
-  testSearchInitiatedByMouseClick();
-  
-  finishTest();
+    }, cw);
+  });
 }