Source code

Revision control

Copy as Markdown

Other Tools

Test Info: Warnings

<!DOCTYPE html>
<title>Historical DOM features must be removed</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<div id=log></div>
<script>
// This test has been split out from dom/historical.html so that the removal
// of Mutation Events can be tracked separately from the removal of other
// features as part of Interop2025 [1]. When Interop2025 concludes, the contents
// of this test can be merged back into dom/historical.html.
function isInterfaceRemoved(name) {
test(function() {
assert_false(name in window)
assert_equals(window[name], undefined)
}, "Historical DOM features must be removed: " + name)
}
var removedInterfaces = [
"MutationEvent"
]
removedInterfaces.forEach(isInterfaceRemoved)
// For reference, these events were defined in
const mutationEvents = [
'DOMSubtreeModified',
'DOMNodeInserted',
'DOMNodeRemoved',
'DOMNodeRemovedFromDocument',
'DOMNodeInsertedIntoDocument',
'DOMCharacterDataModified',
'DOMAttrModified',
'DOMAttributeNameChanged',
'DOMElementNameChanged',
];
mutationEvents.forEach(evt => {
promise_test(async (t) => {
const target = document.createElement('div');
let fired = false;
function listener(event) {
fired = true;
}
target.addEventListener(evt,listener);
document.body.addEventListener(evt,listener);
target.append('here');
t.add_cleanup(() => target.remove());
document.body.appendChild(target);
// Trigger all mutation types except DOMElementNameChanged, which could
// only be triggered by a call to the (deprecated, removed)
// Document.renameNode() API.
target.remove();
document.body.appendChild(target);
target.setAttribute('test','foo');
target.attributes[0].value='bar';
target.attributes[0].name='baz';
target.firstChild.textContent = "bar";
// Mutation events were synchronous, but ensure even async versions
// would fail this test.
await new Promise(resolve=>t.step_timeout(resolve,0));
assert_false(fired,'Event was fired');
}, `The ${evt} mutation event must not be fired.`);
});
</script>