Bug 1642676 - Move test case for SharedWorker disallowed on in-process-webextensions mode into a separate test-file. r=mixedpuppy
☠☠ backed out by 65edebab7a93 ☠ ☠
authorLuca Greco <lgreco@mozilla.com>
Tue, 23 Jun 2020 15:44:43 +0000
changeset 536926 166624b9d855cbcb38f5f11c3cab3e3e66e8f825
parent 536925 110cd0433bbe2ecc3f9517ce1e44e12b284da23b
child 536927 4c3471f84863ed3489900cc05813d9c27dc8cd76
push id37533
push userdluca@mozilla.com
push dateTue, 23 Jun 2020 21:38:40 +0000
treeherdermozilla-central@d48aa0f0aa0b [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmixedpuppy
bugs1642676
milestone79.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 1642676 - Move test case for SharedWorker disallowed on in-process-webextensions mode into a separate test-file. r=mixedpuppy Differential Revision: https://phabricator.services.mozilla.com/D80517
toolkit/components/extensions/test/xpcshell/test_ext_shared_workers.js
toolkit/components/extensions/test/xpcshell/test_ext_shared_workers_mainprocess_disallowed.js
toolkit/components/extensions/test/xpcshell/xpcshell-common.ini
toolkit/components/extensions/test/xpcshell/xpcshell-remote.ini
toolkit/components/extensions/test/xpcshell/xpcshell.ini
--- a/toolkit/components/extensions/test/xpcshell/test_ext_shared_workers.js
+++ b/toolkit/components/extensions/test/xpcshell/test_ext_shared_workers.js
@@ -1,49 +1,26 @@
 /* Any copyright is dedicated to the Public Domain.
  * http://creativecommons.org/publicdomain/zero/1.0/ */
 
 "use strict";
 
 // This test attemps to verify that:
 // - SharedWorkers can be created and successfully spawned by web extensions
 //   when web-extensions run in their own child process.
-// - SharedWorkers cannot be created by web extensions when web extensions
-//   are being run in the main process (because SharedWorkers are only
-//   allowed to be spawned in the parent process if they have a system principal).
 add_task(async function test_spawn_shared_worker() {
-  const background = WebExtensionPolicy.useRemoteWebExtensions
-    ? async function() {
-        const worker = new SharedWorker("worker.js");
-        await new Promise(resolve => {
-          worker.port.onmessage = resolve;
-          worker.port.postMessage("bgpage->worker");
-        });
-        browser.test.sendMessage("test-shared-worker:done");
-      }
-    : function() {
-        // This test covers the builds where the extensions are still
-        // running in the main process (it just checks that we don't
-        // allow it).
-        browser.test.assertThrows(
-          () => {
-            try {
-              new SharedWorker("worker.js");
-            } catch (e) {
-              // assertThrows is currently failing to match the error message
-              // automatically, let's cheat a little bit for now.
-              throw new Error(`${e}`);
-            }
-          },
-          /NS_ERROR_ABORT/,
-          "Got the expected failure in non-remote mode"
-        );
+  const background = async function() {
+    const worker = new SharedWorker("worker.js");
+    await new Promise(resolve => {
+      worker.port.onmessage = resolve;
+      worker.port.postMessage("bgpage->worker");
+    });
+    browser.test.sendMessage("test-shared-worker:done");
+  };
 
-        browser.test.sendMessage("test-shared-worker:done");
-      };
   const extension = ExtensionTestUtils.loadExtension({
     background,
     files: {
       "worker.js": function() {
         self.onconnect = evt => {
           const port = evt.ports[0];
           port.onmessage = () => port.postMessage("worker-reply");
         };
copy from toolkit/components/extensions/test/xpcshell/test_ext_shared_workers.js
copy to toolkit/components/extensions/test/xpcshell/test_ext_shared_workers_mainprocess_disallowed.js
--- a/toolkit/components/extensions/test/xpcshell/test_ext_shared_workers.js
+++ b/toolkit/components/extensions/test/xpcshell/test_ext_shared_workers_mainprocess_disallowed.js
@@ -1,49 +1,38 @@
 /* Any copyright is dedicated to the Public Domain.
  * http://creativecommons.org/publicdomain/zero/1.0/ */
 
 "use strict";
 
 // This test attemps to verify that:
-// - SharedWorkers can be created and successfully spawned by web extensions
-//   when web-extensions run in their own child process.
 // - SharedWorkers cannot be created by web extensions when web extensions
 //   are being run in the main process (because SharedWorkers are only
 //   allowed to be spawned in the parent process if they have a system principal).
 add_task(async function test_spawn_shared_worker() {
-  const background = WebExtensionPolicy.useRemoteWebExtensions
-    ? async function() {
-        const worker = new SharedWorker("worker.js");
-        await new Promise(resolve => {
-          worker.port.onmessage = resolve;
-          worker.port.postMessage("bgpage->worker");
-        });
-        browser.test.sendMessage("test-shared-worker:done");
-      }
-    : function() {
-        // This test covers the builds where the extensions are still
-        // running in the main process (it just checks that we don't
-        // allow it).
-        browser.test.assertThrows(
-          () => {
-            try {
-              new SharedWorker("worker.js");
-            } catch (e) {
-              // assertThrows is currently failing to match the error message
-              // automatically, let's cheat a little bit for now.
-              throw new Error(`${e}`);
-            }
-          },
-          /NS_ERROR_ABORT/,
-          "Got the expected failure in non-remote mode"
-        );
+  const background = function() {
+    // This test covers the builds where the extensions are still
+    // running in the main process (it just checks that we don't
+    // allow it).
+    browser.test.assertThrows(
+      () => {
+        try {
+          new SharedWorker("worker.js");
+        } catch (e) {
+          // assertThrows is currently failing to match the error message
+          // automatically, let's cheat a little bit for now.
+          throw new Error(`${e}`);
+        }
+      },
+      /NS_ERROR_ABORT/,
+      "Got the expected failure in non-remote mode"
+    );
 
-        browser.test.sendMessage("test-shared-worker:done");
-      };
+    browser.test.sendMessage("test-shared-worker:done");
+  };
   const extension = ExtensionTestUtils.loadExtension({
     background,
     files: {
       "worker.js": function() {
         self.onconnect = evt => {
           const port = evt.ports[0];
           port.onmessage = () => port.postMessage("worker-reply");
         };
--- a/toolkit/components/extensions/test/xpcshell/xpcshell-common.ini
+++ b/toolkit/components/extensions/test/xpcshell/xpcshell-common.ini
@@ -129,17 +129,16 @@ skip-if = ccov && os == 'linux' # bug 16
 [test_ext_runtime_onInstalled_and_onStartup.js]
 [test_ext_runtime_ports.js]
 [test_ext_runtime_sendMessage.js]
 [test_ext_runtime_sendMessage_errors.js]
 [test_ext_runtime_sendMessage_no_receiver.js]
 [test_ext_same_site_cookies.js]
 [test_ext_sandbox_var.js]
 [test_ext_schema.js]
-[test_ext_shared_workers.js]
 [test_ext_shutdown_cleanup.js]
 [test_ext_simple.js]
 [test_ext_startupData.js]
 [test_ext_startup_cache.js]
 skip-if = os == "android"
 [test_ext_startup_perf.js]
 [test_ext_startup_request_handler.js]
 [test_ext_storage_local.js]
--- a/toolkit/components/extensions/test/xpcshell/xpcshell-remote.ini
+++ b/toolkit/components/extensions/test/xpcshell/xpcshell-remote.ini
@@ -22,8 +22,9 @@ prefs =
 [include:xpcshell-content.ini]
 
 [test_ext_contentscript_perf_observers.js]
 skip-if = tsan
 # Inexplicably, PerformanceObserver used in the test doesn't fire in non-e10s mode.
 [test_WebExtensionContentScript.js]
 [test_ext_ipcBlob.js]
 skip-if = os == 'android' && processor == 'x86_64'
+[test_ext_shared_workers.js]
--- a/toolkit/components/extensions/test/xpcshell/xpcshell.ini
+++ b/toolkit/components/extensions/test/xpcshell/xpcshell.ini
@@ -66,16 +66,17 @@ skip-if = os == 'android' && processor =
 [test_ext_schemas_privileged.js]
 skip-if = os == 'android' && processor == 'x86_64'
 [test_ext_schemas_revoke.js]
 [test_ext_test_mock.js]
 skip-if = os == 'android' && processor == 'x86_64'
 [test_ext_test_wrapper.js]
 [test_ext_unknown_permissions.js]
 skip-if = os == 'android' && processor == 'x86_64'
+[test_ext_shared_workers_mainprocess_disallowed.js]
 [test_ext_webRequest_urlclassification.js]
 [test_extension_permissions_migration.js]
 [test_load_all_api_modules.js]
 [test_locale_converter.js]
 [test_locale_data.js]
 skip-if = os == 'android' && processor == 'x86_64'
 
 [test_ext_runtime_sendMessage_args.js]