tor-browser

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

MutationObserver-takeRecords.html (1697B)


      1 <!DOCTYPE HTML>
      2 <meta charset=utf-8>
      3 <title>MutationObservers: takeRecords</title>
      4 <script src="/resources/testharness.js"></script>
      5 <script src="/resources/testharnessreport.js"></script>
      6 <script src="mutationobservers.js"></script>
      7 <h1>MutationObservers: takeRecords</h1>
      8 <div id="log"></div>
      9 
     10 <section style="display: none">
     11 
     12 <p id='n00'></p>
     13 
     14 </section>
     15 
     16 <script>
     17 
     18  var n00 = document.getElementById('n00');
     19 
     20  var unused = async_test("unreachabled test");
     21 
     22  var observer;
     23  unused.step(function () {
     24    observer = new MutationObserver(unused.unreached_func("the observer callback should not fire"));
     25    observer.observe(n00, { "subtree": true,
     26                          "childList": true,
     27                          "attributes": true,
     28                          "characterData": true,
     29                          "attributeOldValue": true,
     30                          "characterDataOldValue": true});
     31    n00.id = "foo";
     32    n00.id = "bar";
     33    n00.className = "bar";
     34    n00.textContent = "old data";
     35    n00.firstChild.data = "new data";
     36  });
     37 
     38  test(function() {
     39    checkRecords(n00, observer.takeRecords(), [{type: "attributes", attributeName: "id", oldValue: "n00"},
     40                           {type: "attributes", attributeName: "id", oldValue: "foo"},
     41                           {type: "attributes", attributeName: "class"},
     42                           {type: "childList", addedNodes: [n00.firstChild]},
     43                           {type: "characterData", oldValue: "old data", target: n00.firstChild}]);
     44  }, "All records present");
     45 
     46  test(function() {
     47    checkRecords(n00, observer.takeRecords(), []);
     48  }, "No more records present");
     49 </script>
     50 <script>
     51  unused.done();
     52 
     53 </script>