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

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

Issue 29723684: Issue 6382 - Catch InvalidAccessError exception when checking styles. (Closed) Base URL: https://hg.adblockplus.org/adblockpluscore/
Patch Set: Created March 15, 2018, 9:43 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 508 matching lines...) Expand 10 before | Expand all | Expand 10 after
519 if (!stylesheets) 519 if (!stylesheets)
520 stylesheets = this.document.styleSheets; 520 stylesheets = this.document.styleSheets;
521 521
522 for (let stylesheet of stylesheets) 522 for (let stylesheet of stylesheets)
523 { 523 {
524 // Explicitly ignore third-party stylesheets to ensure consistent behavior 524 // Explicitly ignore third-party stylesheets to ensure consistent behavior
525 // between Firefox and Chrome. 525 // between Firefox and Chrome.
526 if (!this.isSameOrigin(stylesheet)) 526 if (!this.isSameOrigin(stylesheet))
527 continue; 527 continue;
528 528
529 let rules = stylesheet.cssRules; 529 try
530 if (!rules)
531 continue;
532
533 for (let rule of rules)
534 { 530 {
535 if (rule.type != rule.STYLE_RULE) 531 let rules = stylesheet.cssRules;
kzar 2018/03/19 15:52:07 If this is the only line that could cause the exce
hub 2018/03/20 14:53:53 Done.
532 if (!rules)
536 continue; 533 continue;
537 534
538 cssStyles.push(stringifyStyle(rule)); 535 for (let rule of rules)
536 {
537 if (rule.type != rule.STYLE_RULE)
538 continue;
539
540 cssStyles.push(stringifyStyle(rule));
541 }
542 }
543 catch (e)
544 {
545 // On Firefox, there is a chance that an InvalidAccessError
kzar 2018/03/19 15:52:07 How come this happens? Is there a Firefox bug / di
hub 2018/03/20 16:16:02 It's not a bug. https://searchfox.org/mozilla-cen
kzar 2018/04/18 16:12:30 Acknowledged. In fact that link you gave is prett
hub 2018/04/18 18:48:23 Done.
546 // get thrown when accessing cssRules. Just skip the stylesheet
547 // in that case.
548 // See https://issues.adblockplus.org/ticket/6382
549 continue;
539 } 550 }
540 } 551 }
541 552
542 let patterns = this.patterns.slice(); 553 let patterns = this.patterns.slice();
543 let pattern = null; 554 let pattern = null;
544 let generator = null; 555 let generator = null;
545 556
546 let processPatterns = () => 557 let processPatterns = () =>
547 { 558 {
548 let cycleStart = performance.now(); 559 let cycleStart = performance.now();
(...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after
712 characterData: shouldObserveCharacterData(this.patterns), 723 characterData: shouldObserveCharacterData(this.patterns),
713 subtree: true 724 subtree: true
714 } 725 }
715 ); 726 );
716 this.document.addEventListener("load", this.onLoad.bind(this), true); 727 this.document.addEventListener("load", this.onLoad.bind(this), true);
717 } 728 }
718 } 729 }
719 }; 730 };
720 731
721 exports.ElemHideEmulation = ElemHideEmulation; 732 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