Skip to content

Commit

Permalink
Mind that tabs.sendMessage can throw
Browse files Browse the repository at this point in the history
  • Loading branch information
gorhill committed Mar 17, 2024
1 parent 9146134 commit 3f7374c
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 7 deletions.
3 changes: 1 addition & 2 deletions platform/chromium/webext.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,6 @@
Home: https://github.com/gorhill/uBlock
*/

'use strict';

// `webext` is a promisified api of `chrome`. Entries are added as
// the promisification of uBO progress.

Expand Down Expand Up @@ -104,6 +102,7 @@ const webext = {
query: promisifyNoFail(chrome.tabs, 'query', tabs => Array.isArray(tabs) ? tabs : []),
reload: promisifyNoFail(chrome.tabs, 'reload'),
remove: promisifyNoFail(chrome.tabs, 'remove'),
sendMessage: promisifyNoFail(chrome.tabs, 'sendMessage'),
update: promisifyNoFail(chrome.tabs, 'update', tab => tab instanceof Object ? tab : null),
},
// https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/API/webNavigation
Expand Down
6 changes: 1 addition & 5 deletions src/js/broadcast.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,6 @@
Home: https://github.com/gorhill/uBlock
*/

/* globals browser */

'use strict';

/******************************************************************************/

// Broadcast a message to all uBO contexts
Expand All @@ -47,7 +43,7 @@ export async function broadcastToAll(message) {
});
const bcmessage = Object.assign({ broadcast: true }, message);
for ( const tab of tabs ) {
browser.tabs.sendMessage(tab.id, bcmessage);
webext.tabs.sendMessage(tab.id, bcmessage).catch(( ) => { });
}
}

Expand Down

0 comments on commit 3f7374c

Please sign in to comment.