Bug 1143271 - use [ChromeOnly] on MutationObserverInit, r=bz
authorOlli Pettay <Olli.Pettay@helsinki.fi>
Thu, 02 Jun 2016 22:55:30 +0300
changeset 341276 009d5a56af0f86e8e3abfa74dbe96ee429cac4e1
parent 341275 8203279f09e3a5eaba76d38cf614f79aff35561f
child 341277 a2f23b6058a275e8239a5edeeda56830afdb584f
push id1183
push userraliiev@mozilla.com
push dateMon, 05 Sep 2016 20:01:49 +0000
treeherdermozilla-release@3148731bed45 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbz
bugs1143271
milestone49.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 1143271 - use [ChromeOnly] on MutationObserverInit, r=bz
dom/base/nsDOMMutationObserver.cpp
dom/base/test/test_mutationobserver_anonymous.html
dom/webidl/MutationObserver.webidl
--- a/dom/base/nsDOMMutationObserver.cpp
+++ b/dom/base/nsDOMMutationObserver.cpp
@@ -624,25 +624,21 @@ nsDOMMutationObserver::Observe(nsINode& 
     aOptions.mAttributes.Value();
   bool characterData =
     aOptions.mCharacterData.WasPassed() &&
     aOptions.mCharacterData.Value();
   bool subtree = aOptions.mSubtree;
   bool attributeOldValue =
     aOptions.mAttributeOldValue.WasPassed() &&
     aOptions.mAttributeOldValue.Value();
-  bool nativeAnonymousChildList = aOptions.mNativeAnonymousChildList &&
-    nsContentUtils::ThreadsafeIsCallerChrome();
+  bool nativeAnonymousChildList = aOptions.mNativeAnonymousChildList;
   bool characterDataOldValue =
     aOptions.mCharacterDataOldValue.WasPassed() &&
     aOptions.mCharacterDataOldValue.Value();
-  bool animations =
-    aOptions.mAnimations.WasPassed() &&
-    aOptions.mAnimations.Value() &&
-    nsContentUtils::ThreadsafeIsCallerChrome();
+  bool animations = aOptions.mAnimations;
 
   if (!aOptions.mAttributes.WasPassed() &&
       (aOptions.mAttributeOldValue.WasPassed() ||
        aOptions.mAttributeFilter.WasPassed())) {
     attributes = true;
   }
 
   if (!aOptions.mCharacterData.WasPassed() &&
@@ -758,17 +754,17 @@ nsDOMMutationObserver::GetObservingInfo(
     nsMutationReceiver* mr = mReceivers[i];
     info.mChildList = mr->ChildList();
     info.mAttributes.Construct(mr->Attributes());
     info.mCharacterData.Construct(mr->CharacterData());
     info.mSubtree = mr->Subtree();
     info.mAttributeOldValue.Construct(mr->AttributeOldValue());
     info.mCharacterDataOldValue.Construct(mr->CharacterDataOldValue());
     info.mNativeAnonymousChildList = mr->NativeAnonymousChildList();
-    info.mAnimations.Construct(mr->Animations());
+    info.mAnimations = mr->Animations();
     nsCOMArray<nsIAtom>& filters = mr->AttributeFilter();
     if (filters.Count()) {
       info.mAttributeFilter.Construct();
       mozilla::dom::Sequence<nsString>& filtersAsStrings =
         info.mAttributeFilter.Value();
       nsString* strings = filtersAsStrings.AppendElements(filters.Count(),
                                                           mozilla::fallible);
       if (!strings) {
--- a/dom/base/test/test_mutationobserver_anonymous.html
+++ b/dom/base/test/test_mutationobserver_anonymous.html
@@ -228,18 +228,38 @@ function testSubtree() {
     assertSamePseudoElement("before", records[0].addedNodes[0], getFirstChild(parent));
     is(records[0].removedNodes.length, 0, "Shouldn't have got removedNodes");
 
     is(records[1].addedNodes.length, 1, "Should have got addedNodes");
     assertSamePseudoElement("after", records[1].addedNodes[0], getLastChild(parent));
     is(records[1].removedNodes.length, 0, "Shouldn't have got removedNodes");
 
     observer.disconnect();
-    SimpleTest.finish();
+    testDictionaryWithoutChromePriv();
   });
   SpecialPowers.observeMutationEvents(m, document, true, true);
   parent.style.display = "block";
 }
 
+function testDictionaryWithoutChromePriv()
+{
+  var m = new MutationObserver(function() {});
+  try {
+    m.observe(document, { childList: true, get nativeAnonymousChildList() { throw "Foo1"; } } );
+    ok(true, "Shouldn't throw!");
+  } catch(ex) {
+    ok(false, "Did throw " + ex);
+  }
+
+  try {
+    m.observe(document, { childList: true, get animations() { throw "Foo2"; } } );
+    ok(true, "Shouldn't throw!");
+  } catch(ex) {
+    ok(false, "Did throw " + ex);
+  }
+  
+  SimpleTest.finish();
+}
+
 </script>
 </pre>
 </body>
 </html>
--- a/dom/webidl/MutationObserver.webidl
+++ b/dom/webidl/MutationObserver.webidl
@@ -56,19 +56,19 @@ callback MutationCallback = void (sequen
 
 dictionary MutationObserverInit {
   boolean childList = false;
   boolean attributes;
   boolean characterData;
   boolean subtree = false;
   boolean attributeOldValue;
   boolean characterDataOldValue;
-  // [ChromeOnly]
+  [ChromeOnly]
   boolean nativeAnonymousChildList = false;
-  // [ChromeOnly]
-  boolean animations;
+  [ChromeOnly]
+  boolean animations = false;
   sequence<DOMString> attributeFilter;
 };
 
 dictionary MutationObservingInfo : MutationObserverInit
 {
   Node? observedNode = null;
 };