tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

commit 24d78adac95887e3d6fca4d5cc8e4fb88cf355ae
parent 0dcb946b8e1ac82a696182e068d3e08c81d325d0
Author: Alexandra Borovova <aborovova@mozilla.com>
Date:   Thu,  4 Dec 2025 13:47:10 +0000

Bug 2003992 - [webdriver-bidi] Throw an error when calling "emulation.setLocaleOverride" with "locale" argument equal "undefined". r=whimboo

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

Diffstat:
Mremote/webdriver-bidi/modules/root/emulation.sys.mjs | 38++++++++++++++++++--------------------
1 file changed, 18 insertions(+), 20 deletions(-)

diff --git a/remote/webdriver-bidi/modules/root/emulation.sys.mjs b/remote/webdriver-bidi/modules/root/emulation.sys.mjs @@ -362,28 +362,26 @@ class EmulationModule extends RootBiDiModule { } = options; let locale; - if (localeArg !== undefined) { - if (localeArg === null) { - // The API requires an empty string to reset the override. - locale = ""; - } else { - locale = lazy.assert.string( - localeArg, - lazy.pprint`Expected "locale" to be a string, got ${localeArg}` - ); - - // Validate if locale is a structurally valid language tag. - try { - Intl.getCanonicalLocales(localeArg); - } catch (err) { - if (err instanceof RangeError) { - throw new lazy.error.InvalidArgumentError( - `Expected "locale" to be a structurally valid language tag (e.g., "en-GB"), got ${localeArg}` - ); - } + if (localeArg === null) { + // The API requires an empty string to reset the override. + locale = ""; + } else { + locale = lazy.assert.string( + localeArg, + lazy.pprint`Expected "locale" to be a string, got ${localeArg}` + ); - throw err; + // Validate if locale is a structurally valid language tag. + try { + Intl.getCanonicalLocales(localeArg); + } catch (err) { + if (err instanceof RangeError) { + throw new lazy.error.InvalidArgumentError( + `Expected "locale" to be a structurally valid language tag (e.g., "en-GB"), got ${localeArg}` + ); } + + throw err; } }