Backed out changeset 1382e8cdf8a6 (bug 1437258) for xpcshell failures CLOSED TREE
authorshindli <shindli@mozilla.com>
Sat, 01 Dec 2018 04:59:45 +0200
changeset 508283 0066c3d92589f5925c4a20d50bf25349d8613dd9
parent 508282 5a212090eeecc702a8c3461e6926d9c83abb7c09
child 508284 4a7e5e05432e569e0d91a645a441ed65226cf5c7
push id1905
push userffxbld-merge
push dateMon, 21 Jan 2019 12:33:13 +0000
treeherdermozilla-release@c2fca1944d8c [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
bugs1437258
milestone65.0a1
backs out1382e8cdf8a670af149e138585188edd4a5c11e2
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
Backed out changeset 1382e8cdf8a6 (bug 1437258) for xpcshell failures CLOSED TREE
toolkit/components/extensions/child/ext-webRequest.js
toolkit/components/extensions/parent/ext-webRequest.js
toolkit/components/extensions/test/xpcshell/test_ext_webRequest_permission.js
--- a/toolkit/components/extensions/child/ext-webRequest.js
+++ b/toolkit/components/extensions/child/ext-webRequest.js
@@ -1,45 +1,12 @@
 /* -*- Mode: indent-tabs-mode: nil; js-indent-level: 2 -*- */
 /* vim: set sts=2 sw=2 et tw=80: */
 "use strict";
 
-var {
-  ExtensionError,
-} = ExtensionUtils;
-
-function makeWebRequestEvent(context, name) {
-  return new EventManager({
-    context,
-    name: `webRequest.${name}`,
-    register: (fire, filter, info) => {
-      const blockingAllowed = context.extension
-        .hasPermission("webRequestBlocking");
-
-      if (info) {
-        // "blocking" requires webRequestBlocking permission
-        for (let desc of info) {
-          if (desc == "blocking" && !blockingAllowed) {
-            throw new ExtensionError("Using webRequest.addListener with the " +
-              "blocking option requires the 'webRequestBlocking' permission.");
-          }
-        }
-      }
-
-      const listener = (...args) => fire.async(...args);
-
-      let parent = context.childManager.getParentEvent(`webRequest.${name}`);
-      parent.addListener(listener, filter, info);
-      return () => {
-        parent.removeListener(listener);
-      };
-    },
-  }).api();
-}
-
 this.webRequest = class extends ExtensionAPI {
   getAPI(context) {
     let filters = new WeakSet();
 
     context.callOnClose({
       close() {
         for (let filter of ChromeUtils.nondeterministicGetWeakSetKeys(filters)) {
           try {
@@ -57,17 +24,12 @@ this.webRequest = class extends Extensio
           requestId = parseInt(requestId, 10);
 
           let streamFilter = context.cloneScope.StreamFilter.create(
             requestId, context.extension.id);
 
           filters.add(streamFilter);
           return streamFilter;
         },
-        onBeforeRequest: makeWebRequestEvent(context, "onBeforeRequest"),
-        onBeforeSendHeaders:
-          makeWebRequestEvent(context, "onBeforeSendHeaders"),
-        onHeadersReceived: makeWebRequestEvent(context, "onHeadersReceived"),
-        onAuthRequired: makeWebRequestEvent(context, "onAuthRequired"),
       },
     };
   }
 };
--- a/toolkit/components/extensions/parent/ext-webRequest.js
+++ b/toolkit/components/extensions/parent/ext-webRequest.js
@@ -53,23 +53,36 @@ function registerEvent(extension, eventN
     filter2.tabId = filter.tabId;
   }
   if (filter.windowId) {
     filter2.windowId = filter.windowId;
   }
 
   let blockingAllowed = extension.hasPermission("webRequestBlocking");
 
+  let info2 = [];
+  if (info) {
+    for (let desc of info) {
+      if (desc == "blocking" && !blockingAllowed) {
+        Cu.reportError("Using webRequest.addListener with the blocking option " +
+                       "requires the 'webRequestBlocking' permission.");
+      } else {
+        info2.push(desc);
+      }
+    }
+  }
+
   let listenerDetails = {
     addonId: extension.id,
     extension: extension.policy,
     blockingAllowed,
   };
+
   WebRequest[eventName].addListener(
-    listener, filter2, info,
+    listener, filter2, info2,
     listenerDetails);
 
   return {
     unregister: () => { WebRequest[eventName].removeListener(listener); },
     convert(_fire, context) {
       fire = _fire;
       tabParent = context.xulBrowser.frameLoader.tabParent;
     },
--- a/toolkit/components/extensions/test/xpcshell/test_ext_webRequest_permission.js
+++ b/toolkit/components/extensions/test/xpcshell/test_ext_webRequest_permission.js
@@ -83,34 +83,8 @@ add_task(async function test_permissions
 
   results = await contentPage.sendMessage("Test:Check", {});
   equal(results.page, "original", "webRequest redirect fails on a privileged page");
   equal(results.script, "original", "webRequest redirect fails from a privileged page");
 
   await extension.unload();
   await contentPage.close();
 });
-
-
-add_task(async function test_no_webRequestBlocking_error() {
-  function background() {
-    browser.webRequest.onBeforeRequest
-      .addListener(details => {}, {urls: ["<all_urls>"]}, ["blocking"]);
-  }
-
-  const extensionData = {
-    manifest: {permissions: ["webRequest", "<all_urls>"]},
-    background,
-  };
-
-  const extension = ExtensionTestUtils.loadExtension(extensionData);
-
-  const {messages} = await promiseConsoleOutput(async () => {
-    await extension.startup();
-    await extension.unload();
-  });
-
-  const errRegex = new RegExp("Using webRequest\.addListener with the " +
-          "blocking option requires the 'webRequestBlocking' permission\.");
-
-  ok(messages.some(msg => errRegex.test(msg.message)),
-     "Extension fails when blocking without 'webRequestBlocking' permission");
-});