1
0
mirror of https://github.com/gorhill/uBlock.git synced 2024-11-26 12:22:50 +01:00

Mind that tabs.sendMessage can throw

This commit is contained in:
Raymond Hill 2024-03-17 09:34:05 -04:00
parent 9146134874
commit 3f7374c1f1
No known key found for this signature in database
GPG Key ID: 25E1490B761470C2
2 changed files with 2 additions and 7 deletions

View File

@ -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.
@ -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

View File

@ -19,10 +19,6 @@
Home: https://github.com/gorhill/uBlock
*/
/* globals browser */
'use strict';
/******************************************************************************/
// Broadcast a message to all uBO contexts
@ -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(( ) => { });
}
}