test_reload_large_postdata.html (1795B)
1 <!DOCTYPE HTML> 2 <html> 3 <head> 4 <script src="/tests/SimpleTest/SimpleTest.js"></script> 5 <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/> 6 </head> 7 <body> 8 <p id="display"></p> 9 10 <form id="form" action="file_reload_large_postdata.sjs" target="_blank" rel="opener" method="POST"> 11 <input id="input" name="payload" type="hidden" value=""/> 12 </form> 13 14 <pre id="test"> 15 <script> 16 // This is derived from `kTooLargeStream` in `IPCStreamUtils.cpp`. 17 const kTooLargeStream = 1024 * 1024; 18 19 function waitForPopup(expected) { 20 return new Promise(resolve => { 21 addEventListener("message", evt => { 22 info("got message!"); 23 is(evt.source.opener, window, "the event source's opener should be this window"); 24 is(evt.data, expected, "got the expected data from the popup"); 25 resolve(evt.source); 26 }, { once: true }); 27 }); 28 } 29 30 add_task(async function() { 31 await SpecialPowers.pushPrefEnv({"set": [["dom.confirm_repost.testing.always_accept", true]]}); 32 let form = document.getElementById("form"); 33 let input = document.getElementById("input"); 34 35 // Create a very large value to include in the post payload. This should 36 // ensure that the value isn't sent directly over IPC, and is instead sent as 37 // an async inputstream. 38 let payloadSize = kTooLargeStream; 39 40 let popupReady = waitForPopup(payloadSize); 41 input.value = "A".repeat(payloadSize); 42 form.submit(); 43 44 let popup = await popupReady; 45 try { 46 let popupReady2 = waitForPopup(payloadSize); 47 info("reloading popup"); 48 popup.location.reload(); 49 let popup2 = await popupReady2; 50 is(popup, popup2); 51 } finally { 52 popup.close(); 53 } 54 }); 55 56 // The .sjs server can time out processing the 1mb payload in debug builds. 57 SimpleTest.requestLongerTimeout(2); 58 </script> 59 </pre> 60 </body> 61 </html>