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

Side by Side Diff: lib/content/elemHideEmulation.js

Issue 29590629: Issue 5956 - Catch exception when enumerating stylesheets (Closed) Base URL: https://hg.adblockplus.org/adblockpluscore/
Patch Set: Created Oct. 27, 2017, 11:27 p.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * This file is part of Adblock Plus <https://adblockplus.org/>, 2 * This file is part of Adblock Plus <https://adblockplus.org/>,
3 * Copyright (C) 2006-present eyeo GmbH 3 * Copyright (C) 2006-present eyeo GmbH
4 * 4 *
5 * Adblock Plus is free software: you can redistribute it and/or modify 5 * Adblock Plus is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License version 3 as 6 * it under the terms of the GNU General Public License version 3 as
7 * published by the Free Software Foundation. 7 * published by the Free Software Foundation.
8 * 8 *
9 * Adblock Plus is distributed in the hope that it will be useful, 9 * Adblock Plus is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
(...skipping 393 matching lines...) Expand 10 before | Expand all | Expand 10 after
404 404
405 let elements = []; 405 let elements = [];
406 let elementFilters = []; 406 let elementFilters = [];
407 407
408 let cssStyles = []; 408 let cssStyles = [];
409 409
410 let stylesheetOnlyChange = !!stylesheets; 410 let stylesheetOnlyChange = !!stylesheets;
411 if (!stylesheets) 411 if (!stylesheets)
412 stylesheets = this.document.styleSheets; 412 stylesheets = this.document.styleSheets;
413 413
414 for (let stylesheet of stylesheets) 414 try
415 { 415 {
416 // Explicitly ignore third-party stylesheets to ensure consistent behavior 416 for (let stylesheet of stylesheets)
417 // between Firefox and Chrome.
418 if (!this.isSameOrigin(stylesheet))
419 continue;
420
421 let rules = stylesheet.cssRules;
422 if (!rules)
423 continue;
424
425 for (let rule of rules)
426 { 417 {
427 if (rule.type != rule.STYLE_RULE) 418 // Explicitly ignore third-party stylesheets to ensure consistent behavi or
419 // between Firefox and Chrome.
420 if (!this.isSameOrigin(stylesheet))
428 continue; 421 continue;
429 422
430 cssStyles.push(stringifyStyle(rule)); 423 let rules = stylesheet.cssRules;
424 if (!rules)
425 continue;
426
427 for (let rule of rules)
428 {
429 if (rule.type != rule.STYLE_RULE)
430 continue;
431
432 cssStyles.push(stringifyStyle(rule));
433 }
431 } 434 }
432 } 435 }
436 catch (e)
437 {
438 // Make sure to not interrupt.
439 // On Firefox we seem to get a InvalidAccessError when
440 // enumerating the stylesheets.
441 }
433 442
434 let patterns = this.patterns.slice(); 443 let patterns = this.patterns.slice();
435 let pattern = null; 444 let pattern = null;
436 let generator = null; 445 let generator = null;
437 446
438 let processPatterns = () => 447 let processPatterns = () =>
439 { 448 {
440 let cycleStart = performance.now(); 449 let cycleStart = performance.now();
441 450
442 if (!pattern) 451 if (!pattern)
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after
591 characterData: true, 600 characterData: true,
592 subtree: true 601 subtree: true
593 } 602 }
594 ); 603 );
595 this.document.addEventListener("load", this.onLoad.bind(this), true); 604 this.document.addEventListener("load", this.onLoad.bind(this), true);
596 } 605 }
597 } 606 }
598 }; 607 };
599 608
600 exports.ElemHideEmulation = ElemHideEmulation; 609 exports.ElemHideEmulation = ElemHideEmulation;
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld