history.window.js (1271B)
1 // Historically, document.open() created an entry in the session history so 2 // that the original page could be seen by going back. Test that this behavior 3 // no longer occurs. 4 // 5 // This test uses window.open() for variety, as most other tests in this 6 // directory use document.open(). An <iframe> would probably work also. We can 7 // always add an <iframe>-based test later if it is deemed necessary. 8 9 const t = async_test("document.open should not add an entry to the session history"); 10 11 const frameURL = new URL("resources/history-frame.html", document.URL).href; 12 13 let origLength; 14 window.onFrameLoaded = t.step_func(() => { 15 window.onFrameLoaded = t.unreached_func("onFrameLoaded should only be called once"); 16 assert_equals(win.document.URL, frameURL); 17 assert_true(win.document.body.textContent.includes("Old")); 18 origLength = win.history.length; 19 }); 20 window.onDocumentOpen = t.step_func_done(() => { 21 window.onDocumentOpen = t.unreached_func("onDocumentOpen should only be called once"); 22 assert_equals(win.document.URL, frameURL); 23 assert_true(win.document.body.textContent.includes("New")); 24 assert_not_equals(origLength, undefined); 25 assert_equals(win.history.length, origLength); 26 }); 27 28 const win = window.open(frameURL); 29 t.add_cleanup(() => win.close());