test_bug1747019.html (1657B)
1 <!DOCTYPE HTML> 2 <html> 3 <head> 4 <meta charset="utf-8"> 5 <title>Test session history and caching</title> 6 <script src="/tests/SimpleTest/SimpleTest.js"></script> 7 <link rel="stylesheet" href="/tests/SimpleTest/test.css"/> 8 <script> 9 SimpleTest.waitForExplicitFinish(); 10 11 var win; 12 var loadCount = 0; 13 var initialContent; 14 // The test loads first a page in a new window, then using 15 // form submission loads another page and then using form submission 16 // again loads third page. That page triggers history.go(-1). 17 // The second page is loaded now again and should have the same content 18 // as it had before. 19 function test() { 20 win = window.open("cache_control_max_age_3600.sjs?initial"); 21 window.onmessage = (e) => { 22 is(e.data, "loaded", "Should get load message 'loaded'"); 23 ++loadCount; 24 if (loadCount == 1) { 25 win.document.forms[0].submit(); 26 } else if (loadCount == 2) { 27 initialContent = win.document.body.textContent; 28 info("The initial content is [" + initialContent + "]."); 29 win.document.forms[0].submit(); 30 } else if (loadCount == 3) { 31 let newContent = win.document.body.textContent; 32 info("The new content is [" + newContent + "]."); 33 win.close(); 34 is(initialContent, newContent, "Should have loaded the page from cache."); 35 SimpleTest.finish(); 36 } else { 37 ok(false, "Unexpected load count."); 38 } 39 } 40 } 41 </script> 42 </head> 43 <body onload="test()"> 44 <p id="display"></p> 45 <div id="content" style="display: none"></div> 46 <pre id="test"></pre> 47 </body> 48 </html>