From 69f98d5c5855845f25b6b5961dae5de63da7c2c3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Emilio=20Cobos=20=C3=81lvarez?= Date: Sat, 18 Aug 2018 21:32:38 +0000 Subject: [PATCH] Bug 1484474 - Make the ua widget flag in ShadowRoot write-only. r=smaug Letting people set it back to false would be bad. Differential Revision: https://phabricator.services.mozilla.com/D3714 --HG-- extra : moz-landing-system : lando --- dom/base/ShadowRoot.cpp | 7 ------- dom/base/ShadowRoot.h | 5 ++++- dom/html/HTMLMediaElement.cpp | 2 +- dom/webidl/ShadowRoot.webidl | 2 +- toolkit/content/tests/widgets/test_ua_widget.html | 2 +- 5 files changed, 7 insertions(+), 11 deletions(-) diff --git a/dom/base/ShadowRoot.cpp b/dom/base/ShadowRoot.cpp index c903af48f0a2..b8bcb5a904d0 100644 --- a/dom/base/ShadowRoot.cpp +++ b/dom/base/ShadowRoot.cpp @@ -120,12 +120,6 @@ ShadowRoot::SetIsComposedDocParticipant(bool aIsComposedDocParticipant) } } -void -ShadowRoot::SetIsUAWidget(bool aIsUAWidget) -{ - mIsUAWidget = aIsUAWidget; -} - JSObject* ShadowRoot::WrapObject(JSContext* aCx, JS::Handle aGivenProto) { @@ -563,7 +557,6 @@ ShadowRoot::ImportNodeAndAppendChildAt(nsINode& aParentNode, mozilla::ErrorResult& rv) { MOZ_ASSERT(mIsUAWidget); - MOZ_ASSERT(OwnerDoc()); if (!aParentNode.IsInUAWidget()) { rv.Throw(NS_ERROR_INVALID_ARG); diff --git a/dom/base/ShadowRoot.h b/dom/base/ShadowRoot.h index 34443888a780..60d9270003b1 100644 --- a/dom/base/ShadowRoot.h +++ b/dom/base/ShadowRoot.h @@ -197,7 +197,10 @@ public: return mIsUAWidget; } - void SetIsUAWidget(bool aIsUAWidget); + void SetIsUAWidget() + { + mIsUAWidget = true; + } void GetEventTargetParent(EventChainPreVisitor& aVisitor) override; diff --git a/dom/html/HTMLMediaElement.cpp b/dom/html/HTMLMediaElement.cpp index 7978979a912e..7d4ab81310a6 100644 --- a/dom/html/HTMLMediaElement.cpp +++ b/dom/html/HTMLMediaElement.cpp @@ -4950,7 +4950,7 @@ HTMLMediaElement::AttachAndSetUAShadowRoot() // Add a closed shadow root to host video controls RefPtr shadowRoot = AttachShadowWithoutNameChecks(ShadowRootMode::Closed); - shadowRoot->SetIsUAWidget(true); + shadowRoot->SetIsUAWidget(); } nsresult diff --git a/dom/webidl/ShadowRoot.webidl b/dom/webidl/ShadowRoot.webidl index f4d38a899031..fe3e93341cbd 100644 --- a/dom/webidl/ShadowRoot.webidl +++ b/dom/webidl/ShadowRoot.webidl @@ -47,7 +47,7 @@ interface ShadowRoot : DocumentFragment // For triggering UA Widget scope in tests. [ChromeOnly] - void setIsUAWidget(boolean isUAWidget); + void setIsUAWidget(); }; ShadowRoot implements DocumentOrShadowRoot; diff --git a/toolkit/content/tests/widgets/test_ua_widget.html b/toolkit/content/tests/widgets/test_ua_widget.html index 4ee4277a2261..286238b2940a 100644 --- a/toolkit/content/tests/widgets/test_ua_widget.html +++ b/toolkit/content/tests/widgets/test_ua_widget.html @@ -21,7 +21,7 @@ const content = document.getElementById("content"); const div = content.appendChild(document.createElement("div")); div.attachShadow({ mode: "open"}); -SpecialPowers.wrap(div.shadowRoot).setIsUAWidget(true); +SpecialPowers.wrap(div.shadowRoot).setIsUAWidget(); const sandbox = SpecialPowers.Cu.getUAWidgetScope(SpecialPowers.wrap(div).nodePrincipal);