Bug 1143271 - use [ChromeOnly] on MutationObserverInit, r=bz

This commit is contained in:
Olli Pettay
2016-06-02 22:55:30 +03:00
parent 258adb72fe
commit 204ab34752
3 changed files with 27 additions and 11 deletions

View File

@@ -629,15 +629,11 @@ nsDOMMutationObserver::Observe(nsINode& aTarget,
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() ||
@@ -763,7 +759,7 @@ nsDOMMutationObserver::GetObservingInfo(
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();

View File

@@ -233,12 +233,32 @@ function testSubtree() {
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>

View File

@@ -61,10 +61,10 @@ dictionary MutationObserverInit {
boolean subtree = false;
boolean attributeOldValue;
boolean characterDataOldValue;
// [ChromeOnly]
[ChromeOnly]
boolean nativeAnonymousChildList = false;
// [ChromeOnly]
boolean animations;
[ChromeOnly]
boolean animations = false;
sequence<DOMString> attributeFilter;
};