Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Unified Diff: lib/cssInjection.js

Issue 29720585: Noissue - Explicitly ignore asynchronous errors from tabs.insertCSS (Closed) Base URL: https://hg.adblockplus.org/adblockpluschrome/
Patch Set: Add comments Created March 13, 2018, 5:11 p.m.
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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)
{
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld