diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-19 00:47:55 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-19 00:47:55 +0000 |
commit | 26a029d407be480d791972afb5975cf62c9360a6 (patch) | |
tree | f435a8308119effd964b339f76abb83a57c29483 /browser/base/content/test/tabs/browser_dont_process_switch_204.js | |
parent | Initial commit. (diff) | |
download | firefox-26a029d407be480d791972afb5975cf62c9360a6.tar.xz firefox-26a029d407be480d791972afb5975cf62c9360a6.zip |
Adding upstream version 124.0.1.upstream/124.0.1
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to '')
-rw-r--r-- | browser/base/content/test/tabs/browser_dont_process_switch_204.js | 56 |
1 files changed, 56 insertions, 0 deletions
diff --git a/browser/base/content/test/tabs/browser_dont_process_switch_204.js b/browser/base/content/test/tabs/browser_dont_process_switch_204.js new file mode 100644 index 0000000000..b35170ad1e --- /dev/null +++ b/browser/base/content/test/tabs/browser_dont_process_switch_204.js @@ -0,0 +1,56 @@ +/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */ +/* vim: set ft=javascript ts=2 et sw=2 tw=80: */ +/* Any copyright is dedicated to the Public Domain. + * http://creativecommons.org/publicdomain/zero/1.0/ */ + +const TEST_ROOT = getRootDirectory(gTestPath).replace( + "chrome://mochitests/content", + "https://example.com" +); +const TEST_URL = TEST_ROOT + "204.sjs"; +const BLANK_URL = TEST_ROOT + "blank.html"; + +// Test for bug 1626362. +add_task(async function () { + await BrowserTestUtils.withNewTab("about:robots", async function (aBrowser) { + // Get the current pid for browser for comparison later, we expect this + // to be the parent process for about:robots. + let browserPid = await SpecialPowers.spawn(aBrowser, [], () => { + return Services.appinfo.processID; + }); + + is( + Services.appinfo.processID, + browserPid, + "about:robots should have loaded in the parent" + ); + + // Attempt to load a uri that returns a 204 response, and then check that + // we didn't process switch for it. + let stopped = BrowserTestUtils.browserStopped(aBrowser, TEST_URL, true); + BrowserTestUtils.startLoadingURIString(aBrowser, TEST_URL); + await stopped; + + let newPid = await SpecialPowers.spawn(aBrowser, [], () => { + return Services.appinfo.processID; + }); + + is( + browserPid, + newPid, + "Shouldn't change process when we get a 204 response" + ); + + // Load a valid http page and confirm that we did change process + // to confirm that we weren't in a web process to begin with. + let loaded = BrowserTestUtils.browserLoaded(aBrowser, false, BLANK_URL); + BrowserTestUtils.startLoadingURIString(aBrowser, BLANK_URL); + await loaded; + + newPid = await SpecialPowers.spawn(aBrowser, [], () => { + return Services.appinfo.processID; + }); + + isnot(browserPid, newPid, "Should change process for a valid response"); + }); +}); |