Bug 1528188 - Add test with blocking webRequest which overwrites notificationCallbacks r=mayhemer
authorValentin Gosu <valentin.gosu@gmail.com>
Mon, 18 Feb 2019 21:37:30 +0000
changeset 459811 2299664d9a0b83229ed527ca3e5c43452e69ab2a
parent 459810 3d2830a2b70e2157ca78b0099e9dc5c83a1dd897
child 459812 bc1a5ca9464b2342b79ad1642b6fbe51139916e7
push id35574
push usercbrindusan@mozilla.com
push dateTue, 19 Feb 2019 04:38:09 +0000
treeherdermozilla-central@8231f78228bc [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmayhemer
bugs1528188
milestone67.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 1528188 - Add test with blocking webRequest which overwrites notificationCallbacks r=mayhemer Differential Revision: https://phabricator.services.mozilla.com/D20183
toolkit/components/remotebrowserutils/tests/browser/browser_httpResponseProcessSelection.js
--- a/toolkit/components/remotebrowserutils/tests/browser/browser_httpResponseProcessSelection.js
+++ b/toolkit/components/remotebrowserutils/tests/browser/browser_httpResponseProcessSelection.js
@@ -1,8 +1,11 @@
+/* eslint-env webextensions */
+"use strict";
+
 const {E10SUtils} = ChromeUtils.import("resource://gre/modules/E10SUtils.jsm");
 
 let PREF_NAME = "browser.tabs.remote.useHTTPResponseProcessSelection";
 
 async function performLoad(browser, opts, action) {
   let loadedPromise = BrowserTestUtils.browserLoaded(
     browser, false, opts.url, opts.maybeErrorPage);
   await action();
@@ -10,21 +13,43 @@ async function performLoad(browser, opts
 }
 
 const EXTENSION_DATA = {
   manifest: {
     "name": "Simple extension test",
     "version": "1.0",
     "manifest_version": 2,
     "description": "",
+
+    permissions: [
+      "proxy",
+      "webRequest",
+      "webRequestBlocking",
+      "<all_urls>",
+    ],
   },
 
   files: {
     "dummy.html": "<html>webext dummy</html>",
   },
+
+  async background() {
+    browser.test.log("background script running");
+    browser.webRequest.onAuthRequired.addListener(async (details) => {
+      browser.test.log("webRequest onAuthRequired");
+
+      // A blocking request that returns a promise exercises a codepath that
+      // sets the notificationCallbacks on the channel to a JS object that we
+      // can't do directly QueryObject on with expected results.
+      // This triggered a crash which was fixed in bug 1528188.
+      return new Promise(async (resolve, reject) => {
+        setTimeout(resolve, 0);
+      });
+    }, {urls: ["*://*/*"]}, ["blocking"]);
+  },
 };
 
 async function withExtensionDummy(callback) {
   let extension = ExtensionTestUtils.loadExtension(EXTENSION_DATA);
   await extension.startup();
   let rv = await callback(`moz-extension://${extension.uuid}/dummy.html`);
   await extension.unload();
   return rv;