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