Bug 1373677 - Remove support for the moz-extremely-unstable-and-will-change-webcomponents permission; r=wchen

This commit is contained in:
Ehsan Akhgari 2017-06-17 12:39:04 -04:00
Родитель 84176294e0
Коммит b306e0842e
2 изменённых файлов: 6 добавлений и 44 удалений

Просмотреть файл

@ -6049,6 +6049,10 @@ nsDocument::CustomElementConstructor(JSContext* aCx, unsigned aArgc, JS::Value*
bool
nsDocument::IsWebComponentsEnabled(JSContext* aCx, JSObject* aObject)
{
if (!nsContentUtils::IsWebComponentsEnabled()) {
return false;
}
JS::Rooted<JSObject*> obj(aCx, aObject);
JSAutoCompartment ac(aCx, obj);
@ -6056,15 +6060,6 @@ nsDocument::IsWebComponentsEnabled(JSContext* aCx, JSObject* aObject)
nsCOMPtr<nsPIDOMWindowInner> window =
do_QueryInterface(nsJSUtils::GetStaticScriptGlobal(global));
bool enabled =
nsContentUtils::IsWebComponentsEnabled() ||
// Check for the webcomponents permission. See Bug 1181555.
IsWebComponentsEnabled(window);
if (!enabled) {
return false;
}
nsIDocument* doc = window ? window->GetExtantDoc() : nullptr;
if (doc && doc->IsStyledByServo()) {
NS_WARNING("stylo: Web Components not supported yet");
@ -6077,21 +6072,11 @@ nsDocument::IsWebComponentsEnabled(JSContext* aCx, JSObject* aObject)
bool
nsDocument::IsWebComponentsEnabled(dom::NodeInfo* aNodeInfo)
{
nsIDocument* doc = aNodeInfo->GetDocument();
bool enabled = nsContentUtils::IsWebComponentsEnabled();
if (!enabled) {
// Use GetScopeObject() here so that data documents work the same way as the
// main document they're associated with.
nsCOMPtr<nsPIDOMWindowInner> window =
do_QueryInterface(doc->GetScopeObject());
enabled = IsWebComponentsEnabled(window);
}
if (!enabled) {
if (!nsContentUtils::IsWebComponentsEnabled()) {
return false;
}
nsIDocument* doc = aNodeInfo->GetDocument();
if (doc->IsStyledByServo()) {
NS_WARNING("stylo: Web Components not supported yet");
return false;
@ -6100,26 +6085,6 @@ nsDocument::IsWebComponentsEnabled(dom::NodeInfo* aNodeInfo)
return true;
}
bool
nsDocument::IsWebComponentsEnabled(nsPIDOMWindowInner* aWindow)
{
if (aWindow) {
nsresult rv;
nsCOMPtr<nsIPermissionManager> permMgr =
do_GetService(NS_PERMISSIONMANAGER_CONTRACTID, &rv);
NS_ENSURE_SUCCESS(rv, false);
uint32_t perm;
rv = permMgr->TestPermissionFromWindow(
aWindow, "moz-extremely-unstable-and-will-change-webcomponents", &perm);
NS_ENSURE_SUCCESS(rv, false);
return perm == nsIPermissionManager::ALLOW_ACTION;
}
return false;
}
void
nsDocument::ScheduleSVGForPresAttrEvaluation(nsSVGElement* aSVG)
{

Просмотреть файл

@ -1395,9 +1395,6 @@ private:
void UpdatePossiblyStaleDocumentState();
static bool CustomElementConstructor(JSContext* aCx, unsigned aArgc, JS::Value* aVp);
// Check whether web components are enabled for the given window.
static bool IsWebComponentsEnabled(nsPIDOMWindowInner* aWindow);
public:
virtual already_AddRefed<mozilla::dom::CustomElementRegistry>
GetCustomElementRegistry() override;