Bug 1551744 move webrequest modules into extension component r=kmag
authorShane Caraveo <scaraveo@mozilla.com>
Wed, 15 May 2019 00:20:40 +0000
changeset 535771 9d42cbab5277796bf76e874bdc4fe3eaaad99889
parent 535770 90ff166702b5dd7e9848eef62746457b11d8fe92
child 535772 294fb9eba22edda7dd2f8c3691364eb8b6a2a2d0
push id2082
push userffxbld-merge
push dateMon, 01 Jul 2019 08:34:18 +0000
treeherdermozilla-release@2fb19d0466d2 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerskmag
bugs1551744
milestone68.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 1551744 move webrequest modules into extension component r=kmag Differential Revision: https://phabricator.services.mozilla.com/D31168
toolkit/components/extensions/test/xpcshell/data/dummy_page.html
toolkit/components/extensions/test/xpcshell/data/file_WebRequest_page2.html
toolkit/components/extensions/test/xpcshell/data/file_image_bad.png
toolkit/components/extensions/test/xpcshell/data/file_image_good.png
toolkit/components/extensions/test/xpcshell/data/file_image_redirect.png
toolkit/components/extensions/test/xpcshell/data/file_script_bad.js
toolkit/components/extensions/test/xpcshell/data/file_script_good.js
toolkit/components/extensions/test/xpcshell/data/file_script_redirect.js
toolkit/components/extensions/test/xpcshell/data/file_script_xhr.js
toolkit/components/extensions/test/xpcshell/data/file_style_bad.css
toolkit/components/extensions/test/xpcshell/data/file_style_good.css
toolkit/components/extensions/test/xpcshell/data/file_style_redirect.css
toolkit/components/extensions/test/xpcshell/test_webRequest_ancestors.js
toolkit/components/extensions/test/xpcshell/test_webRequest_cookies.js
toolkit/components/extensions/test/xpcshell/test_webRequest_filtering.js
toolkit/components/extensions/test/xpcshell/xpcshell-common.ini
toolkit/components/extensions/webrequest/SecurityInfo.jsm
toolkit/components/extensions/webrequest/WebRequest.jsm
toolkit/components/extensions/webrequest/WebRequestCommon.jsm
toolkit/components/extensions/webrequest/WebRequestContent.js
toolkit/components/extensions/webrequest/WebRequestUpload.jsm
toolkit/components/extensions/webrequest/moz.build
toolkit/modules/addons/SecurityInfo.jsm
toolkit/modules/addons/WebRequest.jsm
toolkit/modules/addons/WebRequestCommon.jsm
toolkit/modules/addons/WebRequestContent.js
toolkit/modules/addons/WebRequestUpload.jsm
toolkit/modules/moz.build
toolkit/modules/tests/browser/WebRequest_dynamic.sjs
toolkit/modules/tests/browser/WebRequest_redirection.sjs
toolkit/modules/tests/browser/browser.ini
toolkit/modules/tests/browser/browser_WebRequest.js
toolkit/modules/tests/browser/browser_WebRequest_ancestors.js
toolkit/modules/tests/browser/browser_WebRequest_cookies.js
toolkit/modules/tests/browser/browser_WebRequest_filtering.js
toolkit/modules/tests/browser/dummy_page.html
toolkit/modules/tests/browser/file_WebRequest_page1.html
toolkit/modules/tests/browser/file_WebRequest_page2.html
toolkit/modules/tests/browser/file_image_bad.png
toolkit/modules/tests/browser/file_image_good.png
toolkit/modules/tests/browser/file_image_redirect.png
toolkit/modules/tests/browser/file_script_bad.js
toolkit/modules/tests/browser/file_script_good.js
toolkit/modules/tests/browser/file_script_redirect.js
toolkit/modules/tests/browser/file_script_xhr.js
toolkit/modules/tests/browser/file_style_bad.css
toolkit/modules/tests/browser/file_style_good.css
toolkit/modules/tests/browser/file_style_redirect.css
rename from toolkit/modules/tests/browser/dummy_page.html
rename to toolkit/components/extensions/test/xpcshell/data/dummy_page.html
rename from toolkit/modules/tests/browser/file_WebRequest_page2.html
rename to toolkit/components/extensions/test/xpcshell/data/file_WebRequest_page2.html
rename from toolkit/modules/tests/browser/file_image_bad.png
rename to toolkit/components/extensions/test/xpcshell/data/file_image_bad.png
rename from toolkit/modules/tests/browser/file_image_good.png
rename to toolkit/components/extensions/test/xpcshell/data/file_image_good.png
copy from toolkit/modules/tests/browser/file_image_bad.png
copy to toolkit/components/extensions/test/xpcshell/data/file_image_redirect.png
rename from toolkit/modules/tests/browser/file_script_bad.js
rename to toolkit/components/extensions/test/xpcshell/data/file_script_bad.js
--- a/toolkit/modules/tests/browser/file_script_bad.js
+++ b/toolkit/components/extensions/test/xpcshell/data/file_script_bad.js
@@ -1,1 +1,3 @@
+"use strict";
+
 window.failure = true;
