Bug 1329731 - Add moz-extension to the principals immune to script policy.
MozReview-Commit-ID: FAn2Cq5Lz5O
--- a/js/xpconnect/src/XPCJSContext.cpp
+++ b/js/xpconnect/src/XPCJSContext.cpp
@@ -342,16 +342,25 @@ PrincipalImmuneToScriptPolicy(nsIPrincip
if (ep)
return true;
// Check whether our URI is an "about:" URI that allows scripts. If it is,
// we need to allow JS to run.
nsCOMPtr<nsIURI> principalURI;
aPrincipal->GetURI(getter_AddRefs(principalURI));
MOZ_ASSERT(principalURI);
+
+ // WebExtension principals gets a free pass.
+ nsString addonId;
+ aPrincipal->GetAddonId(addonId);
+ bool isWebExtension = !addonId.IsEmpty();
+ if (isWebExtension) {
+ return true;
+ }
+
bool isAbout;
nsresult rv = principalURI->SchemeIs("about", &isAbout);
if (NS_SUCCEEDED(rv) && isAbout) {
nsCOMPtr<nsIAboutModule> module;
rv = NS_GetAboutModule(principalURI, getter_AddRefs(module));
if (NS_SUCCEEDED(rv)) {
uint32_t flags;
rv = module->GetURIFlags(principalURI, &flags);