Bug 1400391 - Fix e10s xpcshell-test for remote webextensions. r=kmag, a=lizzard
authorShane Caraveo <scaraveo@mozilla.com>
Sun, 17 Sep 2017 19:34:13 -0700
changeset 666741 e75d21e51a000fee4b49143f2e5860331c49012d
parent 666740 24caabac22e93d0fda6c3ea456ade71b79ebfac0
child 666742 f5d255813d92d9818d483e631e4901d3315ee900
push id80488
push userbmo:mkelly@mozilla.com
push dateTue, 19 Sep 2017 04:42:30 +0000
reviewerskmag, lizzard
bugs1400391
milestone56.0
Bug 1400391 - Fix e10s xpcshell-test for remote webextensions. r=kmag, a=lizzard 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
--- 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.defineLazyModuleGetter(this, "ContentTask",
@@ -22,17 +22,27 @@ XPCOMUtils.defineLazyModuleGetter(this, 
                                   "resource://gre/modules/FileUtils.jsm");
 XPCOMUtils.defineLazyModuleGetter(this, "HttpServer",
                                   "resource://testing-common/httpd.js");
 XPCOMUtils.defineLazyModuleGetter(this, "NetUtil",
                                   "resource://gre/modules/NetUtil.jsm");
 XPCOMUtils.defineLazyModuleGetter(this, "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