Index: lib/cssInjection.js |
=================================================================== |
--- a/lib/cssInjection.js |
+++ b/lib/cssInjection.js |
@@ -71,23 +71,34 @@ |
try |
{ |
browser.tabs.insertCSS(tabId, { |
code: styleSheet, |
cssOrigin: "user", |
frameId, |
matchAboutBlank: true, |
runAt: "document_start" |
- }); |
+ }) |
+ // Some errors are asynchronous (e.g. frame-not-found on Chromium 66). We |
+ // can simply ignore any such errors. |
+ .catch(() => {}); |
} |
catch (error) |
{ |
+ // If the error is about the "cssOrigin" option, this is an older version |
+ // of Chromium (65 and below) or Firefox (52 and below) that does not |
+ // support user style sheets. |
if (/\bcssOrigin\b/.test(error.message)) |
userStyleSheetsSupported = false; |
+ // Sometimes a frame gets removed from the document between the time the |
+ // content script sends the "elemhide.getSelectors" message and the time |
+ // the background page tries to inject a style sheet, which causes |
+ // tabs.insertCSS to throw a frame-not-found error. We must handle any such |
+ // errors. |
return false; |
} |
return true; |
} |
function removeStyleSheet(tabId, frameId, styleSheet) |
{ |