Bug 1465592 - Enable Shadow DOM unconditionally in chrome documents draft
authorBrian Grinstead <bgrinstead@mozilla.com>
Thu, 31 May 2018 10:49:06 -0700
changeset 802316 07f8190d759f2ffa97272fe5dea2d5a1e9c414d3
parent 798084 b75acf9652937ce79a9bf02de843c100db0e5ec7
push id111860
push userbgrinstead@mozilla.com
push dateThu, 31 May 2018 17:54:30 +0000
bugs1465592
milestone62.0a1
Bug 1465592 - Enable Shadow DOM unconditionally in chrome documents MozReview-Commit-ID: FEfW3D5wgnc
dom/base/Element.cpp
dom/base/nsDocument.cpp
--- a/dom/base/Element.cpp
+++ b/dom/base/Element.cpp
@@ -1174,17 +1174,18 @@ Element::GetShadowRootByMode() const
 // https://dom.spec.whatwg.org/#dom-element-attachshadow
 already_AddRefed<ShadowRoot>
 Element::AttachShadow(const ShadowRootInit& aInit, ErrorResult& aError)
 {
   /**
    * 1. If context object’s namespace is not the HTML namespace,
    *    then throw a "NotSupportedError" DOMException.
    */
-  if (!IsHTMLElement()) {
+  if (!IsHTMLElement() &&
+      !(XRE_IsParentProcess() && nsContentUtils::AllowXULXBLForPrincipal(NodePrincipal()))) {
     aError.Throw(NS_ERROR_DOM_NOT_SUPPORTED_ERR);
     return nullptr;
   }
 
   /**
    * 2. If context object’s local name is not
    *      a valid custom element name, "article", "aside", "blockquote",
    *      "body", "div", "footer", "h1", "h2", "h3", "h4", "h5", "h6",
--- a/dom/base/nsDocument.cpp
+++ b/dom/base/nsDocument.cpp
@@ -2114,17 +2114,18 @@ nsDocument::Init()
   NS_ENSURE_TRUE(mNodeInfo, NS_ERROR_OUT_OF_MEMORY);
   MOZ_ASSERT(mNodeInfo->NodeType() == DOCUMENT_NODE,
              "Bad NodeType in aNodeInfo");
 
   NS_ASSERTION(OwnerDoc() == this, "Our nodeinfo is busted!");
 
   // Set this when document is initialized and value stays the same for the
   // lifetime of the document.
-  mIsShadowDOMEnabled = nsContentUtils::IsShadowDOMEnabled();
+  mIsShadowDOMEnabled = nsContentUtils::IsShadowDOMEnabled() ||
+    (XRE_IsParentProcess() && AllowXULXBL());
 
   // If after creation the owner js global is not set for a document
   // we use the default compartment for this document, instead of creating
   // wrapper in some random compartment when the document is exposed to js
   // via some events.
   nsCOMPtr<nsIGlobalObject> global = xpc::NativeGlobal(xpc::PrivilegedJunkScope());
   NS_ENSURE_TRUE(global, NS_ERROR_FAILURE);
   mScopeObject = do_GetWeakReference(global);