Bug 1305217: Part 2 - Run webNavigation listeners asynchronously. r=mixedpuppy
☠☠ backed out by 6cbde9c5e058 ☠ ☠
authorKris Maglione <maglione.k@gmail.com>
Wed, 09 Nov 2016 18:07:07 -0800
changeset 352359 05c206c4311bc4d6e727f89243aea2b5139fca61
parent 352358 4efa832fc852bb0499f8518c458ff052bede560e
child 352360 888815bca14ce217d0be88ec39a79018790ee969
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)
reviewersmixedpuppy
bugs1305217
milestone52.0a1
Bug 1305217: Part 2 - Run webNavigation listeners asynchronously. r=mixedpuppy MozReview-Commit-ID: AhnyokpgDFZ
toolkit/components/extensions/ExtensionChild.jsm
toolkit/components/extensions/ext-webNavigation.js
toolkit/components/extensions/test/mochitest/test_ext_webnavigation_filters.html
--- a/toolkit/components/extensions/ExtensionChild.jsm
+++ b/toolkit/components/extensions/ExtensionChild.jsm
@@ -756,20 +756,19 @@ class PseudoChildAPIManager extends Chil
 
     this.parentContext = ParentAPIManager.proxyContexts.get(this.id);
 
     // Synchronously unload the ProxyContext because we synchronously create it.
     this.context.callOnClose(this.parentContext);
   }
 
   getFallbackImplementation(namespace, name) {
-    // This is gross and should be removed ASAP.
     let useDirectParentAPI = (
       // Incompatible APIs are listed here.
-      namespace == "webNavigation" // ChildAPIManager is oblivious to filters.
+      false
     );
 
     if (useDirectParentAPI) {
       let apiObj = findPathInObject(this.parentContext.apiObj, namespace, false);
 
       if (apiObj && name in apiObj) {
         return new LocalAPIImplementation(apiObj, name, this.context);
       }
--- a/toolkit/components/extensions/ext-webNavigation.js
+++ b/toolkit/components/extensions/ext-webNavigation.js
@@ -10,17 +10,16 @@ XPCOMUtils.defineLazyModuleGetter(this, 
                                   "resource://gre/modules/MatchPattern.jsm");
 XPCOMUtils.defineLazyModuleGetter(this, "WebNavigation",
                                   "resource://gre/modules/WebNavigation.jsm");
 
 Cu.import("resource://gre/modules/ExtensionUtils.jsm");
 var {
   SingletonEventManager,
   ignoreEvent,
-  runSafe,
 } = ExtensionUtils;
 
 const defaultTransitionTypes = {
   topFrame: "link",
   subFrame: "auto_subframe",
 };
 
 const frameTransitions = {
@@ -123,17 +122,17 @@ function WebNavigationEventManager(conte
       // Fills in tabId typically.
       extensions.emit("fill-browser-data", data.browser, data2);
       if (data2.tabId < 0) {
         return;
       }
 
       fillTransitionProperties(eventName, data, data2);
 
-      runSafe(context, callback, data2);
+      context.runSafe(callback, data2);
     };
 
     WebNavigation[eventName].addListener(listener, filters);
     return () => {
       WebNavigation[eventName].removeListener(listener);
     };
   };
 
--- a/toolkit/components/extensions/test/mochitest/test_ext_webnavigation_filters.html
+++ b/toolkit/components/extensions/test/mochitest/test_ext_webnavigation_filters.html
@@ -183,23 +183,26 @@ add_task(function* test_webnav_unresolve
         },
       ],
     },
   ];
 
   function* runTestScenario(event, {url, filters}) {
     for (let testFilters of filters) {
       let {okFilter, failFilter} = testFilters;
+
       info(`Prepare the new test scenario: ${event} ${url} ${JSON.stringify(testFilters)}`);
       win.location = "about:blank";
+
       extension.sendMessage("test-filter", event, {url: okFilter}, {url: failFilter});
       yield extension.awaitMessage("test-filter-ready");
 
       info(`Loading the test url: ${url}`);
       win.location = url;
+
       yield extension.awaitMessage("test-filter-next");
 
       info("Test scenario completed. Moving to the next test scenario.");
     }
   }
 
   const BASE_WEBNAV_EVENTS = [
     "onBeforeNavigate",
@@ -222,22 +225,24 @@ add_task(function* test_webnav_unresolve
   let url = BASE + "/file_WebNavigation_page3.html";
 
   let okFilter = [{urlContains: "_page3.html"}];
   let failFilter = [{ports: [444]}];
   let event = "onCompleted";
 
   info(`Loading the initial test url: ${url}`);
   extension.sendMessage("test-filter", event, {url: okFilter}, {url: failFilter});
+
   yield extension.awaitMessage("test-filter-ready");
   win.location = url;
   yield extension.awaitMessage("test-filter-next");
 
   event = "onReferenceFragmentUpdated";
   extension.sendMessage("test-filter", event, {url: okFilter}, {url: failFilter});
+
   yield extension.awaitMessage("test-filter-ready");
   win.location = url + "#ref1";
   yield extension.awaitMessage("test-filter-next");
 
   info("WebNavigation event filters test onHistoryStateUpdated scenario starting...");
 
   event = "onHistoryStateUpdated";
   extension.sendMessage("test-filter", event, {url: okFilter}, {url: failFilter});