diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-28 14:29:10 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-28 14:29:10 +0000 |
commit | 2aa4a82499d4becd2284cdb482213d541b8804dd (patch) | |
tree | b80bf8bf13c3766139fbacc530efd0dd9d54394c /dom/tests/browser/browser_allocateGigabyte.js | |
parent | Initial commit. (diff) | |
download | firefox-2aa4a82499d4becd2284cdb482213d541b8804dd.tar.xz firefox-2aa4a82499d4becd2284cdb482213d541b8804dd.zip |
Adding upstream version 86.0.1.upstream/86.0.1upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'dom/tests/browser/browser_allocateGigabyte.js')
-rw-r--r-- | dom/tests/browser/browser_allocateGigabyte.js | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/dom/tests/browser/browser_allocateGigabyte.js b/dom/tests/browser/browser_allocateGigabyte.js new file mode 100644 index 0000000000..602dbd791b --- /dev/null +++ b/dom/tests/browser/browser_allocateGigabyte.js @@ -0,0 +1,45 @@ +/* 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" + ); + }); + }); +}); |