aborted-parser.window.js (1501B)
1 // document.open() bails out early if there is an active parser with non-zero 2 // script nesting level or if a load was aborted while there was an active 3 // parser. window.stop() aborts the current parser, so once it has been called 4 // while a parser is active, document.open() will no longer do anything to that 5 // document, 6 7 window.handlers = {}; 8 9 async_test(t => { 10 const frame = document.body.appendChild(document.createElement("iframe")); 11 t.add_cleanup(() => frame.remove()); 12 frame.src = "resources/aborted-parser-frame.html"; 13 window.handlers.afterOpen = t.step_func_done(() => { 14 const openCalled = frame.contentDocument.childNodes.length === 0; 15 assert_false(openCalled, "child document should not be empty"); 16 assert_equals(frame.contentDocument.querySelector("p").textContent, 17 "Text", "Should still have our paragraph"); 18 }); 19 }, "document.open() after parser is aborted"); 20 21 async_test(t => { 22 const frame = document.body.appendChild(document.createElement("iframe")); 23 t.add_cleanup(() => frame.remove()); 24 frame.src = "resources/aborted-parser-async-frame.html"; 25 window.handlers.afterOpenAsync = t.step_func_done(() => { 26 const openCalled = frame.contentDocument.childNodes.length === 0; 27 assert_false(openCalled, "child document should not be empty"); 28 assert_equals(frame.contentDocument.querySelector("p").textContent, 29 "Text", "Should still have our paragraph"); 30 }); 31 }, "async document.open() after parser is aborted");