Bug 1676956 - Run StreamFilter tests with oop extensions too r=mixedpuppy
☠☠ backed out by 24bbee272252 ☠ ☠
authorRob Wu <rob@robwu.nl>
Thu, 17 Dec 2020 15:30:02 +0000
changeset 561137 5e7653247208f42860d6c52b8b8a43ed25ba9dfd
parent 561136 ae4e6196f6026b5e9f4566414034828a61b65436
child 561138 a421fd8b98973bcd6569ccc904523105c7282cd6
push id133039
push userrob@robwu.nl
push dateThu, 17 Dec 2020 15:49:11 +0000
treeherderautoland@5e7653247208 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmixedpuppy
bugs1676956
milestone86.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 1676956 - Run StreamFilter tests with oop extensions too r=mixedpuppy This patch ensures that the StreamFilter unit tests run on all supported configurations (e10s + out-of-process extensions in particular), and not just e10s + in-process extensions. Differential Revision: https://phabricator.services.mozilla.com/D98797
toolkit/components/extensions/test/xpcshell/test_ext_webRequest_startup.js
toolkit/components/extensions/test/xpcshell/test_ext_webRequest_startup_StreamFilter.js
toolkit/components/extensions/test/xpcshell/xpcshell-common-e10s.ini
toolkit/components/extensions/test/xpcshell/xpcshell-common.ini
toolkit/components/extensions/test/xpcshell/xpcshell-e10s.ini
toolkit/components/extensions/test/xpcshell/xpcshell-remote.ini
toolkit/components/extensions/test/xpcshell/xpcshell.ini
--- a/toolkit/components/extensions/test/xpcshell/test_ext_webRequest_startup.js
+++ b/toolkit/components/extensions/test/xpcshell/test_ext_webRequest_startup.js
@@ -167,76 +167,16 @@ add_task(async function test_2() {
 
   Services.obs.notifyObservers(null, "sessionstore-windows-restored");
   await extension.awaitMessage("ready");
 
   await extension.unload();
   await promiseShutdownManager();
 });
 
