fune/dom/tests/browser/browser_allocateGigabyte.js
Kris Maglione 94e3b0bd8d Bug 1596918: Part 3a - Scripted rewrite of most ContentTask.spawn calls to SpecialPowers.spawn calls. r=mccr8,remote-protocol-reviewers,ato
This is generally pretty straightforward, and rewrites nearly all calls. It
skips the ones that it can detect using frame script globals like
`sendAsyncMessage`, though.

Differential Revision: https://phabricator.services.mozilla.com/D53740

--HG--
extra : moz-landing-system : lando
2019-12-13 20:36:16 +00:00

45 lines
1.4 KiB
JavaScript

/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
const TEST_URI =
"http://example.com/browser/dom/tests/browser/test_largeAllocation.html";
function expectProcessCreated() {
let os = Services.obs;
return new Promise(resolve => {
let topic = "ipc:content-created";
function observer() {
os.removeObserver(observer, topic);
ok(true, "Expect process created");
resolve();
}
os.addObserver(observer, topic);
});
}
add_task(async function() {
await SpecialPowers.pushPrefEnv({
set: [["dom.largeAllocationHeader.enabled", true]],
});
// A toplevel tab should be able to navigate cross process!
await BrowserTestUtils.withNewTab("about:blank", async function(aBrowser) {
let epc = expectProcessCreated();
await SpecialPowers.spawn(aBrowser, [TEST_URI], TEST_URI => {
content.document.location = TEST_URI;
});
// Wait for the new process to be created by the Large-Allocation header
await epc;
// Allocate a gigabyte of memory in the content process
await SpecialPowers.spawn(aBrowser, [], () => {
let arrayBuffer = new ArrayBuffer(1024 * 1024 * 1024);
ok(
arrayBuffer,
"Successfully allocated a gigabyte of memory in content process"
);
});
});
});