Bug 1236554 - enable browser_visituri_nohistory in e10s, r=mak
authorNeil Deakin <neil@mozilla.com>
Wed, 20 Jan 2016 08:45:58 -0500
changeset 315903 7d55178b297d3b120ef659c9b24aaf67c24f6d5c
parent 315902 9d2c02559cdf964aa1a8d0da1c61f6b1780cdf9f
child 315904 5b5edd360f70a8a16b73ea895fa168ae8cab4bd5
push id5703
push userraliiev@mozilla.com
push dateMon, 07 Mar 2016 14:18:41 +0000
treeherdermozilla-beta@31e373ad5b5f [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmak
bugs1236554
milestone46.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 1236554 - enable browser_visituri_nohistory in e10s, r=mak
toolkit/components/places/tests/browser/browser_visituri_nohistory.js
--- a/toolkit/components/places/tests/browser/browser_visituri_nohistory.js
+++ b/toolkit/components/places/tests/browser/browser_visituri_nohistory.js
@@ -1,65 +1,42 @@
 /**
  * Any copyright is dedicated to the Public Domain.
  * http://creativecommons.org/publicdomain/zero/1.0/
  */
 
 const INITIAL_URL = "http://example.com/tests/toolkit/components/places/tests/browser/begin.html";
 const FINAL_URL = "http://example.com/tests/toolkit/components/places/tests/browser/final.html";
 
-var gTab = gBrowser.selectedTab = gBrowser.addTab();
-
 /**
  * One-time observer callback.
  */
-function waitForObserve(name, callback)
+function promiseObserve(name)
 {
-  let observer = {
-    QueryInterface: XPCOMUtils.generateQI([Ci.nsIObserver]),
-    observe: function(subject, topic, data)
-    {
+  return new Promise(resolve => {
+    Services.obs.addObserver(function observer(subject) {
       Services.obs.removeObserver(observer, name);
-      callback(subject, topic, data);
-    }
-  };
-
-  Services.obs.addObserver(observer, name, false);
-}
-
-/**
- * One-time DOMContentLoaded callback.
- */
-function waitForLoad(callback)
-{
-  gTab.linkedBrowser.addEventListener("load", function()
-  {
-    gTab.linkedBrowser.removeEventListener("load", arguments.callee, true);
-    callback();
-  }, true);
+      resolve(subject);
+    }, name, false);
+  });
 }
 
-function test()
+add_task(function* ()
 {
-  waitForExplicitFinish();
+  yield new Promise(resolve => SpecialPowers.pushPrefEnv({"set": [["places.history.enabled", false]]}, resolve));
+
+  let visitUriPromise = promiseObserve("uri-visit-saved");
 
-  Services.prefs.setBoolPref("places.history.enabled", false);
+  yield BrowserTestUtils.openNewForegroundTab(gBrowser, INITIAL_URL);
+
+  yield new Promise(resolve => SpecialPowers.popPrefEnv(resolve));
 
-  waitForObserve("uri-visit-saved", function(subject, topic, data)
-  {
-    let uri = subject.QueryInterface(Ci.nsIURI);
-    is(uri.spec, FINAL_URL, "received expected visit");
-    if (uri.spec != FINAL_URL)
-      return;
-    gBrowser.removeCurrentTab();
-    PlacesTestUtils.clearHistory().then(finish);
-  });
+  let browserLoadedPromise = BrowserTestUtils.browserLoaded(gBrowser.selectedBrowser);
+  gBrowser.loadURI(FINAL_URL);
+  yield browserLoadedPromise;
 
-  Services.prefs.setBoolPref("places.history.enabled", false);
-  content.location.href = INITIAL_URL;
-  waitForLoad(function()
-  {
-    try {
-      Services.prefs.clearUserPref("places.history.enabled");
-    } catch(ex) {}    
-    content.location.href = FINAL_URL;
-  });
-}
+  let subject = yield visitUriPromise;
+  let uri = subject.QueryInterface(Ci.nsIURI);
+  is(uri.spec, FINAL_URL, "received expected visit");
+
+  yield PlacesTestUtils.clearHistory();
+  gBrowser.removeCurrentTab();
+});