Bug 1393150 prevent remote extensions when e10s is off, r=bz,kmag

MozReview-Commit-ID: HjLLa9vx2UW
This commit is contained in:
Shane Caraveo
2017-09-14 15:12:45 -07:00
parent c87558dd5f
commit 5592e73c3a
8 changed files with 31 additions and 9 deletions

View File

@@ -11,8 +11,6 @@ const {interfaces: Ci, utils: Cu, classes: Cc} = Components;
Cu.import("resource://gre/modules/Services.jsm");
Cu.import("resource://gre/modules/XPCOMUtils.jsm");
XPCOMUtils.defineLazyPreferenceGetter(this, "useRemoteWebExtensions",
"extensions.webextensions.remote", false);
XPCOMUtils.defineLazyPreferenceGetter(this, "useSeparateFileUriProcess",
"browser.tabs.remote.separateFileUriProcess", false);
XPCOMUtils.defineLazyPreferenceGetter(this, "allowLinkedWebInFileUriProcess",
@@ -185,7 +183,7 @@ this.E10SUtils = {
return NOT_REMOTE;
case "moz-extension":
return useRemoteWebExtensions ? EXTENSION_REMOTE_TYPE : NOT_REMOTE;
return WebExtensionPolicy.useRemoteWebExtensions ? EXTENSION_REMOTE_TYPE : NOT_REMOTE;
default:
// For any other nested URIs, we use the innerURI to determine the

View File

@@ -103,6 +103,8 @@ support-files =
[test_unsafeDereference.html]
[test_webconsole-node-grip.html]
[test_webextension-addon-debugging-connect.html]
skip-if = !e10s # test is designed to work on e10s only
[test_webextension-addon-debugging-reload.html]
skip-if = !e10s # test is designed to work on e10s only
[test_websocket-server.html]
skip-if = false

View File

@@ -82,10 +82,18 @@ interface WebExtensionPolicy {
[Affects=Everything, SetterThrows]
attribute boolean active;
/**
* True if both e10s and webextensions.remote are enabled. This must be
* used instead of checking the remote pref directly since remote extensions
* require both to be enabled.
*/
static readonly attribute boolean useRemoteWebExtensions;
/**
* True if the calling process is an extension process.
*/
static readonly attribute boolean isExtensionProcess;
/**
* Returns true if the extension has cross-origin access to the given URI.
*/

View File

@@ -82,8 +82,6 @@ XPCOMUtils.defineLazyServiceGetters(this, {
});
XPCOMUtils.defineLazyPreferenceGetter(this, "processCount", "dom.ipc.processCount.extension");
XPCOMUtils.defineLazyPreferenceGetter(this, "useRemoteWebExtensions",
"extensions.webextensions.remote", false);
var {
GlobalManager,
@@ -1026,7 +1024,7 @@ this.Extension = class extends ExtensionData {
StartupCache.clearAddonData(addonData.id);
}
this.remote = useRemoteWebExtensions;
this.remote = !WebExtensionPolicy.isExtensionProcess;
if (this.remote && processCount !== 1) {
throw new Error("Out-of-process WebExtensions are not supported with multiple child processes");

View File

@@ -20,6 +20,7 @@
#include "nsIDOMDocument.h"
#include "nsIDocument.h"
#include "nsILoadInfo.h"
#include "nsIXULRuntime.h"
#include "nsNetUtil.h"
#include "nsPIDOMWindow.h"
#include "nsXULAppAPI.h"
@@ -81,15 +82,22 @@ ExtensionPolicyService::ExtensionPolicyService()
RegisterObservers();
}
bool
ExtensionPolicyService::UseRemoteExtensions() const
{
return sRemoteExtensions && BrowserTabsRemoteAutostart();
}
bool
ExtensionPolicyService::IsExtensionProcess() const
{
if (sRemoteExtensions && XRE_IsContentProcess()) {
bool isRemote = UseRemoteExtensions();
if (isRemote && XRE_IsContentProcess()) {
auto& remoteType = dom::ContentChild::GetSingleton()->GetRemoteType();
return remoteType.EqualsLiteral(EXTENSION_REMOTE_TYPE);
}
return XRE_IsParentProcess();
return !isRemote && XRE_IsParentProcess();
}

View File

@@ -75,6 +75,7 @@ public:
void BaseCSP(nsAString& aDefaultCSP) const;
void DefaultCSP(nsAString& aDefaultCSP) const;
bool UseRemoteExtensions() const;
bool IsExtensionProcess() const;
protected:

View File

@@ -212,6 +212,12 @@ WebExtensionPolicy::GetURL(const nsAString& aPath) const
return NS_ConvertUTF8toUTF16(spec);
}
/* static */ bool
WebExtensionPolicy::UseRemoteWebExtensions(GlobalObject& aGlobal)
{
return EPS().UseRemoteExtensions();
}
/* static */ bool
WebExtensionPolicy::IsExtensionProcess(GlobalObject& aGlobal)
{

View File

@@ -140,6 +140,7 @@ public:
GetByURI(dom::GlobalObject& aGlobal, nsIURI* aURI);
static bool UseRemoteWebExtensions(dom::GlobalObject& aGlobal);
static bool IsExtensionProcess(dom::GlobalObject& aGlobal);