tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

historical-mutation-events.html (2343B)


      1 <!DOCTYPE html>
      2 <title>Historical DOM features must be removed</title>
      3 <script src="/resources/testharness.js"></script>
      4 <script src="/resources/testharnessreport.js"></script>
      5 <div id=log></div>
      6 <script>
      7 // This test has been split out from dom/historical.html so that the removal
      8 // of Mutation Events can be tracked separately from the removal of other
      9 // features as part of Interop2025 [1]. When Interop2025 concludes, the contents
     10 // of this test can be merged back into dom/historical.html.
     11 // [1] https://github.com/web-platform-tests/interop/blob/main/2025/README.md
     12 
     13 function isInterfaceRemoved(name) {
     14  test(function() {
     15    assert_false(name in window)
     16    assert_equals(window[name], undefined)
     17  }, "Historical DOM features must be removed: " + name)
     18 }
     19 var removedInterfaces = [
     20  "MutationEvent"
     21 ]
     22 removedInterfaces.forEach(isInterfaceRemoved)
     23 
     24 // For reference, these events were defined in
     25 // https://www.w3.org/TR/2003/NOTE-DOM-Level-3-Events-20031107/DOM3-Events.html#events-Events-EventTypes-complete
     26 const mutationEvents = [
     27  'DOMSubtreeModified',
     28  'DOMNodeInserted',
     29  'DOMNodeRemoved',
     30  'DOMNodeRemovedFromDocument',
     31  'DOMNodeInsertedIntoDocument',
     32  'DOMCharacterDataModified',
     33  'DOMAttrModified',
     34  'DOMAttributeNameChanged',
     35  'DOMElementNameChanged',
     36 ];
     37 mutationEvents.forEach(evt => {
     38  promise_test(async (t) => {
     39    const target = document.createElement('div');
     40    let fired = false;
     41    function listener(event) {
     42      fired = true;
     43    }
     44    target.addEventListener(evt,listener);
     45    document.body.addEventListener(evt,listener);
     46    target.append('here');
     47    t.add_cleanup(() => target.remove());
     48    document.body.appendChild(target);
     49 
     50    // Trigger all mutation types except DOMElementNameChanged, which could
     51    // only be triggered by a call to the (deprecated, removed)
     52    // Document.renameNode() API.
     53    target.remove();
     54    document.body.appendChild(target);
     55    target.setAttribute('test','foo');
     56    target.attributes[0].value='bar';
     57    target.attributes[0].name='baz';
     58    target.firstChild.textContent = "bar";
     59    // Mutation events were synchronous, but ensure even async versions
     60    // would fail this test.
     61    await new Promise(resolve=>t.step_timeout(resolve,0));
     62    assert_false(fired,'Event was fired');
     63  }, `The ${evt} mutation event must not be fired.`);
     64 });
     65 </script>