rename from toolkit/modules/tests/browser/file_script_good.js
rename to toolkit/components/extensions/test/xpcshell/data/file_script_good.js
--- a/toolkit/modules/tests/browser/file_script_good.js
+++ b/toolkit/components/extensions/test/xpcshell/data/file_script_good.js
@@ -1,1 +1,3 @@
+"use strict";
+
 window.success = window.success ? window.success + 1 : 1;
rename from toolkit/modules/tests/browser/file_script_redirect.js
rename to toolkit/components/extensions/test/xpcshell/data/file_script_redirect.js
--- a/toolkit/modules/tests/browser/file_script_redirect.js
+++ b/toolkit/components/extensions/test/xpcshell/data/file_script_redirect.js
@@ -1,2 +1,4 @@
+"use strict";
+
 window.failure = true;
 
rename from toolkit/modules/tests/browser/file_script_xhr.js
rename to toolkit/components/extensions/test/xpcshell/data/file_script_xhr.js
--- a/toolkit/modules/tests/browser/file_script_xhr.js
+++ b/toolkit/components/extensions/test/xpcshell/data/file_script_xhr.js
@@ -1,3 +1,5 @@
+"use strict";
+
 var request = new XMLHttpRequest();
 request.open("get", "http://example.com/browser/toolkit/modules/tests/browser/xhr_resource", false);
 request.send();
rename from toolkit/modules/tests/browser/file_style_bad.css
rename to toolkit/components/extensions/test/xpcshell/data/file_style_bad.css
rename from toolkit/modules/tests/browser/file_style_good.css
rename to toolkit/components/extensions/test/xpcshell/data/file_style_good.css
copy from toolkit/modules/tests/browser/file_style_bad.css
copy to toolkit/components/extensions/test/xpcshell/data/file_style_redirect.css
rename from toolkit/modules/tests/browser/browser_WebRequest_ancestors.js
rename to toolkit/components/extensions/test/xpcshell/test_webRequest_ancestors.js
--- a/toolkit/modules/tests/browser/browser_WebRequest_ancestors.js
+++ b/toolkit/components/extensions/test/xpcshell/test_webRequest_ancestors.js
@@ -1,30 +1,29 @@
 "use strict";
 
-// This test requires an XMLHttpRequest constructor which isn't
-// associated with a window.
-const {XMLHttpRequest} = Cu.Sandbox(window, {wantGlobalProperties: ["XMLHttpRequest"]});
-
 var {WebRequest} = ChromeUtils.import("resource://gre/modules/WebRequest.jsm");
 var {PromiseUtils} = ChromeUtils.import("resource://gre/modules/PromiseUtils.jsm");
 
+const server = createHttpServer({hosts: ["example.com"]});
+server.registerDirectory("/data/", do_get_file("data"));
+
 add_task(async function test_ancestors_exist() {
   let deferred = PromiseUtils.defer();
   function onBeforeRequest(details) {
     info(`onBeforeRequest ${details.url}`);
     ok(typeof details.frameAncestors === "object", `ancestors exists [${typeof details.frameAncestors}]`);
     deferred.resolve();
   }
 
-  WebRequest.onBeforeRequest.addListener(onBeforeRequest, {urls: new MatchPatternSet(["http://mochi.test/test/*"])}, ["blocking"]);
+  WebRequest.onBeforeRequest.addListener(onBeforeRequest, {urls: new MatchPatternSet(["http://example.com/*"])}, ["blocking"]);
 
-  let tab = await BrowserTestUtils.openNewForegroundTab(gBrowser, "http://mochi.test:8888/test/");
+  let contentPage = await ExtensionTestUtils.loadContentPage("http://example.com/data/file_sample.html");
   await deferred.promise;
-  BrowserTestUtils.removeTab(tab);
+  await contentPage.close();
 
   WebRequest.onBeforeRequest.removeListener(onBeforeRequest);
 });
 
 add_task(async function test_ancestors_null() {
   let deferred = PromiseUtils.defer();
   function onBeforeRequest(details) {
     info(`onBeforeRequest ${details.url}`);
@@ -42,13 +41,13 @@ add_task(async function test_ancestors_n
       xhr.onload = () => { resolve(xhr.responseText); };
       xhr.onerror = () => { reject(xhr.status); };
       // use a different contextId to avoid auth cache.
       xhr.setOriginAttributes({userContextId: 1});
       xhr.send();
     });
   }
 
-  await fetch("http://mochi.test:8888/test/");
+  await fetch("http://example.com/data/file_sample.html");
   await deferred.promise;
 
   WebRequest.onBeforeRequest.removeListener(onBeforeRequest);
 });
