test_bug1536471.html (2582B)
1 <!DOCTYPE HTML> 2 <html> 3 <!-- 4 https://bugzilla.mozilla.org/show_bug.cgi?id=1536471 5 --> 6 <head> 7 <title>Test for Bug 1536471</title> 8 <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script> 9 <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" /> 10 <script type="application/javascript"> 11 12 let testWin; 13 async function test() { 14 // Open a new tab and load a document with an iframe inside 15 testWin = window.open("file_bug1536471.html"); 16 await waitForLoad(); 17 var iframe = testWin.document.getElementById("staticFrame"); 18 is(testWin.history.length, 1, "Checking the number of session history entries when there is only one iframe"); 19 20 // Navigate the iframe to different pages 21 await loadUriInFrame(iframe, "frame1.html"); 22 is(testWin.history.length, 2, "Checking the number of session history entries after having navigated a single iframe 1 time"); 23 await loadUriInFrame(iframe, "frame2.html"); 24 is(testWin.history.length, 3, "Checking the number of session history entries after having navigated a single iframe 2 times"); 25 await loadUriInFrame(iframe, "frame3.html"); 26 is(testWin.history.length, 4, "Checking the number of session history entries after having navigated a single iframe 3 times"); 27 28 // Reload the top document 29 testWin.location.reload(true); 30 await waitForLoad(); 31 is(testWin.history.length, 1, "Checking the number of session history entries after reloading the top document"); 32 33 testWin.close(); 34 SimpleTest.finish(); 35 } 36 37 async function waitForLoad() { 38 await new Promise(resolve => { 39 window.bodyOnLoad = function() { 40 setTimeout(resolve, 0); 41 window.bodyOnLoad = undefined; 42 }; 43 }); 44 } 45 46 async function iframeOnload(frame) { 47 return new Promise(resolve => { 48 frame.addEventListener("load", () => { 49 setTimeout(resolve, 0); 50 }, {once: true}); 51 }); 52 } 53 54 async function loadUriInFrame(frame, uri) { 55 let onloadPromise = iframeOnload(frame); 56 frame.src = uri; 57 await onloadPromise; 58 } 59 </script> 60 </head> 61 62 <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=1536471">Mozilla Bug </a> 63 <p id="display"></p> 64 <div id="content" style="display: none"> 65 </div> 66 <pre id="test"> 67 <script type="text/javascript"> 68 SimpleTest.waitForExplicitFinish(); 69 </script> 70 </pre> 71 <body onload="test()"> 72 </body> 73 </html>