Bug 1465592 - Enable Shadow DOM unconditionally in chrome documents;r=smaug

Differential Revision: https://phabricator.services.mozilla.com/D6278

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Brian Grinstead 2018-09-20 18:18:32 +00:00
Родитель d42f66fd2b
Коммит 6f15c7154f
3 изменённых файлов: 7 добавлений и 2 удалений

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

@ -1182,7 +1182,8 @@ Element::AttachShadow(const ShadowRootInit& aInit, ErrorResult& aError)
* 1. If context objects namespace is not the HTML namespace,
* then throw a "NotSupportedError" DOMException.
*/
if (!IsHTMLElement()) {
if (!IsHTMLElement() &&
!(XRE_IsParentProcess() && IsXULElement() && nsContentUtils::AllowXULXBLForPrincipal(NodePrincipal()))) {
aError.Throw(NS_ERROR_DOM_NOT_SUPPORTED_ERR);
return nullptr;
}

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

@ -2163,7 +2163,8 @@ nsDocument::Init()
// 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

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

@ -31,6 +31,8 @@
class TestCustomElement extends XULElement {
constructor() {
super();
this.attachShadow({mode: "open"});
}
connectedCallback() {
@ -87,6 +89,7 @@
function basicCustomElementCreate() {
let element = document.createElementNS(XUL_NS, "test-custom-element");
ok(element.shadowRoot, "Shadow DOM works even with pref off");
document.querySelector("#content").appendChild(element);
is(element.textContent, "foo", "Should have set the textContent");
ok(element instanceof TestCustomElement, "Should be an instance of TestCustomElement");