Bug 1311197 - Remove CPOWs from browser_localfile2.js. r=Gijs
authorBlake Kaplan <mrbkap@gmail.com>
Mon, 10 Oct 2016 16:54:34 -0700
changeset 351633 fbd597046674eae52e0dcfefb725070794682858
parent 351632 9ce4a72010fa5012941c19d91138659e24864470
child 351634 d30948200f1867b97e669bc7d5592dc51532cf0a
push id6795
push userjlund@mozilla.com
push dateMon, 23 Jan 2017 14:19:46 +0000
treeherdermozilla-esr52@76101b503191 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersGijs
bugs1311197
milestone52.0a1
Bug 1311197 - Remove CPOWs from browser_localfile2.js. r=Gijs MozReview-Commit-ID: Dv5RCSTmp8
toolkit/mozapps/extensions/test/xpinstall/browser_localfile2.js
--- a/toolkit/mozapps/extensions/test/xpinstall/browser_localfile2.js
+++ b/toolkit/mozapps/extensions/test/xpinstall/browser_localfile2.js
@@ -1,50 +1,38 @@
 // ----------------------------------------------------------------------------
 // Test whether an install fails if the url is a local file when requested from
 // web content
-function test() {
-  waitForExplicitFinish();
-
+add_task(function* test() {
   var cr = Components.classes["@mozilla.org/chrome/chrome-registry;1"]
                      .getService(Components.interfaces.nsIChromeRegistry);
 
   var chromeroot = getChromeRoot(gTestPath);
   var xpipath = chromeroot + "amosigned.xpi";
   try {
     xpipath = cr.convertChromeURL(makeURI(xpipath)).spec;
   } catch (ex) {
     // scenario where we are running from a .jar and already extracted
   }
 
   var triggers = encodeURIComponent(JSON.stringify({
     "Unsigned XPI": xpipath
   }));
-  gBrowser.selectedTab = gBrowser.addTab();
-
-  function loadListener() {
-    gBrowser.selectedBrowser.removeEventListener("load", loadListener, true);
-    gBrowser.contentWindow.addEventListener("InstallTriggered", page_loaded, false);
-  }
-
-  gBrowser.selectedBrowser.addEventListener("load", loadListener, true);
 
   // In non-e10s the exception in the content page would trigger a test failure
   if (!gMultiProcessBrowser)
     expectUncaughtException();
 
-  gBrowser.loadURI(TESTROOT + "installtrigger.html?" + triggers);
-}
-
-function page_loaded() {
-  gBrowser.contentWindow.removeEventListener("InstallTriggered", page_loaded, false);
-  var doc = gBrowser.contentDocument;
-  is(doc.getElementById("return").textContent, "exception", "installTrigger should have failed");
+  let URI = TESTROOT + "installtrigger.html?" + triggers;
+  yield BrowserTestUtils.withNewTab({ gBrowser, url: "about:blank" }, function* (browser) {
+    yield ContentTask.spawn(browser, URI, function* (URI) {
+      content.location.href = URI;
 
-  // In non-e10s the exception from the page is thrown after the event so we
-  // have to spin the event loop to make sure it arrives so expectUncaughtException
-  // sees it.
-  executeSoon(() => {
-    gBrowser.removeCurrentTab();
-    finish();
+      let loaded = ContentTaskUtils.waitForEvent(this, "load", true);
+      let installTriggered = ContentTaskUtils.waitForEvent(this, "InstallTriggered", true, null, true);
+      yield Promise.all([ loaded, installTriggered ]);
+
+      let doc = content.document;
+      is(doc.getElementById("return").textContent, "exception", "installTrigger should have failed");
+    });
   });
-}
+});
 // ----------------------------------------------------------------------------