mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-18 15:55:36 +00:00
Bug 1681529 - Part 1: Add a test for reloading a page with a large postdata payload, r=peterv
Without the other patches in this series, this test fails with both with and without Fission enabled, for two different reasons. With Fission disabled, the second reload request appears as empty, due to us being unable to rewind the postData nsIInputStream. With Fission enabled, the second reload request causes crashes due to the nsMIMEInputStream's invariant of requiring a seekable stream is invalidated, causing the nsICloneableInputStream implementation to misbehave. Differential Revision: https://phabricator.services.mozilla.com/D101800
This commit is contained in:
parent
51eef41214
commit
b3fac57b0f
46
docshell/test/navigation/file_reload_large_postdata.sjs
Normal file
46
docshell/test/navigation/file_reload_large_postdata.sjs
Normal file
@ -0,0 +1,46 @@
|
||||
/* -*- Mode: indent-tabs-mode: nil; js-indent-level: 2 -*- */
|
||||
/* vim: set sts=2 sw=2 et tw=80 ft=javascript: */
|
||||
"use strict";
|
||||
|
||||
const BinaryInputStream = CC(
|
||||
"@mozilla.org/binaryinputstream;1",
|
||||
"nsIBinaryInputStream",
|
||||
"setInputStream"
|
||||
);
|
||||
|
||||
Cu.importGlobalProperties(["URLSearchParams"]);
|
||||
|
||||
function readStream(inputStream) {
|
||||
let available = 0;
|
||||
let result = [];
|
||||
while ((available = inputStream.available()) > 0) {
|
||||
result.push(inputStream.readBytes(available));
|
||||
}
|
||||
return result.join("");
|
||||
}
|
||||
|
||||
function handleRequest(request, response) {
|
||||
let rv = (() => {
|
||||
try {
|
||||
if (request.method != "POST") {
|
||||
return "ERROR: not a POST request";
|
||||
}
|
||||
|
||||
let body = new URLSearchParams(
|
||||
readStream(new BinaryInputStream(request.bodyInputStream))
|
||||
);
|
||||
return body.get("payload").length;
|
||||
} catch (e) {
|
||||
return "ERROR: Exception: " + e;
|
||||
}
|
||||
})();
|
||||
|
||||
response.setHeader("Content-Type", "text/html", false);
|
||||
response.setHeader("Cache-Control", "no-cache", false);
|
||||
response.write(`<!DOCTYPE HTML>
|
||||
<script>
|
||||
let rv = (${JSON.stringify(rv)});
|
||||
opener.postMessage(rv, "*");
|
||||
</script>
|
||||
`);
|
||||
}
|
@ -119,3 +119,6 @@ skip-if = true # This was disabled for a few years now anyway, bug 1677544
|
||||
[test_triggeringprincipal_iframe_iframe_window_open.html]
|
||||
[test_contentpolicy_block_window.html]
|
||||
[test_rate_limit_location_change.html]
|
||||
[test_reload_large_postdata.html]
|
||||
support-files =
|
||||
file_reload_large_postdata.sjs
|
||||
|
61
docshell/test/navigation/test_reload_large_postdata.html
Normal file
61
docshell/test/navigation/test_reload_large_postdata.html
Normal file
@ -0,0 +1,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.
|
||||
requestLongerTimeout(2);
|
||||
</script>
|
||||
</pre>
|
||||
</body>
|
||||
</html>
|
@ -40,6 +40,8 @@ bool SerializeInputStreamWithFdsChild(nsIIPCSerializableInputStream* aStream,
|
||||
MOZ_RELEASE_ASSERT(aStream);
|
||||
MOZ_ASSERT(aManager);
|
||||
|
||||
// If you change this size, please also update the payload size in
|
||||
// test_reload_large_postdata.html.
|
||||
const uint64_t kTooLargeStream = 1024 * 1024;
|
||||
|
||||
uint32_t sizeUsed = 0;
|
||||
|
Loading…
Reference in New Issue
Block a user