Attachment #8878798: Remove support for the moz-extremely-unstable-and-will-change-webcomponents permission for bug #1373677

View | Details | Raw Unified | Return to bug 1373677
Collapse All | Expand All

(-)a/dom/base/nsDocument.cpp (-42 lines)
Line     Link Here 
 Lines 6051-6130   nsDocument::IsWebComponentsEnabled(JSContext* aCx, JSObject* aObject) Link Here 
6051
{
6051
{
6052
  JS::Rooted<JSObject*> obj(aCx, aObject);
6052
  JS::Rooted<JSObject*> obj(aCx, aObject);
6053
6053
6054
  JSAutoCompartment ac(aCx, obj);
6054
  JSAutoCompartment ac(aCx, obj);
6055
  JS::Rooted<JSObject*> global(aCx, JS_GetGlobalForObject(aCx, obj));
6055
  JS::Rooted<JSObject*> global(aCx, JS_GetGlobalForObject(aCx, obj));
6056
  nsCOMPtr<nsPIDOMWindowInner> window =
6056
  nsCOMPtr<nsPIDOMWindowInner> window =
6057
    do_QueryInterface(nsJSUtils::GetStaticScriptGlobal(global));
6057
    do_QueryInterface(nsJSUtils::GetStaticScriptGlobal(global));
6058
6058
6059
  bool enabled =
6060
    nsContentUtils::IsWebComponentsEnabled() ||
6061
    // Check for the webcomponents permission. See Bug 1181555.
6062
    IsWebComponentsEnabled(window);
6063
6064
  if (!enabled) {
6065
    return false;
6066
  }
6067
6068
  nsIDocument* doc = window ? window->GetExtantDoc() : nullptr;
6059
  nsIDocument* doc = window ? window->GetExtantDoc() : nullptr;
6069
  if (doc && doc->IsStyledByServo()) {
6060
  if (doc && doc->IsStyledByServo()) {
6070
    NS_WARNING("stylo: Web Components not supported yet");
6061
    NS_WARNING("stylo: Web Components not supported yet");
6071
    return false;
6062
    return false;
6072
  }
6063
  }
6073
6064
6074
  return true;
6065
  return true;
6075
}
6066
}
6076
6067
6077
bool
6068
bool
6078
nsDocument::IsWebComponentsEnabled(dom::NodeInfo* aNodeInfo)
6069
nsDocument::IsWebComponentsEnabled(dom::NodeInfo* aNodeInfo)
6079
{
6070
{
6080
  nsIDocument* doc = aNodeInfo->GetDocument();
6071
  nsIDocument* doc = aNodeInfo->GetDocument();
6081
6072
6082
  bool enabled = nsContentUtils::IsWebComponentsEnabled();
6083
  if (!enabled) {
6084
    // Use GetScopeObject() here so that data documents work the same way as the
6085
    // main document they're associated with.
6086
    nsCOMPtr<nsPIDOMWindowInner> window =
6087
      do_QueryInterface(doc->GetScopeObject());
6088
    enabled = IsWebComponentsEnabled(window);
6089
  }
6090
6091
  if (!enabled) {
6092
    return false;
6093
  }
6094
6095
  if (doc->IsStyledByServo()) {
6073
  if (doc->IsStyledByServo()) {
6096
    NS_WARNING("stylo: Web Components not supported yet");
6074
    NS_WARNING("stylo: Web Components not supported yet");
6097
    return false;
6075
    return false;
6098
  }
6076
  }
6099
6077
6100
  return true;
6078
  return true;
6101
}
6079
}
6102
6080
6103
bool
6104
nsDocument::IsWebComponentsEnabled(nsPIDOMWindowInner* aWindow)
6105
{
6106
  if (aWindow) {
6107
    nsresult rv;
6108
    nsCOMPtr<nsIPermissionManager> permMgr =
6109
      do_GetService(NS_PERMISSIONMANAGER_CONTRACTID, &rv);
6110
    NS_ENSURE_SUCCESS(rv, false);
6111
6112
    uint32_t perm;
6113
    rv = permMgr->TestPermissionFromWindow(
6114
      aWindow, "moz-extremely-unstable-and-will-change-webcomponents", &perm);
6115
    NS_ENSURE_SUCCESS(rv, false);
6116
6117
    return perm == nsIPermissionManager::ALLOW_ACTION;
6118
  }
6119
6120
  return false;
6121
}
6122
6123
void
6081
void
6124
nsDocument::ScheduleSVGForPresAttrEvaluation(nsSVGElement* aSVG)
6082
nsDocument::ScheduleSVGForPresAttrEvaluation(nsSVGElement* aSVG)
6125
{
6083
{
6126
  mLazySVGPresElements.PutEntry(aSVG);
6084
  mLazySVGPresElements.PutEntry(aSVG);
6127
}
6085
}
6128
6086
6129
void
6087
void
6130
nsDocument::UnscheduleSVGForPresAttrEvaluation(nsSVGElement* aSVG)
6088
nsDocument::UnscheduleSVGForPresAttrEvaluation(nsSVGElement* aSVG)
(-)a/dom/base/nsDocument.h (-3 lines)
Line     Link Here 
 Lines 1390-1408   protected: Link Here 
1390
  mozilla::dom::FlashClassification mFlashClassification;
1390
  mozilla::dom::FlashClassification mFlashClassification;
1391
  // Do not use this value directly. Call the |IsThirdParty()| method, which
1391
  // Do not use this value directly. Call the |IsThirdParty()| method, which
1392
  // caches its result here.
1392
  // caches its result here.
1393
  mozilla::Maybe<bool> mIsThirdParty;
1393
  mozilla::Maybe<bool> mIsThirdParty;
1394
private:
1394
private:
1395
  void UpdatePossiblyStaleDocumentState();
1395
  void UpdatePossiblyStaleDocumentState();
1396
  static bool CustomElementConstructor(JSContext* aCx, unsigned aArgc, JS::Value* aVp);
1396
  static bool CustomElementConstructor(JSContext* aCx, unsigned aArgc, JS::Value* aVp);
1397
1397
1398
  // Check whether web components are enabled for the given window.
1399
  static bool IsWebComponentsEnabled(nsPIDOMWindowInner* aWindow);
1400
1401
public:
1398
public:
1402
  virtual already_AddRefed<mozilla::dom::CustomElementRegistry>
1399
  virtual already_AddRefed<mozilla::dom::CustomElementRegistry>
1403
    GetCustomElementRegistry() override;
1400
    GetCustomElementRegistry() override;
1404
1401
1405
  // Check whether web components are enabled for the global of aObject.
1402
  // Check whether web components are enabled for the global of aObject.
1406
  static bool IsWebComponentsEnabled(JSContext* aCx, JSObject* aObject);
1403
  static bool IsWebComponentsEnabled(JSContext* aCx, JSObject* aObject);
1407
  // Check whether web components are enabled for the global of the document
1404
  // Check whether web components are enabled for the global of the document
1408
  // this nodeinfo comes from.
1405
  // this nodeinfo comes from.

Return to bug 1373677