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 /ipc/glue/test/browser/browser_utility_geolocation_crashed.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 'ipc/glue/test/browser/browser_utility_geolocation_crashed.js')
-rw-r--r-- | ipc/glue/test/browser/browser_utility_geolocation_crashed.js | 70 |
1 files changed, 70 insertions, 0 deletions
diff --git a/ipc/glue/test/browser/browser_utility_geolocation_crashed.js b/ipc/glue/test/browser/browser_utility_geolocation_crashed.js new file mode 100644 index 0000000000..b0c341b69f --- /dev/null +++ b/ipc/glue/test/browser/browser_utility_geolocation_crashed.js @@ -0,0 +1,70 @@ +/* Any copyright is dedicated to the Public Domain. + * http://creativecommons.org/publicdomain/zero/1.0/ */ + +"use strict"; + +async function getGeolocation() { + info("Requesting geolocation"); + + let resolve; + let promise = new Promise((_resolve, _reject) => { + resolve = _resolve; + }); + + navigator.geolocation.getCurrentPosition( + () => { + ok(true, "geolocation succeeded"); + resolve(undefined); + }, + () => { + ok(false, "geolocation failed"); + resolve(undefined); + } + ); + + return promise; +} + +add_setup(async function () { + // Avoid the permission doorhanger and cache that would trigger instead + // of re-requesting location. Setting geo.timeout to 0 causes it to + // retry the system geolocation (incl. recreating the utility process) + // instead of reusing the MLS geolocation fallback it found the first time. + await SpecialPowers.pushPrefEnv({ + set: [ + ["geo.prompt.testing", true], + ["geo.prompt.testing.allow", true], + ["geo.provider.network.debug.requestCache.enabled", false], + ["geo.provider.testing", false], + ["geo.timeout", 0], + ], + }); +}); + +add_task(async function testGeolocationProcessCrash() { + info("Start the Windows utility process"); + await getGeolocation(); + + info("Crash the utility process"); + await crashSomeUtilityActor("windowsUtils"); + + info("Restart the Windows utility process"); + await getGeolocation(); + + info("Confirm the restarted process"); + await checkUtilityExists("windowsUtils"); + + info("Kill the utility process"); + await cleanUtilityProcessShutdown("windowsUtils", true); + + info("Restart the Windows utility process again"); + await getGeolocation(); + + info("Confirm the restarted process"); + await checkUtilityExists("windowsUtils"); +}); + +add_task(async function testCleanup() { + info("Clean up to avoid confusing future tests"); + await cleanUtilityProcessShutdown("windowsUtils", true); +}); |