mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 973638, update MutationObserver.observe() to follow the spec, r=baku
--HG-- extra : rebase_source : dd62e2140275c2026038322c6b656886ec7d122a
This commit is contained in:
parent
641a2b8f22
commit
ab899fa308
@ -453,16 +453,57 @@ nsDOMMutationObserver::Observe(nsINode& aTarget,
|
||||
mozilla::ErrorResult& aRv)
|
||||
{
|
||||
|
||||
if (!(aOptions.mChildList || aOptions.mAttributes || aOptions.mCharacterData)) {
|
||||
aRv.Throw(NS_ERROR_DOM_SYNTAX_ERR);
|
||||
bool childList = aOptions.mChildList;
|
||||
bool attributes =
|
||||
aOptions.mAttributes.WasPassed() &&
|
||||
aOptions.mAttributes.Value();
|
||||
bool characterData =
|
||||
aOptions.mCharacterData.WasPassed() &&
|
||||
aOptions.mCharacterData.Value();
|
||||
bool subtree = aOptions.mSubtree;
|
||||
bool attributeOldValue =
|
||||
aOptions.mAttributeOldValue.WasPassed() &&
|
||||
aOptions.mAttributeOldValue.Value();
|
||||
bool characterDataOldValue =
|
||||
aOptions.mCharacterDataOldValue.WasPassed() &&
|
||||
aOptions.mCharacterDataOldValue.Value();
|
||||
|
||||
if (!aOptions.mAttributes.WasPassed() &&
|
||||
(aOptions.mAttributeOldValue.WasPassed() ||
|
||||
aOptions.mAttributeFilter.WasPassed())) {
|
||||
attributes = true;
|
||||
}
|
||||
|
||||
if (!aOptions.mCharacterData.WasPassed() &&
|
||||
aOptions.mCharacterDataOldValue.WasPassed()) {
|
||||
characterData = true;
|
||||
}
|
||||
|
||||
if (!(childList || attributes || characterData)) {
|
||||
aRv.Throw(NS_ERROR_DOM_TYPE_ERR);
|
||||
return;
|
||||
}
|
||||
if (aOptions.mAttributeOldValue && !aOptions.mAttributes) {
|
||||
aRv.Throw(NS_ERROR_DOM_SYNTAX_ERR);
|
||||
|
||||
if (aOptions.mAttributeOldValue.WasPassed() &&
|
||||
aOptions.mAttributeOldValue.Value() &&
|
||||
aOptions.mAttributes.WasPassed() &&
|
||||
!aOptions.mAttributes.Value()) {
|
||||
aRv.Throw(NS_ERROR_DOM_TYPE_ERR);
|
||||
return;
|
||||
}
|
||||
if (aOptions.mCharacterDataOldValue && !aOptions.mCharacterData) {
|
||||
aRv.Throw(NS_ERROR_DOM_SYNTAX_ERR);
|
||||
|
||||
if (aOptions.mAttributeFilter.WasPassed() &&
|
||||
aOptions.mAttributes.WasPassed() &&
|
||||
!aOptions.mAttributes.Value()) {
|
||||
aRv.Throw(NS_ERROR_DOM_TYPE_ERR);
|
||||
return;
|
||||
}
|
||||
|
||||
if (aOptions.mCharacterDataOldValue.WasPassed() &&
|
||||
aOptions.mCharacterDataOldValue.Value() &&
|
||||
aOptions.mCharacterData.WasPassed() &&
|
||||
!aOptions.mCharacterData.Value()) {
|
||||
aRv.Throw(NS_ERROR_DOM_TYPE_ERR);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -473,11 +514,6 @@ nsDOMMutationObserver::Observe(nsINode& aTarget,
|
||||
const mozilla::dom::Sequence<nsString>& filtersAsString =
|
||||
aOptions.mAttributeFilter.Value();
|
||||
uint32_t len = filtersAsString.Length();
|
||||
|
||||
if (len != 0 && !aOptions.mAttributes) {
|
||||
aRv.Throw(NS_ERROR_DOM_SYNTAX_ERR);
|
||||
return;
|
||||
}
|
||||
filters.SetCapacity(len);
|
||||
|
||||
for (uint32_t i = 0; i < len; ++i) {
|
||||
@ -487,12 +523,12 @@ nsDOMMutationObserver::Observe(nsINode& aTarget,
|
||||
}
|
||||
|
||||
nsMutationReceiver* r = GetReceiverFor(&aTarget, true);
|
||||
r->SetChildList(aOptions.mChildList);
|
||||
r->SetAttributes(aOptions.mAttributes);
|
||||
r->SetCharacterData(aOptions.mCharacterData);
|
||||
r->SetSubtree(aOptions.mSubtree);
|
||||
r->SetAttributeOldValue(aOptions.mAttributeOldValue);
|
||||
r->SetCharacterDataOldValue(aOptions.mCharacterDataOldValue);
|
||||
r->SetChildList(childList);
|
||||
r->SetAttributes(attributes);
|
||||
r->SetCharacterData(characterData);
|
||||
r->SetSubtree(subtree);
|
||||
r->SetAttributeOldValue(attributeOldValue);
|
||||
r->SetCharacterDataOldValue(characterDataOldValue);
|
||||
r->SetAttributeFilter(filters);
|
||||
r->SetAllAttributes(allAttrs);
|
||||
r->RemoveClones();
|
||||
@ -541,11 +577,11 @@ nsDOMMutationObserver::GetObservingInfo(nsTArray<Nullable<MutationObservingInfo>
|
||||
MutationObservingInfo& info = aResult.AppendElement()->SetValue();
|
||||
nsMutationReceiver* mr = mReceivers[i];
|
||||
info.mChildList = mr->ChildList();
|
||||
info.mAttributes = mr->Attributes();
|
||||
info.mCharacterData = mr->CharacterData();
|
||||
info.mAttributes.Construct(mr->Attributes());
|
||||
info.mCharacterData.Construct(mr->CharacterData());
|
||||
info.mSubtree = mr->Subtree();
|
||||
info.mAttributeOldValue = mr->AttributeOldValue();
|
||||
info.mCharacterDataOldValue = mr->CharacterDataOldValue();
|
||||
info.mAttributeOldValue.Construct(mr->AttributeOldValue());
|
||||
info.mCharacterDataOldValue.Construct(mr->CharacterDataOldValue());
|
||||
nsCOMArray<nsIAtom>& filters = mr->AttributeFilter();
|
||||
if (filters.Count()) {
|
||||
info.mAttributeFilter.Construct();
|
||||
|
@ -101,8 +101,7 @@ function runTest() {
|
||||
e = ex;
|
||||
}
|
||||
ok(e, "Should have thrown an exception");
|
||||
is(e.name, "SyntaxError", "Should have thrown SyntaxError");
|
||||
is(e.code, DOMException.SYNTAX_ERR, "Should have thrown DOMException.SYNTAX_ERR");
|
||||
is(e.name, "TypeError", "Should have thrown TypeError");
|
||||
|
||||
e = null;
|
||||
try {
|
||||
@ -110,9 +109,7 @@ function runTest() {
|
||||
} catch (ex) {
|
||||
e = ex;
|
||||
}
|
||||
ok(e, "Should have thrown an exception");
|
||||
is(e.name, "SyntaxError", "Should have thrown SyntaxError");
|
||||
is(e.code, DOMException.SYNTAX_ERR, "Should have thrown DOMException.SYNTAX_ERR");
|
||||
ok(!e, "Shouldn't have thrown an exception");
|
||||
|
||||
e = null;
|
||||
try {
|
||||
@ -120,9 +117,7 @@ function runTest() {
|
||||
} catch (ex) {
|
||||
e = ex;
|
||||
}
|
||||
ok(e, "Should have thrown an exception");
|
||||
is(e.name, "SyntaxError", "Should have thrown SyntaxError");
|
||||
is(e.code, DOMException.SYNTAX_ERR, "Should have thrown DOMException.SYNTAX_ERR");
|
||||
ok(!e, "Shouldn't have thrown an exception");
|
||||
|
||||
e = null;
|
||||
try {
|
||||
@ -130,9 +125,7 @@ function runTest() {
|
||||
} catch (ex) {
|
||||
e = ex;
|
||||
}
|
||||
ok(e, "Should have thrown an exception");
|
||||
is(e.name, "SyntaxError", "Should have thrown SyntaxError");
|
||||
is(e.code, DOMException.SYNTAX_ERR, "Should have thrown DOMException.SYNTAX_ERR");
|
||||
ok(!e, "Shouldn't have thrown an exception");
|
||||
|
||||
e = null;
|
||||
try {
|
||||
@ -140,7 +133,7 @@ function runTest() {
|
||||
} catch (ex) {
|
||||
e = ex;
|
||||
}
|
||||
ok(e, "Should have thrown an exception");
|
||||
ok(e, "Should have thrown an exception");
|
||||
|
||||
m = new M(function(records, observer) {
|
||||
is(observer, m, "2nd parameter should be the mutation observer");
|
||||
|
@ -47,11 +47,11 @@ callback MutationCallback = void (sequence<MutationRecord> mutations, MutationOb
|
||||
|
||||
dictionary MutationObserverInit {
|
||||
boolean childList = false;
|
||||
boolean attributes = false;
|
||||
boolean characterData = false;
|
||||
boolean attributes;
|
||||
boolean characterData;
|
||||
boolean subtree = false;
|
||||
boolean attributeOldValue = false;
|
||||
boolean characterDataOldValue = false;
|
||||
boolean attributeOldValue;
|
||||
boolean characterDataOldValue;
|
||||
sequence<DOMString> attributeFilter;
|
||||
};
|
||||
|
||||
|
@ -1,8 +0,0 @@
|
||||
[MutationObserver-attributes.html]
|
||||
type: testharness
|
||||
[attributeOldValue alone Element.id: update mutation]
|
||||
expected: FAIL
|
||||
|
||||
[attributeFilter alone Element.id/Element.className: multiple filter update mutation]
|
||||
expected: FAIL
|
||||
|
@ -1,5 +0,0 @@
|
||||
[MutationObserver-characterData.html]
|
||||
type: testharness
|
||||
[characterData/characterDataOldValue alone Text.data: simple mutation]
|
||||
expected: FAIL
|
||||
|
Loading…
Reference in New Issue
Block a user