[PM-11519] browser global variable triggering error fix jest (#10821)

* [PM-11519] `browser` global reference triggering an error when sending an extension message

* [PM-11519] `browser` global reference triggering an error when sending an extension message
This commit is contained in:
Cesar Gonzalez 2024-08-30 09:32:40 -05:00 committed by GitHub
parent 4453a5c114
commit ba42f10ea3
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 5 additions and 1 deletions

View File

@ -105,7 +105,11 @@ export async function sendExtensionMessage(
command: string,
options: Record<string, any> = {},
): Promise<any> {
if (typeof browser?.runtime?.sendMessage !== "undefined") {
if (
typeof browser !== "undefined" &&
typeof browser.runtime !== "undefined" &&
typeof browser.runtime.sendMessage !== "undefined"
) {
return browser.runtime.sendMessage({ command, ...options });
}