Bug 1115696: fix browser_aboutHome.js to work correctly with inContent prefs enabled/disabled, r=mak
authorGavin Sharp <gavin@gavinsharp.com>
Mon, 05 Jan 2015 07:59:12 -0800
changeset 222215 07317d58d433a97d5a7a01d7155054ae88a97723
parent 222214 8f91a31d4cec2830c135037fec299490f1cca2ff
child 222216 20dd052812f8a5c44d420c2220bd800bc230ab6c
push id28060
push userryanvm@gmail.com
push dateTue, 06 Jan 2015 16:02:34 +0000
treeherdermozilla-central@b42615e51c81 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmak
bugs1115696
milestone37.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 1115696: fix browser_aboutHome.js to work correctly with inContent prefs enabled/disabled, r=mak
browser/base/content/test/general/browser_aboutHome.js
--- a/browser/base/content/test/general/browser_aboutHome.js
+++ b/browser/base/content/test/general/browser_aboutHome.js
@@ -434,17 +434,17 @@ let gTests = [
   run: Task.async(function* () {
     let doc = gBrowser.selectedBrowser.contentDocument;
     let searchIcon = doc.getElementById("searchIcon");
     let panel = window.document.getElementById("abouthome-search-panel");
 
     info("Waiting for popup to open");
     EventUtils.synthesizeMouseAtCenter(searchIcon, {}, gBrowser.selectedBrowser.contentWindow);
     yield promiseWaitForEvent(panel, "popupshown");
-    ok("Saw popup open");
+    info("Saw popup open");
 
     let promise = promisePrefsOpen();
     let item = window.document.getElementById("abouthome-search-panel-manage");
     EventUtils.synthesizeMouseAtCenter(item, {});
 
     yield promise;
   })
 }
@@ -627,22 +627,43 @@ function promiseWaitForEvent(node, type,
     node.addEventListener(type, function listener(event) {
       node.removeEventListener(type, listener, capturing);
       resolve(event);
     }, capturing);
   });
 }
 
 let promisePrefsOpen = Task.async(function*() {
-  info("Waiting for the preferences tab to open...");
-  let event = yield promiseWaitForEvent(gBrowser.tabContainer, "TabOpen", true);
-  let tab = event.target;
-  yield promiseTabLoadEvent(tab);
-  is(tab.linkedBrowser.currentURI.spec, "about:preferences#search", "Should have seen the prefs tab");
-  gBrowser.removeTab(tab);
+  if (Services.prefs.getBoolPref("browser.preferences.inContent")) {
+    info("Waiting for the preferences tab to open...");
+    let event = yield promiseWaitForEvent(gBrowser.tabContainer, "TabOpen", true);
+    let tab = event.target;
+    yield promiseTabLoadEvent(tab);
+    is(tab.linkedBrowser.currentURI.spec, "about:preferences#search", "Should have seen the prefs tab");
+    gBrowser.removeTab(tab);
+  } else {
+    info("Waiting for the preferences window to open...");
+    yield new Promise(resolve => {
+      let winWatcher = Cc["@mozilla.org/embedcomp/window-watcher;1"].
+                       getService(Ci.nsIWindowWatcher);
+      winWatcher.registerNotification(function onWin(subj, topic, data) {
+        if (topic == "domwindowopened" && subj instanceof Ci.nsIDOMWindow) {
+          subj.addEventListener("load", function onLoad() {
+            subj.removeEventListener("load", onLoad);
+            is(subj.document.documentURI, "chrome://browser/content/preferences/preferences.xul", "Should have seen the prefs window");
+            winWatcher.unregisterNotification(onWin);
+            executeSoon(() => {
+              subj.close();
+              resolve();
+            });
+          });
+        }
+      });
+    });
+  }
 });
 
 function promiseNewEngine(basename) {
   info("Waiting for engine to be added: " + basename);
   let addDeferred = Promise.defer();
   let url = getRootDirectory(gTestPath) + basename;
   Services.search.addEngine(url, Ci.nsISearchEngine.TYPE_MOZSEARCH, "", false, {
     onSuccess: function (engine) {