Bug 1181555 - Add 'experimental-webcomponents' permission. r=fabrice

This commit is contained in:
Chris Lord 2015-08-20 12:07:54 +01:00
parent ed7ba5dc7c
commit 20ccf3a80a
2 changed files with 33 additions and 2 deletions

View File

@ -579,6 +579,12 @@ this.PermissionsTable = { geolocation: {
privileged: DENY_ACTION,
certified: ALLOW_ACTION
},
"moz-extremely-unstable-and-will-change-webcomponents": {
app: DENY_ACTION,
trusted: DENY_ACTION,
privileged: ALLOW_ACTION,
certified: ALLOW_ACTION
}
};
/**

View File

@ -92,6 +92,7 @@
#include "nsIAuthPrompt2.h"
#include "nsIScriptSecurityManager.h"
#include "nsIPermissionManager.h"
#include "nsIPrincipal.h"
#include "nsIDOMWindow.h"
@ -5832,8 +5833,32 @@ bool
nsDocument::IsWebComponentsEnabled(JSContext* aCx, JSObject* aObject)
{
JS::Rooted<JSObject*> obj(aCx, aObject);
return Preferences::GetBool("dom.webcomponents.enabled") ||
IsInCertifiedApp(aCx, obj);
if (Preferences::GetBool("dom.webcomponents.enabled")) {
return true;
}
// Check for the webcomponents permission. See Bug 1181555.
JSAutoCompartment ac(aCx, obj);
JS::Rooted<JSObject*> global(aCx, JS_GetGlobalForObject(aCx, obj));
nsCOMPtr<nsPIDOMWindow> window =
do_QueryInterface(nsJSUtils::GetStaticScriptGlobal(global));
if (window) {
nsresult rv;
nsCOMPtr<nsIPermissionManager> permMgr =
do_GetService(NS_PERMISSIONMANAGER_CONTRACTID, &rv);
NS_ENSURE_SUCCESS(rv, false);
uint32_t perm;
rv = permMgr->TestPermissionFromWindow(
window, "moz-extremely-unstable-and-will-change-webcomponents", &perm);
NS_ENSURE_SUCCESS(rv, false);
return perm == nsIPermissionManager::ALLOW_ACTION;
}
return false;
}
nsresult