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

Unified Diff: lib/content/elemHideEmulation.js

Issue 29590629: Issue 5956 - Catch exception when enumerating stylesheets (Closed) Base URL: https://hg.adblockplus.org/adblockpluscore/
Patch Set: Catch the exceptions inside too Created Oct. 30, 2017, 7:25 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/content/elemHideEmulation.js
===================================================================
--- a/lib/content/elemHideEmulation.js
+++ b/lib/content/elemHideEmulation.js
@@ -406,35 +406,51 @@
let elementFilters = [];
let cssStyles = [];
let stylesheetOnlyChange = !!stylesheets;
if (!stylesheets)
stylesheets = this.document.styleSheets;
- for (let stylesheet of stylesheets)
+ try
{
- // Explicitly ignore third-party stylesheets to ensure consistent behavior
- // between Firefox and Chrome.
- if (!this.isSameOrigin(stylesheet))
- continue;
+ for (let stylesheet of stylesheets)
+ {
+ try
+ {
+ // Explicitly ignore third-party stylesheets to ensure consistent behavior
kzar 2017/11/03 10:20:50 Nit: This line is too long, did you check the code
+ // between Firefox and Chrome.
+ if (!this.isSameOrigin(stylesheet))
+ continue;
+
+ let rules = stylesheet.cssRules;
+ if (!rules)
+ continue;
- let rules = stylesheet.cssRules;
- if (!rules)
- continue;
+ for (let rule of rules)
+ {
+ if (rule.type != rule.STYLE_RULE)
+ continue;
- for (let rule of rules)
- {
- if (rule.type != rule.STYLE_RULE)
- continue;
-
- cssStyles.push(stringifyStyle(rule));
+ cssStyles.push(stringifyStyle(rule));
+ }
+ }
+ catch (e)
+ {
+ // On Firefox we seem to get a InvalidAccessError when
kzar 2017/11/03 10:20:50 Nit: "...get an...".
+ // accessing the stylesheet under some circumstances.
+ }
}
}
+ catch (e)
+ {
+ // On Firefox we seem to get a InvalidAccessError when
kzar 2017/11/03 10:20:50 Maybe combine these two identical comments and add
+ // enumerating the stylesheet under some circumstances.
+ }
let patterns = this.patterns.slice();
let pattern = null;
let generator = null;
let processPatterns = () =>
{
let cycleStart = performance.now();
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld