Bug 1484474 - Make the ua widget flag in ShadowRoot write-only. r=smaug
authorEmilio Cobos Álvarez <emilio@crisal.io>
Sat, 18 Aug 2018 21:32:38 +0000
changeset 432416 2d78ad30fa75b7334ef6ab7aa30ed01a7166ca85
parent 432415 8aa36c4082b2e3ef8aade2028b6ea6033e2c5db2
child 432417 39f61de4e7bb164f1ad812852b4f46bd18e3d96d
push id106731
push usershindli@mozilla.com
push dateMon, 20 Aug 2018 16:36:25 +0000
treeherdermozilla-inbound@14ef4dec6126 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssmaug
bugs1484474
milestone63.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
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
dom/base/ShadowRoot.cpp
dom/base/ShadowRoot.h
dom/html/HTMLMediaElement.cpp
dom/webidl/ShadowRoot.webidl
toolkit/content/tests/widgets/test_ua_widget.html
--- a/dom/base/ShadowRoot.cpp
+++ b/dom/base/ShadowRoot.cpp
@@ -115,22 +115,16 @@ ShadowRoot::SetIsComposedDocParticipant(
   nsIDocument* doc = OwnerDoc();
   if (IsComposedDocParticipant()) {
     doc->AddComposedDocShadowRoot(*this);
   } else {
     doc->RemoveComposedDocShadowRoot(*this);
   }
 }
 
-void
-ShadowRoot::SetIsUAWidget(bool aIsUAWidget)
-{
-  mIsUAWidget = aIsUAWidget;
-}
-
 JSObject*
 ShadowRoot::WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto)
 {
   return mozilla::dom::ShadowRoot_Binding::Wrap(aCx, this, aGivenProto);
 }
 
 void
 ShadowRoot::CloneInternalDataFrom(ShadowRoot* aOther)
@@ -558,17 +552,16 @@ ShadowRoot::SetInnerHTML(const nsAString
 
 nsINode*
 ShadowRoot::ImportNodeAndAppendChildAt(nsINode& aParentNode,
                                        nsINode& aNode,
                                        bool aDeep,
                                        mozilla::ErrorResult& rv)
 {
   MOZ_ASSERT(mIsUAWidget);
-  MOZ_ASSERT(OwnerDoc());
 
   if (!aParentNode.IsInUAWidget()) {
     rv.Throw(NS_ERROR_INVALID_ARG);
     return nullptr;
   }
 
   RefPtr<nsINode> node = OwnerDoc()->ImportNode(aNode, aDeep, rv);
   if (rv.Failed()) {
--- a/dom/base/ShadowRoot.h
+++ b/dom/base/ShadowRoot.h
@@ -192,17 +192,20 @@ public:
 
   void SetIsComposedDocParticipant(bool aIsComposedDocParticipant);
 
   bool IsUAWidget() const
   {
     return mIsUAWidget;
   }
 
-  void SetIsUAWidget(bool aIsUAWidget);
+  void SetIsUAWidget()
+  {
+    mIsUAWidget = true;
+  }
 
   void GetEventTargetParent(EventChainPreVisitor& aVisitor) override;
 
 protected:
   // FIXME(emilio): This will need to become more fine-grained.
   void ApplicableRulesChanged();
 
   virtual ~ShadowRoot();
--- a/dom/html/HTMLMediaElement.cpp
+++ b/dom/html/HTMLMediaElement.cpp
@@ -4945,17 +4945,17 @@ HTMLMediaElement::AttachAndSetUAShadowRo
   if (GetShadowRoot()) {
     MOZ_ASSERT(GetShadowRoot()->IsUAWidget());
     return;
   }
 
   // Add a closed shadow root to host video controls
   RefPtr<ShadowRoot> shadowRoot =
     AttachShadowWithoutNameChecks(ShadowRootMode::Closed);
-  shadowRoot->SetIsUAWidget(true);
+  shadowRoot->SetIsUAWidget();
 }
 
 nsresult
 HTMLMediaElement::InitializeDecoderAsClone(ChannelMediaDecoder* aOriginal)
 {
   NS_ASSERTION(mLoadingSrc, "mLoadingSrc must already be set");
   NS_ASSERTION(mDecoder == nullptr, "Shouldn't have a decoder");
   AssertReadyStateIsNothing();
--- a/dom/webidl/ShadowRoot.webidl
+++ b/dom/webidl/ShadowRoot.webidl
@@ -42,12 +42,12 @@ interface ShadowRoot : DocumentFragment
   [CEReactions, Throws, Func="IsChromeOrXBLOrUAWidget"]
   Node importNodeAndAppendChildAt(Node parentNode, Node node, optional boolean deep = false);
 
   [CEReactions, Throws, Func="IsChromeOrXBLOrUAWidget"]
   Node createElementAndAppendChildAt(Node parentNode, DOMString localName);
 
   // For triggering UA Widget scope in tests.
   [ChromeOnly]
-  void setIsUAWidget(boolean isUAWidget);
+  void setIsUAWidget();
 };
 
 ShadowRoot implements DocumentOrShadowRoot;
--- a/toolkit/content/tests/widgets/test_ua_widget.html
+++ b/toolkit/content/tests/widgets/test_ua_widget.html
@@ -16,17 +16,17 @@
 
 <pre id="test">
 <script class="testbody" type="text/javascript">
 
 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);
 
 SpecialPowers.setWrapped(sandbox, "info", SpecialPowers.wrap(info));
 SpecialPowers.setWrapped(sandbox, "is", SpecialPowers.wrap(is));
 SpecialPowers.setWrapped(sandbox, "ok", SpecialPowers.wrap(ok));
 
 const sandboxScript = function(shadowRoot) {