From 3f7374c1f1f8ba3207bc777347088f2fb070fc1e Mon Sep 17 00:00:00 2001 From: Raymond Hill Date: Sun, 17 Mar 2024 09:34:05 -0400 Subject: [PATCH] Mind that `tabs.sendMessage` can throw --- platform/chromium/webext.js | 3 +-- src/js/broadcast.js | 6 +----- 2 files changed, 2 insertions(+), 7 deletions(-) diff --git a/platform/chromium/webext.js b/platform/chromium/webext.js index 5c6f470171ce4..f044649d61ada 100644 --- a/platform/chromium/webext.js +++ b/platform/chromium/webext.js @@ -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 diff --git a/src/js/broadcast.js b/src/js/broadcast.js index d4293ceb34acb..964465b17b36b 100644 --- a/src/js/broadcast.js +++ b/src/js/broadcast.js @@ -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(( ) => { }); } }