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: Update comment Created March 13, 2018, 5:41 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,36 @@
try
{
browser.tabs.insertCSS(tabId, {
code: styleSheet,
cssOrigin: "user",
frameId,
matchAboutBlank: true,
runAt: "document_start"
- });
+ })
+ // Some errors on Chromium are asynchronous promise rejections
+ // (e.g. "Error: No frame with id 574 in tab 266"). We explicitly ignore
+ // these, because otherwise they show up in the log too often and make
+ // debugging difficult.
+ .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.
Sebastian Noack 2018/03/13 18:40:58 This is only the case on Firefox, while Chromium g
Manish Jethani 2018/03/13 22:08:38 Done.
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