-// Test that a blocking listener that uses filterResponseData() works
-// properly (i.e., that the delayed call to registerTraceableChannel
-// works properly).
-add_task(async function test_3() {
-  const DATA = `<!DOCTYPE html>
-<html>
-<body>
-  <h1>This is a modified page</h1>
-</body>
-</html>`;
-
-  function background(data) {
-    browser.webRequest.onBeforeRequest.addListener(
-      details => {
-        let filter = browser.webRequest.filterResponseData(details.requestId);
-        filter.onstop = () => {
-          let encoded = new TextEncoder("utf-8").encode(data);
-          filter.write(encoded);
-          filter.close();
-        };
-      },
-      { urls: ["http://example.com/data/file_sample.html"] },
-      ["blocking"]
-    );
-  }
-
-  await promiseStartupManager();
-
-  let extension = ExtensionTestUtils.loadExtension({
-    useAddonManager: "permanent",
-    manifest: {
-      permissions: ["webRequest", "webRequestBlocking", "http://example.com/"],
-    },
-
-    background: `(${background})(${uneval(DATA)})`,
-  });
-
-  await extension.startup();
-
-  await promiseRestartManager();
-  await extension.awaitStartup();
-
-  let dataPromise = ExtensionTestUtils.fetch(
-    "http://example.com/",
-    "http://example.com/data/file_sample.html"
-  );
-
-  Services.obs.notifyObservers(null, "browser-delayed-startup-finished");
-  let data = await dataPromise;
-
-  equal(
-    data,
-    DATA,
-    "Stream filter was properly installed for a load during startup"
-  );
-
-  await extension.unload();
-  await promiseShutdownManager();
-});
-
 // Tests that moving permission to optional retains permission and that the
 // persistent listeners are used as expected.
 add_task(async function test_persistent_listener_after_sideload_upgrade() {
   let id = "permission-sideload-upgrade@test";
   let extensionData = {
     useAddonManager: "permanent",
     manifest: {
       version: "1.0",
new file mode 100644
--- /dev/null
+++ b/toolkit/components/extensions/test/xpcshell/test_ext_webRequest_startup_StreamFilter.js
@@ -0,0 +1,84 @@
+"use strict";
+
+AddonTestUtils.init(this);
+AddonTestUtils.overrideCertDB();
+AddonTestUtils.createAppInfo(
+  "xpcshell@tests.mozilla.org",
+  "XPCShell",
+  "1",
+  "43"
+);
+
+let {
+  promiseRestartManager,
+  promiseShutdownManager,
+  promiseStartupManager,
+} = AddonTestUtils;
+
+const server = createHttpServer({ hosts: ["example.com"] });
+server.registerDirectory("/data/", do_get_file("data"));
+
+Services.prefs.setBoolPref(
+  "extensions.webextensions.background-delayed-startup",
+  true
+);
+
+// Test that a blocking listener that uses filterResponseData() works
+// properly (i.e., that the delayed call to registerTraceableChannel
+// works properly).
+add_task(async function test_StreamFilter_at_restart() {
+  const DATA = `<!DOCTYPE html>
+<html>
+<body>
+  <h1>This is a modified page</h1>
+</body>
+</html>`;
+
+  function background(data) {
+    browser.webRequest.onBeforeRequest.addListener(
+      details => {
+        let filter = browser.webRequest.filterResponseData(details.requestId);
+        filter.onstop = () => {
+          let encoded = new TextEncoder("utf-8").encode(data);
+          filter.write(encoded);
+          filter.close();
+        };
+      },
+      { urls: ["http://example.com/data/file_sample.html"] },
+      ["blocking"]
+    );
+  }
+
+  await promiseStartupManager();
+
+  let extension = ExtensionTestUtils.loadExtension({
+    useAddonManager: "permanent",
+    manifest: {
+      permissions: ["webRequest", "webRequestBlocking", "http://example.com/"],
+    },
+
+    background: `(${background})(${uneval(DATA)})`,
+  });
+
+  await extension.startup();
+
+  await promiseRestartManager();
+  await extension.awaitStartup();
+
+  let dataPromise = ExtensionTestUtils.fetch(
+    "http://example.com/",
+    "http://example.com/data/file_sample.html"
+  );
+
+  Services.obs.notifyObservers(null, "browser-delayed-startup-finished");
+  let data = await dataPromise;
+
+  equal(
+    data,
+    DATA,
+    "Stream filter was properly installed for a load during startup"
+  );
+
+  await extension.unload();
+  await promiseShutdownManager();
+});
new file mode 100644
--- /dev/null
+++ b/toolkit/components/extensions/test/xpcshell/xpcshell-common-e10s.ini
@@ -0,0 +1,10 @@
+# Similar to xpcshell-common.ini, except tests here only run
+# when e10s is enabled (with or without out-of-process extensions).
+
+[test_ext_webRequest_filterResponseData.js]
+# tsan failure is for test_filter_301 timing out, bug 1674773
+skip-if = tsan || os == "android" && debug
+[test_ext_webRequest_responseBody.js]
+skip-if = os == "android" && debug
+[test_ext_webRequest_startup_StreamFilter.js]
+skip-if = os == "android" && debug
--- a/toolkit/components/extensions/test/xpcshell/xpcshell-common.ini
+++ b/toolkit/components/extensions/test/xpcshell/xpcshell-common.ini
@@ -215,16 +215,18 @@ skip-if = os == "android" && debug
 [test_ext_webRequest_permission.js]
 skip-if = os == "android" && debug
 [test_ext_webRequest_redirect_mozextension.js]
 skip-if = os == "android" # Android: Bug 1680132
 [test_ext_webRequest_requestSize.js]
 skip-if = socketprocess_networking
 [test_ext_webRequest_set_cookie.js]
 skip-if = appname == "thunderbird"
+[test_ext_webRequest_startup.js]
+skip-if = os == "android" && debug
 [test_ext_webRequest_style_cache.js]
 skip-if = os == "android" # Android: Bug 1680132
 [test_ext_webRequest_suspend.js]
 [test_ext_webRequest_userContextId.js]
 [test_ext_webRequest_viewsource.js]
 [test_ext_webRequest_webSocket.js]
 skip-if = appname == "thunderbird"
 [test_ext_xhr_capabilities.js]
--- a/toolkit/components/extensions/test/xpcshell/xpcshell-e10s.ini
+++ b/toolkit/components/extensions/test/xpcshell/xpcshell-e10s.ini
@@ -13,20 +13,16 @@ tags = webextensions webextensions-e10s
 # Make sure that loading the default settings for url-classifier-skip-urls
 # doesn't interfere with running our tests while IDB operations are in
 # flight by overriding the default remote settings bucket pref name to
 # ensure that the IDB database isn't created in the first place.
 prefs =
   services.settings.server=http://localhost:7777/remote-settings-dummy/v1
   services.settings.default_bucket=nonexistent-bucket-foo
 
+[include:xpcshell-common-e10s.ini]
 [include:xpcshell-content.ini]
 
-[test_ext_webRequest_filterResponseData.js]
-# tsan failure is for test_filter_301 timing out, bug 1674773
-skip-if = tsan || os == "android" && debug
-# streamFilter is supported with e10s only
-[test_ext_webRequest_responseBody.js]
-skip-if = os == "android" && debug
-# streamFilter is supported with e10s only
-[test_ext_webRequest_startup.js]
-skip-if = os == "android" && debug
-# streamFilter is supported with e10s only
\ No newline at end of file
+# Tests that need to run with e10s only must NOT be placed here,
+# but in xpcshell-common-e10s.ini.
+# A test here will only run on one configuration, e10s + in-process extensions,
+# while the primary target is e10s + out-of-process extensions.
+# xpcshell-common-e10s.ini runs in both configurations.
--- a/toolkit/components/extensions/test/xpcshell/xpcshell-remote.ini
+++ b/toolkit/components/extensions/test/xpcshell/xpcshell-remote.ini
@@ -14,16 +14,17 @@ tags = webextensions remote-webextension
 # doesn't interfere with running our tests while IDB operations are in
 # flight by overriding the default remote settings bucket pref name to
 # ensure that the IDB database isn't created in the first place.
 prefs =
   services.settings.server=http://localhost:7777/remote-settings-dummy/v1
   services.settings.default_bucket=nonexistent-bucket-foo
 
 [include:xpcshell-common.ini]
+[include:xpcshell-common-e10s.ini]
 [include:xpcshell-content.ini]
 
 [test_ext_contentscript_perf_observers.js] # Inexplicably, PerformanceObserver used in the test doesn't fire in non-e10s mode.
 skip-if = tsan
 [test_ext_contentscript_xorigin_frame.js]
 [test_WebExtensionContentScript.js]
 [test_ext_ipcBlob.js]
 skip-if = os == 'android' && processor == 'x86_64'
--- a/toolkit/components/extensions/test/xpcshell/xpcshell.ini
+++ b/toolkit/components/extensions/test/xpcshell/xpcshell.ini
@@ -20,22 +20,24 @@ prefs =
 # configuration, or do not support out-of-process content or extensions
 # for one reason or another.
 #
 # Tests which are affected by remote content or remote extensions should
 # go in one of:
 #
 #  - xpcshell-common.ini
 #    For tests which should run in all configurations.
+#  - xpcshell-common-e10s.ini
+#    For tests which should run in all configurations where e10s is enabled.
 #  - xpcshell-remote.ini
 #    For tests which should only run with both remote extensions and remote content.
 #  - xpcshell-content.ini
 #    For tests which rely on content pages, and should run in all configurations.
 #  - xpcshell-e10s.ini
-#    For tests which rely on conetn pages, and should only run with remote content
+#    For tests which rely on content pages, and should only run with remote content
 #    but in-process extensions.
 
 [test_ExtensionStorageSync_migration_kinto.js]
 skip-if = os == 'android' # Not shipped on Android
 [test_MatchPattern.js]
 [test_StorageSyncService.js]
 skip-if = os == 'android' && processor == 'x86_64'
 [test_WebExtensionPolicy.js]