Bug 1400391 fix e10s xpcshell-test for remote webextensions, r?kmag draft
authorShane Caraveo <scaraveo@mozilla.com>
Sun, 17 Sep 2017 19:34:13 -0700
changeset 666139 5278f7729c916c2ac716c00555ed4c7d7716c9d3
parent 665648 6be5c7d30d2def62a762ac187252eba626b23a92
child 731986 b2c73c54adaf97c4d331909ef8675b6cc46ab4e8
push id80285
push usermixedpuppy@gmail.com
push dateMon, 18 Sep 2017 02:34:35 +0000
reviewerskmag
bugs1400391
milestone57.0a1
Bug 1400391 fix e10s xpcshell-test for remote webextensions, r?kmag MozReview-Commit-ID: AgdmUNWLGaq
toolkit/components/extensions/test/xpcshell/head.js
toolkit/components/extensions/test/xpcshell/head_e10s.js
toolkit/components/extensions/test/xpcshell/head_remote.js
toolkit/components/extensions/test/xpcshell/test_ext_proxy_auth.js
--- a/toolkit/components/extensions/test/xpcshell/head.js
+++ b/toolkit/components/extensions/test/xpcshell/head.js
@@ -1,13 +1,13 @@
 "use strict";
 
 const {classes: Cc, interfaces: Ci, utils: Cu, results: Cr} = Components;
 
-/* exported createHttpServer, promiseConsoleOutput, cleanupDir */
+/* exported createHttpServer, promiseConsoleOutput, cleanupDir, testEnv */
 
 Components.utils.import("resource://gre/modules/AppConstants.jsm");
 Components.utils.import("resource://gre/modules/Services.jsm");
 Components.utils.import("resource://gre/modules/XPCOMUtils.jsm");
 Components.utils.import("resource://gre/modules/Timer.jsm");
 Components.utils.import("resource://testing-common/AddonTestUtils.jsm");
 
 XPCOMUtils.defineLazyModuleGetters(this, {
@@ -17,17 +17,27 @@ XPCOMUtils.defineLazyModuleGetters(this,
   ExtensionParent: "resource://gre/modules/ExtensionParent.jsm",
   ExtensionTestUtils: "resource://testing-common/ExtensionXPCShellUtils.jsm",
   FileUtils: "resource://gre/modules/FileUtils.jsm",
   HttpServer: "resource://testing-common/httpd.js",
   NetUtil: "resource://gre/modules/NetUtil.jsm",
   Schemas: "resource://gre/modules/Schemas.jsm",
 });
 
+// These values may be changed in later head files and tested in check_remote
+// below.
 Services.prefs.setBoolPref("extensions.webextensions.remote", false);
+const testEnv = {
+  expectRemote: false,
+};
+
+add_task(function check_remote() {
+  Assert.equal(WebExtensionPolicy.useRemoteWebExtensions, testEnv.expectRemote, "useRemoteWebExtensions matches");
+  Assert.equal(WebExtensionPolicy.isExtensionProcess, !testEnv.expectRemote, "testing from extension process");
+});
 
 ExtensionTestUtils.init(this);
 
 /**
  * Creates a new HttpServer for testing, and begins listening on the
  * specified port. Automatically shuts down the server when the test
  * unit ends.
  *
--- a/toolkit/components/extensions/test/xpcshell/head_e10s.js
+++ b/toolkit/components/extensions/test/xpcshell/head_e10s.js
@@ -1,5 +1,10 @@
 "use strict";
 
 /* globals ExtensionTestUtils */
 
+// We want to force enable e10s so we can test remote extensions
+Services.prefs.setBoolPref("browser.tabs.remote.force-enable", true);
+// This causes nsIXULRuntime.browserTabsRemoteAutostart to reset and force e10s
+Services.prefs.setStringPref("e10s.rollout.cohort", "xpcshell-test");
+
 ExtensionTestUtils.remoteContentScripts = true;
--- a/toolkit/components/extensions/test/xpcshell/head_remote.js
+++ b/toolkit/components/extensions/test/xpcshell/head_remote.js
@@ -1,4 +1,7 @@
 "use strict";
 
 Services.prefs.setBoolPref("extensions.webextensions.remote", true);
 Services.prefs.setIntPref("dom.ipc.keepProcessesAlive.extension", 1);
+
+/* globals testEnv */
+testEnv.expectRemote = true; // tested in head_test.js
--- a/toolkit/components/extensions/test/xpcshell/test_ext_proxy_auth.js
+++ b/toolkit/components/extensions/test/xpcshell/test_ext_proxy_auth.js
@@ -69,9 +69,9 @@ add_task(async function test_webRequest_
   await handlingExt.startup();
   await handlingExt.awaitMessage("pac-ready");
 
   let contentPage = await ExtensionTestUtils.loadContentPage(`http://mozilla.org/`);
 
   await handlingExt.awaitMessage("done");
   await contentPage.close();
   await handlingExt.unload();
-}).only();
+});