Bug 1347983 - Part 2: Add a test to ensure that forms submitted from a large-allocation page behave correctly, r=smaug

MozReview-Commit-ID: Af44H11AFMf
This commit is contained in:
Michael Layzell 2017-03-16 14:32:30 -04:00
Родитель ccc519e3f4
Коммит 64b0637518
4 изменённых файлов: 72 добавлений и 1 удалений

Просмотреть файл

@ -13,6 +13,7 @@ support-files =
test_largeAllocation.html^headers^
test_largeAllocation2.html
test_largeAllocation2.html^headers^
test_largeAllocationFormSubmit.sjs
helper_largeAllocation.js
!/dom/tests/mochitest/geolocation/network_geolocation.sjs

Просмотреть файл

@ -494,6 +494,46 @@ function* largeAllocSuccessTests() {
yield BrowserTestUtils.closeWindow(newWindow);
});
// XXX: Important - reset the process count, as it was set to 1 by the
// previous test.
yield SpecialPowers.pushPrefEnv({
set: [["dom.ipc.processCount.webLargeAllocation", 20]],
});
yield BrowserTestUtils.withNewTab("about:blank", function*(aBrowser) {
info("Starting test 11");
let pid1 = yield getPID(aBrowser);
is(false, yield getInLAProc(aBrowser));
let ready = Promise.all([expectProcessCreated(),
BrowserTestUtils.browserLoaded(aBrowser)]);
yield ContentTask.spawn(aBrowser, TEST_URI, TEST_URI => {
content.document.location = TEST_URI;
});
yield ready;
let pid2 = yield getPID(aBrowser);
isnot(pid1, pid2, "PIDs 1 and 2 should not match");
is(true, yield getInLAProc(aBrowser));
yield Promise.all([
ContentTask.spawn(aBrowser, null, () => {
content.document.querySelector("#submit").click();
}),
BrowserTestUtils.browserLoaded(aBrowser)
]);
let innerText = yield ContentTask.spawn(aBrowser, null, () => {
return content.document.body.innerText;
});
isnot(innerText, "FAIL", "We should not have sent a get request!");
is(innerText, "textarea=default+value&button=submit",
"The post data should be received by the callee");
});
// XXX: Make sure to reset dom.ipc.processCount.webLargeAllocation if adding a
// test after the above test.
}

Просмотреть файл

@ -1,4 +1,10 @@
<!doctype html>
<html>
<body>Loaded in a new process!</body>
<body>
Loaded in a new process!
<form action="test_largeAllocationFormSubmit.sjs" method="POST">
<input type="text" name="textarea" value="default value">
<input type="submit" name="button" value="submit" id="submit">
</form>
</body>
</html>

Просмотреть файл

@ -0,0 +1,24 @@
const BinaryInputStream = Components.Constructor("@mozilla.org/binaryinputstream;1",
"nsIBinaryInputStream",
"setInputStream");
function handleRequest(request, response) {
response.setHeader("Large-Allocation", "0", false);
response.setHeader("Content-Type", "text/plain", false);
response.setStatusLine(request.httpVersion, "200", "Found");
if (request.method == "GET") {
response.write("FAIL");
return;
}
var body = new BinaryInputStream(request.bodyInputStream);
var avail;
var bytes = [];
while ((avail = body.available()) > 0)
Array.prototype.push.apply(bytes, body.readByteArray(avail));
var data = String.fromCharCode.apply(null, bytes);
response.bodyOutputStream.write(data, data.length);
}