1- import browser from "webextension-polyfill" ;
21import pRetry from "p-retry" ;
32import { isBackground } from "webext-detect" ;
43import { deserializeError } from "serialize-error" ;
@@ -22,7 +21,6 @@ import { events } from "./events.js";
2221const _errorNonExistingTarget =
2322 "Could not establish connection. Receiving end does not exist." ;
2423
25- // https://github.com/mozilla/webextension-polyfill/issues/384
2624const _errorTargetClosedEarly =
2725 "A listener indicated an asynchronous response by returning true, but the message channel closed before a response was received" ;
2826
@@ -166,9 +164,9 @@ async function manageMessage(
166164 throw error ;
167165 }
168166
169- if ( browser . tabs && typeof target . tabId === "number" ) {
167+ if ( chrome . tabs && typeof target . tabId === "number" ) {
170168 try {
171- const tabInfo = await browser . tabs . get ( target . tabId ) ;
169+ const tabInfo = await chrome . tabs . get ( target . tabId ) ;
172170 if ( tabInfo . discarded ) {
173171 throw new Error ( errorTabWasDiscarded ) ;
174172 }
@@ -270,7 +268,7 @@ function messenger<
270268 "↗️ sending message to runtime" ,
271269 attemptLog ( attemptCount ) ,
272270 ) ;
273- return browser . runtime . sendMessage (
271+ return chrome . runtime . sendMessage (
274272 makeMessage ( type , args , target , options ) ,
275273 ) ;
276274 } ;
@@ -279,7 +277,7 @@ function messenger<
279277 }
280278
281279 // Contexts without direct Tab access must go through background
282- if ( ! browser . tabs ) {
280+ if ( ! chrome . tabs ) {
283281 return manageConnection (
284282 type ,
285283 options ,
@@ -291,7 +289,7 @@ function messenger<
291289 "↗️ sending message to runtime" ,
292290 attemptLog ( attemptCount ) ,
293291 ) ;
294- return browser . runtime . sendMessage (
292+ return chrome . runtime . sendMessage (
295293 makeMessage ( type , args , target , options ) ,
296294 ) ;
297295 } ,
@@ -316,7 +314,7 @@ function messenger<
316314 frameId ,
317315 attemptLog ( attemptCount ) ,
318316 ) ;
319- return browser . tabs . sendMessage (
317+ return chrome . tabs . sendMessage (
320318 tabId ,
321319 makeMessage ( type , args , target , options ) ,
322320 frameId === "allFrames"
0 commit comments