OLD | NEW |
(Empty) | |
| 1 <!DOCTYPE HTML> |
| 2 <meta charset=utf-8> |
| 3 <title>MutationObservers: disconnect</title> |
| 4 <script src="../../../../resources/testharness.js"></script> |
| 5 <script src="../../../../resources/testharnessreport.js"></script> |
| 6 <h1>MutationObservers: disconnect</h1> |
| 7 <div id="log"></div> |
| 8 <section style="display: none"> |
| 9 <p id='n00'></p> |
| 10 </section> |
| 11 <script> |
| 12 var n00 = document.getElementById('n00'); |
| 13 var parentTest = async_test("subtree mutations"); |
| 14 function masterMO(sequence, obs) { |
| 15 parentTest.step(function() { |
| 16 assert_equals(sequence.length, 4, "mutation records must match"); |
| 17 }); |
| 18 parentTest.done(); |
| 19 } |
| 20 parentTest.step(function() { |
| 21 (new MutationObserver(masterMO)).observe(n00.parentNode, {"subtree": true, "at
tributes": true}); |
| 22 }); |
| 23 |
| 24 var disconnectTest = async_test("disconnect discarded some mutations"); |
| 25 function observerCallback(sequence, obs) { |
| 26 disconnectTest.step(function() { |
| 27 assert_equals(sequence.length, 1); |
| 28 assert_equals(sequence[0].type, "attributes"); |
| 29 assert_equals(sequence[0].attributeName, "id"); |
| 30 assert_equals(sequence[0].oldValue, "latest"); |
| 31 disconnectTest.done(); |
| 32 }); |
| 33 } |
| 34 |
| 35 var observer; |
| 36 disconnectTest.step(function() { |
| 37 observer = new MutationObserver(observerCallback); |
| 38 observer.observe(n00, {"attributes": true}); |
| 39 n00.id = "foo"; |
| 40 n00.id = "bar"; |
| 41 observer.disconnect(); |
| 42 observer.observe(n00, {"attributes": true, "attributeOldValue": true}); |
| 43 n00.id = "latest"; |
| 44 observer.disconnect(); |
| 45 observer.observe(n00, {"attributes": true, "attributeOldValue": true}); |
| 46 n00.id = "n0000"; |
| 47 }); |
| 48 </script> |
OLD | NEW |