mutation-observer.window.js (1104B)
1 async_test(t => { 2 const frame = document.body.appendChild(document.createElement("iframe")); 3 t.add_cleanup(() => { frame.remove(); }); 4 const originalHTMLElement = frame.contentDocument.documentElement; 5 assert_equals(originalHTMLElement.localName, "html"); 6 const observer = new frame.contentWindow.MutationObserver(t.step_func_done(records => { 7 // Even though we passed `subtree: true` to observer.observe, due to the 8 // fact that "replace all" algorithm removes children with the "suppress 9 // observers flag" set, we still only get the html element as the sole 10 // removed node. 11 assert_equals(records.length, 1); 12 assert_equals(records[0].type, "childList"); 13 assert_equals(records[0].target, frame.contentDocument); 14 assert_array_equals(records[0].addedNodes, []); 15 assert_array_equals(records[0].removedNodes, [originalHTMLElement]); 16 })); 17 observer.observe(frame.contentDocument, { childList: true, subtree: true }); 18 assert_equals(frame.contentDocument.open(), frame.contentDocument); 19 }, "document.open() should inform mutation observer of node removal");