rename from toolkit/modules/tests/browser/browser_WebRequest_cookies.js
rename to toolkit/components/extensions/test/xpcshell/test_webRequest_cookies.js
--- a/toolkit/modules/tests/browser/browser_WebRequest_cookies.js
+++ b/toolkit/components/extensions/test/xpcshell/test_webRequest_cookies.js
@@ -1,14 +1,28 @@
 "use strict";
 
 var {WebRequest} = ChromeUtils.import("resource://gre/modules/WebRequest.jsm");
 
-const BASE = "http://example.com/browser/toolkit/modules/tests/browser";
-const URL = BASE + "/WebRequest_dynamic.sjs";
+const server = createHttpServer({hosts: ["example.com"]});
+server.registerPathHandler("/", (request, response) => {
+  response.setStatusLine(request.httpVersion, 200, "OK");
+  if (request.hasHeader("Cookie")) {
+    let value = request.getHeader("Cookie");
+    if (value == "blinky=1") {
+      response.setHeader("Set-Cookie", "dinky=1", false);
+    }
+    response.write("cookie-present");
+  } else {
+    response.setHeader("Set-Cookie", "foopy=1", false);
+    response.write("cookie-not-present");
+  }
+});
+
+const URL = "http://example.com/";
 
 var countBefore = 0;
 var countAfter = 0;
 
 function onBeforeSendHeaders(details) {
   if (details.url != URL) {
     return undefined;
   }
@@ -16,65 +30,56 @@ function onBeforeSendHeaders(details) {
   countBefore++;
 
   info(`onBeforeSendHeaders ${details.url}`);
   let found = false;
   let headers = [];
   for (let {name, value} of details.requestHeaders) {
     info(`Saw header ${name} '${value}'`);
     if (name == "Cookie") {
-      is(value, "foopy=1", "Cookie is correct");
+      equal(value, "foopy=1", "Cookie is correct");
       headers.push({name, value: "blinky=1"});
       found = true;
     } else {
       headers.push({name, value});
     }
   }
   ok(found, "Saw cookie header");
+  equal(countBefore, 1, "onBeforeSendHeaders hit once");
 
   return {requestHeaders: headers};
 }
 
 function onResponseStarted(details) {
   if (details.url != URL) {
     return;
   }
 
   countAfter++;
 
   info(`onResponseStarted ${details.url}`);
   let found = false;
   for (let {name, value} of details.responseHeaders) {
     info(`Saw header ${name} '${value}'`);
-    if (name == "Set-Cookie") {
-      is(value, "dinky=1", "Cookie is correct");
+    if (name == "set-cookie") {
+      equal(value, "dinky=1", "Cookie is correct");
       found = true;
     }
   }
   ok(found, "Saw cookie header");
+  equal(countAfter, 1, "onResponseStarted hit once");
 }
 
 add_task(async function filter_urls() {
   // First load the URL so that we set cookie foopy=1.
-  gBrowser.selectedTab = BrowserTestUtils.addTab(gBrowser, URL);
-  await waitForLoad();
-  gBrowser.removeCurrentTab();
+  let contentPage = await ExtensionTestUtils.loadContentPage(URL);
+  await contentPage.close();
 
   // Now load with WebRequest set up.
-  WebRequest.onBeforeSendHeaders.addListener(onBeforeSendHeaders, null, ["blocking"]);
-  WebRequest.onResponseStarted.addListener(onResponseStarted, null);
+  WebRequest.onBeforeSendHeaders.addListener(onBeforeSendHeaders, null, ["blocking", "requestHeaders"]);
+  WebRequest.onResponseStarted.addListener(onResponseStarted, null, ["responseHeaders"]);
 
-  gBrowser.selectedTab = BrowserTestUtils.addTab(gBrowser, URL);
-
-  await waitForLoad();
-
-  gBrowser.removeCurrentTab();
+  contentPage = await ExtensionTestUtils.loadContentPage(URL);
+  await contentPage.close();
 
   WebRequest.onBeforeSendHeaders.removeListener(onBeforeSendHeaders);
   WebRequest.onResponseStarted.removeListener(onResponseStarted);
-
-  is(countBefore, 1, "onBeforeSendHeaders hit once");
-  is(countAfter, 1, "onResponseStarted hit once");
 });
-
-function waitForLoad(browser = gBrowser.selectedBrowser) {
-  return BrowserTestUtils.browserLoaded(browser);
-}
rename from toolkit/modules/tests/browser/browser_WebRequest_filtering.js
rename to toolkit/components/extensions/test/xpcshell/test_webRequest_filtering.js
--- a/toolkit/modules/tests/browser/browser_WebRequest_filtering.js
+++ b/toolkit/components/extensions/test/xpcshell/test_webRequest_filtering.js
@@ -1,13 +1,16 @@
 "use strict";
 
 var {WebRequest} = ChromeUtils.import("resource://gre/modules/WebRequest.jsm");
 
-const BASE = "http://example.com/browser/toolkit/modules/tests/browser";
+const server = createHttpServer({hosts: ["example.com"]});
+server.registerDirectory("/data/", do_get_file("data"));
+
+const BASE = "http://example.com/data/";
 const URL = BASE + "/file_WebRequest_page2.html";
 
 var requested = [];
 
 function onBeforeRequest(details) {
   info(`onBeforeRequest ${details.url}`);
   if (details.url.startsWith(BASE)) {
     requested.push(details.url);
@@ -48,36 +51,33 @@ function removeDupes(list) {
   list.length = j + 1;
 }
 
 function compareLists(list1, list2, kind) {
   list1.sort();
   removeDupes(list1);
   list2.sort();
   removeDupes(list2);
-  is(String(list1), String(list2), `${kind} URLs correct`);
+  equal(String(list1), String(list2), `${kind} URLs correct`);
 }
 
 add_task(async function setup() {
   // Disable rcwn to make cache behavior deterministic.
-  await SpecialPowers.pushPrefEnv({set: [["network.http.rcwn.enabled", false]]});
+  Services.prefs.setBoolPref("network.http.rcwn.enabled", false);
 });
 
 add_task(async function filter_urls() {
   let filter = {urls: new MatchPatternSet(["*://*/*_style_*"])};
 
   WebRequest.onBeforeRequest.addListener(onBeforeRequest, filter, ["blocking"]);
   WebRequest.onBeforeSendHeaders.addListener(onBeforeSendHeaders, filter, ["blocking"]);
   WebRequest.onResponseStarted.addListener(onResponseStarted, filter);
 
-  gBrowser.selectedTab = BrowserTestUtils.addTab(gBrowser, URL);
-
-  await waitForLoad();
-
-  gBrowser.removeCurrentTab();
+  let contentPage = await ExtensionTestUtils.loadContentPage(URL);
+  await contentPage.close();
 
   compareLists(requested, expected_urls, "requested");
   compareLists(sendHeaders, expected_urls, "sendHeaders");
   compareLists(completed, expected_urls, "completed");
 
   WebRequest.onBeforeRequest.removeListener(onBeforeRequest);
   WebRequest.onBeforeSendHeaders.removeListener(onBeforeSendHeaders);
   WebRequest.onResponseStarted.removeListener(onResponseStarted);
@@ -85,26 +85,19 @@ add_task(async function filter_urls() {
 
 add_task(async function filter_types() {
   let filter = {types: ["stylesheet"]};
 
   WebRequest.onBeforeRequest.addListener(onBeforeRequest, filter, ["blocking"]);
   WebRequest.onBeforeSendHeaders.addListener(onBeforeSendHeaders, filter, ["blocking"]);
   WebRequest.onResponseStarted.addListener(onResponseStarted, filter);
 
-  gBrowser.selectedTab = BrowserTestUtils.addTab(gBrowser, URL);
-
-  await waitForLoad();
-
-  gBrowser.removeCurrentTab();
+  let contentPage = await ExtensionTestUtils.loadContentPage(URL);
+  await contentPage.close();
 
   compareLists(requested, expected_urls, "requested");
   compareLists(sendHeaders, expected_urls, "sendHeaders");
   compareLists(completed, expected_urls, "completed");
 
   WebRequest.onBeforeRequest.removeListener(onBeforeRequest);
   WebRequest.onBeforeSendHeaders.removeListener(onBeforeSendHeaders);
   WebRequest.onResponseStarted.removeListener(onResponseStarted);
 });
-
-function waitForLoad(browser = gBrowser.selectedBrowser) {
-  return BrowserTestUtils.browserLoaded(browser);
-}
--- a/toolkit/components/extensions/test/xpcshell/xpcshell-common.ini
+++ b/toolkit/components/extensions/test/xpcshell/xpcshell-common.ini
@@ -176,11 +176,14 @@ skip-if = appname == "thunderbird" || os
 skip-if = appname == "thunderbird" || os == "android" # Bug 1350559
 [test_proxy_listener.js]
 [test_proxy_incognito.js]
 skip-if = os == "android" # incognito not supported on android
 [test_proxy_scripts.js]
 [test_proxy_scripts_deprecated.js]
 [test_proxy_scripts_results.js]
 [test_proxy_userContextId.js]
+[test_webRequest_ancestors.js]
+[test_webRequest_cookies.js]
+[test_webRequest_filtering.js]
 [test_ext_brokenlinks.js]
 [test_ext_performance_counters.js]
 skip-if = appname == "thunderbird" || os == "android"
rename from toolkit/modules/addons/SecurityInfo.jsm
rename to toolkit/components/extensions/webrequest/SecurityInfo.jsm
rename from toolkit/modules/addons/WebRequest.jsm
rename to toolkit/components/extensions/webrequest/WebRequest.jsm
rename from toolkit/modules/addons/WebRequestCommon.jsm
rename to toolkit/components/extensions/webrequest/WebRequestCommon.jsm
rename from toolkit/modules/addons/WebRequestContent.js
rename to toolkit/components/extensions/webrequest/WebRequestContent.js
rename from toolkit/modules/addons/WebRequestUpload.jsm
rename to toolkit/components/extensions/webrequest/WebRequestUpload.jsm
--- a/toolkit/components/extensions/webrequest/moz.build
+++ b/toolkit/components/extensions/webrequest/moz.build
@@ -1,14 +1,22 @@
 # -*- Mode: python; indent-tabs-mode: nil; tab-width: 40 -*-
 # vim: set filetype=python:
 # This Source Code Form is subject to the terms of the Mozilla Public
 # License, v. 2.0. If a copy of the MPL was not distributed with this
 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
 
+EXTRA_JS_MODULES += [
+    'SecurityInfo.jsm',
+    'WebRequest.jsm',
+    'WebRequestCommon.jsm',
+    'WebRequestContent.js',
+    'WebRequestUpload.jsm',
+]
+
 UNIFIED_SOURCES += [
     'ChannelWrapper.cpp',
     'StreamFilter.cpp',
     'StreamFilterChild.cpp',
     'StreamFilterEvents.cpp',
     'StreamFilterParent.cpp',
     'WebRequestService.cpp',
 ]
--- a/toolkit/modules/moz.build
+++ b/toolkit/modules/moz.build
@@ -163,24 +163,19 @@ with Files('docs/**'):
     SCHEDULES.exclusive = ['docs']
 
 EXTRA_JS_MODULES += [
     'AboutPagesUtils.jsm',
     'ActorChild.jsm',
     'ActorManagerChild.jsm',
     'ActorManagerParent.jsm',
     'addons/MatchURLFilters.jsm',
-    'addons/SecurityInfo.jsm',
     'addons/WebNavigation.jsm',
     'addons/WebNavigationContent.js',
     'addons/WebNavigationFrames.jsm',
-    'addons/WebRequest.jsm',
-    'addons/WebRequestCommon.jsm',
-    'addons/WebRequestContent.js',
-    'addons/WebRequestUpload.jsm',
     'AppMenuNotifications.jsm',
     'AsyncPrefs.jsm',
     'AutoCompletePopupContent.jsm',
     'AutoScrollController.jsm',
     'BinarySearch.jsm',
     'BrowserUtils.jsm',
     'CanonicalJSON.jsm',
     'CertUtils.jsm',
deleted file mode 100644
--- a/toolkit/modules/tests/browser/WebRequest_dynamic.sjs
+++ /dev/null
@@ -1,13 +0,0 @@
-function handleRequest(aRequest, aResponse) {
-  aResponse.setStatusLine(aRequest.httpVersion, 200);
-  if (aRequest.hasHeader('Cookie')) {
-    let value = aRequest.getHeader("Cookie");
-    if (value == "blinky=1") {
-      aResponse.setHeader("Set-Cookie", "dinky=1");
-    }
-    aResponse.write("cookie-present");
-  } else {
-    aResponse.setHeader("Set-Cookie", "foopy=1");
-    aResponse.write("cookie-not-present");
-  }
-}
deleted file mode 100644
--- a/toolkit/modules/tests/browser/WebRequest_redirection.sjs
+++ /dev/null
@@ -1,4 +0,0 @@
-function handleRequest(aRequest, aResponse) {
-  aResponse.setStatusLine(aRequest.httpVersion, 302);
-  aResponse.setHeader("Location", "./dummy_page.html");
-}
--- a/toolkit/modules/tests/browser/browser.ini
+++ b/toolkit/modules/tests/browser/browser.ini
@@ -1,32 +1,17 @@
 [DEFAULT]
 support-files =
-  dummy_page.html
   file_FinderIframeTest.html
   file_FinderSample.html
   file_WebNavigation_page1.html
   file_WebNavigation_page2.html
   file_WebNavigation_page3.html
-  file_WebRequest_page1.html
-  file_WebRequest_page2.html
   file_getSelectionDetails_inputs.html
-  file_image_good.png
-  file_image_bad.png
-  file_image_redirect.png
-  file_style_good.css
-  file_style_bad.css
-  file_style_redirect.css
-  file_script_good.js
-  file_script_bad.js
-  file_script_redirect.js
-  file_script_xhr.js
   head.js
-  WebRequest_dynamic.sjs
-  WebRequest_redirection.sjs
 
 [browser_AsyncPrefs.js]
 [browser_BrowserUtils.js]
 [browser_CreditCard.js]
 [browser_Deprecated.js]
 [browser_Finder.js]
 [browser_Finder_hidden_textarea.js]
 skip-if = verify && debug
@@ -40,15 +25,10 @@ skip-if = (verify && debug && (os == 'ma
 [browser_FinderHighlighter.js]
 skip-if = debug || os = "linux"
 [browser_FinderHighlighter2.js]
 skip-if = debug || os = "linux"
 [browser_Geometry.js]
 [browser_InlineSpellChecker.js]
 [browser_WebNavigation.js]
 skip-if = true # Superseded by WebExtension tests
-[browser_WebRequest.js]
-skip-if = (verify && debug && (os == 'mac'))
-[browser_WebRequest_ancestors.js]
-[browser_WebRequest_cookies.js]
-[browser_WebRequest_filtering.js]
 [browser_PromiseMessage.js]
 [browser_Troubleshoot.js]
deleted file mode 100644
--- a/toolkit/modules/tests/browser/browser_WebRequest.js
+++ /dev/null
@@ -1,209 +0,0 @@
-"use strict";
-
-var {WebRequest} = ChromeUtils.import("resource://gre/modules/WebRequest.jsm");
-
-const BASE = "http://example.com/browser/toolkit/modules/tests/browser";
-const URL = BASE + "/file_WebRequest_page1.html";
-
-var expected_browser;
-
-function checkType(details) {
-  let expected_type = "???";
-  if (details.url.includes("style")) {
-    expected_type = "stylesheet";
-  } else if (details.url.includes("image")) {
-    expected_type = "image";
-  } else if (details.url.includes("script")) {
-    expected_type = "script";
-  } else if (details.url.includes("page1")) {
-    expected_type = "main_frame";
-  } else if (/page2|_redirection\.|dummy_page/.test(details.url)) {
-    expected_type = "sub_frame";
-  } else if (details.url.includes("xhr")) {
-    expected_type = "xmlhttprequest";
-  }
-  is(details.type, expected_type, "resource type is correct");
-}
-
-var windowIDs = new Map();
-
-var requested = [];
-
-function onBeforeRequest(details) {
-  info(`onBeforeRequest ${details.url}`);
-  if (details.url.startsWith(BASE)) {
-    requested.push(details.url);
-
-    is(details.browser, expected_browser, "correct <browser> element");
-    checkType(details);
-
-    windowIDs.set(details.url, details.windowId);
-    if (details.url.includes("page2")) {
-      let page1id = windowIDs.get(URL);
-      ok(details.windowId != page1id, "sub-frame gets its own window ID");
-      is(details.parentWindowId, page1id, "parent window id is correct");
-
-      is(details.frameAncestors.length, 1, "correctly has only one ancestor");
-      let ancestor = details.frameAncestors[0];
-      ok(ancestor.url.includes("page1"), "parent window url seems correct");
-      is(ancestor.frameId, page1id, "parent window id is correct");
-    }
-  }
-  if (details.url.includes("_bad.")) {
-    return {cancel: true};
-  }
-  return undefined;
-}
-
-var sendHeaders = [];
-
-function onBeforeSendHeaders(details) {
-  info(`onBeforeSendHeaders ${details.url}`);
-  if (details.url.startsWith(BASE)) {
-    sendHeaders.push(details.url);
-
-    is(details.browser, expected_browser, "correct <browser> element");
-    checkType(details);
-
-    let id = windowIDs.get(details.url);
-    is(id, details.windowId, "window ID same in onBeforeSendHeaders as onBeforeRequest");
-  }
-  if (details.url.includes("_redirect.")) {
-    return {redirectUrl: details.url.replace("_redirect.", "_good.")};
-  }
-  return undefined;
-}
-
-var beforeRedirect = [];
-
-function onBeforeRedirect(details) {
-  info(`onBeforeRedirect ${details.url} -> ${details.redirectUrl}`);
-  checkType(details);
-  if (details.url.startsWith(BASE)) {
-    beforeRedirect.push(details.url);
-
-    is(details.browser, expected_browser, "correct <browser> element");
-    checkType(details);
-
-    let expectedUrl = details.url.replace("_redirect.", "_good.").replace(/\w+_redirection\..*/, "dummy_page.html");
-    is(details.redirectUrl, expectedUrl, "Correct redirectUrl value");
-  }
-  let id = windowIDs.get(details.url);
-  is(id, details.windowId, "window ID same in onBeforeRedirect as onBeforeRequest");
-  // associate stored windowId with final url
-  windowIDs.set(details.redirectUrl, details.windowId);
-  return {};
-}
-
-var headersReceived = [];
-
-function onResponseStarted(details) {
-  if (details.url.startsWith(BASE)) {
-    headersReceived.push(details.url);
-  }
-}
-
-const expected_requested = [BASE + "/file_WebRequest_page1.html",
-                            BASE + "/file_style_good.css",
-                            BASE + "/file_style_bad.css",
-                            BASE + "/file_style_redirect.css",
-                            BASE + "/file_image_good.png",
-                            BASE + "/file_image_bad.png",
-                            BASE + "/file_image_redirect.png",
-                            BASE + "/file_script_good.js",
-                            BASE + "/file_script_bad.js",
-                            BASE + "/file_script_redirect.js",
-                            BASE + "/file_script_xhr.js",
-                            BASE + "/file_WebRequest_page2.html",
-                            BASE + "/nonexistent_script_url.js",
-                            BASE + "/WebRequest_redirection.sjs",
-                            BASE + "/dummy_page.html",
-                            BASE + "/xhr_resource"];
-
-const expected_sendHeaders = [BASE + "/file_WebRequest_page1.html",
-                              BASE + "/file_style_good.css",
-                              BASE + "/file_style_redirect.css",
-                              BASE + "/file_image_good.png",
-                              BASE + "/file_image_redirect.png",
-                              BASE + "/file_script_good.js",
-                              BASE + "/file_script_redirect.js",
-                              BASE + "/file_script_xhr.js",
-                              BASE + "/file_WebRequest_page2.html",
-                              BASE + "/nonexistent_script_url.js",
-                              BASE + "/WebRequest_redirection.sjs",
-                              BASE + "/dummy_page.html",
-                              BASE + "/xhr_resource"];
-
-const expected_beforeRedirect = expected_sendHeaders.filter(u => /_redirect\./.test(u))
-                                  .concat(BASE + "/WebRequest_redirection.sjs");
-
-const expected_headersReceived = [BASE + "/file_WebRequest_page1.html",
-                                  BASE + "/file_style_good.css",
-                                  BASE + "/file_image_good.png",
-                                  BASE + "/file_script_good.js",
-                                  BASE + "/file_script_xhr.js",
-                                  BASE + "/file_WebRequest_page2.html",
-                                  BASE + "/nonexistent_script_url.js",
-                                  BASE + "/dummy_page.html",
-                                  BASE + "/xhr_resource"];
-
-function removeDupes(list) {
-  let j = 0;
-  for (let i = 1; i < list.length; i++) {
-    if (list[i] != list[j]) {
-      j++;
-      if (i != j) {
-        list[j] = list[i];
-      }
-    }
-  }
-  list.length = j + 1;
-}
-
-function compareLists(list1, list2, kind) {
-  list1.sort();
-  removeDupes(list1);
-  list2.sort();
-  removeDupes(list2);
-  is(String(list1), String(list2), `${kind} URLs correct`);
-}
-
-async function test_once() {
-  WebRequest.onBeforeRequest.addListener(onBeforeRequest, null, ["blocking"]);
-  WebRequest.onBeforeSendHeaders.addListener(onBeforeSendHeaders, null, ["blocking"]);
-  WebRequest.onBeforeRedirect.addListener(onBeforeRedirect);
-  WebRequest.onResponseStarted.addListener(onResponseStarted);
-
-  await BrowserTestUtils.withNewTab({ gBrowser, url: "about:blank" },
-    async function(browser) {
-      expected_browser = browser;
-      BrowserTestUtils.loadURI(browser, URL);
-      await BrowserTestUtils.browserLoaded(expected_browser);
-
-      expected_browser = null;
-
-      await ContentTask.spawn(browser, null, function() {
-        let win = content.wrappedJSObject;
-        is(win.success, 2, "Good script ran");
-        is(win.failure, undefined, "Failure script didn't run");
-
-        let style =
-          content.getComputedStyle(content.document.getElementById("test"));
-        is(style.getPropertyValue("color"), "rgb(255, 0, 0)", "Good CSS loaded");
-      });
-    });
-
-  compareLists(requested, expected_requested, "requested");
-  compareLists(sendHeaders, expected_sendHeaders, "sendHeaders");
-  compareLists(beforeRedirect, expected_beforeRedirect, "beforeRedirect");
-  compareLists(headersReceived, expected_headersReceived, "headersReceived");
-
-  WebRequest.onBeforeRequest.removeListener(onBeforeRequest);
-  WebRequest.onBeforeSendHeaders.removeListener(onBeforeSendHeaders);
-  WebRequest.onBeforeRedirect.removeListener(onBeforeRedirect);
-  WebRequest.onResponseStarted.removeListener(onResponseStarted);
-}
-
-// Run the test twice to make sure it works with caching.
-add_task(test_once);
-add_task(test_once);
deleted file mode 100644
--- a/toolkit/modules/tests/browser/file_WebRequest_page1.html
+++ /dev/null
@@ -1,29 +0,0 @@
-<!DOCTYPE HTML>
-
-<html>
-<head>
-<meta charset="utf-8">
-<link rel="stylesheet" href="file_style_good.css">
-<link rel="stylesheet" href="file_style_bad.css">
-<link rel="stylesheet" href="file_style_redirect.css">
-</head>
-<body>
-
-<div id="test">Sample text</div>
-
-<img id="img_good" src="file_image_good.png">
-<img id="img_bad" src="file_image_bad.png">
-<img id="img_redirect" src="file_image_redirect.png">
-
-<script src="file_script_good.js"></script>
-<script src="file_script_bad.js"></script>
-<script src="file_script_redirect.js"></script>
-
-<script src="file_script_xhr.js"></script>
-
-<script src="nonexistent_script_url.js"></script>
-
-<iframe src="file_WebRequest_page2.html" width="200" height="200"></iframe>
-<iframe src="WebRequest_redirection.sjs" width="200" height="50"></iframe>
-</body>
-</html>
deleted file mode 100644
index 4c3be508477eb19cd08ddf4d0f568a06a4ec7a45..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391
GIT binary patch
literal 0
Hc$@<O00001
deleted file mode 100644
--- a/toolkit/modules/tests/browser/file_style_redirect.css
+++ /dev/null
@@ -1,3 +0,0 @@
-#test {
-  color: green !important;
-}