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: Link to the code to explain the exception Created April 18, 2018, 6:47 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 590 matching lines...) Expand 10 before | Expand all | Expand 10 after
601 if (mutations && patterns.some(pattern => pattern.dependsOnStylesAndDOM)) 601 if (mutations && patterns.some(pattern => pattern.dependsOnStylesAndDOM))
602 stylesheets = this.document.styleSheets; 602 stylesheets = this.document.styleSheets;
603 603
604 for (let stylesheet of stylesheets || []) 604 for (let stylesheet of stylesheets || [])
605 { 605 {
606 // Explicitly ignore third-party stylesheets to ensure consistent behavior 606 // Explicitly ignore third-party stylesheets to ensure consistent behavior
607 // between Firefox and Chrome. 607 // between Firefox and Chrome.
608 if (!this.isSameOrigin(stylesheet)) 608 if (!this.isSameOrigin(stylesheet))
609 continue; 609 continue;
610 610
611 let rules = stylesheet.cssRules; 611 let rules;
612 try
613 {
614 rules = stylesheet.cssRules;
615 }
616 catch (e)
617 {
618 // On Firefox, there is a chance that an InvalidAccessError
619 // get thrown when accessing cssRules. Just skip the stylesheet
620 // in that case.
621 // See https://searchfox.org/mozilla-central/rev/f65d7528e34ef1a7665b4a1 a7b7cdb1388fcd3aa/layout/style/StyleSheet.cpp#699
622 continue;
623 }
624
612 if (!rules) 625 if (!rules)
613 continue; 626 continue;
614 627
615 for (let rule of rules) 628 for (let rule of rules)
616 { 629 {
617 if (rule.type != rule.STYLE_RULE) 630 if (rule.type != rule.STYLE_RULE)
618 continue; 631 continue;
619 632
620 cssStyles.push(stringifyStyle(rule)); 633 cssStyles.push(stringifyStyle(rule));
621 } 634 }
(...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after
809 characterData: shouldObserveCharacterData(this.patterns), 822 characterData: shouldObserveCharacterData(this.patterns),
810 subtree: true 823 subtree: true
811 } 824 }
812 ); 825 );
813 this.document.addEventListener("load", this.onLoad.bind(this), true); 826 this.document.addEventListener("load", this.onLoad.bind(this), true);
814 } 827 }
815 } 828 }
816 }; 829 };
817 830
818 exports.ElemHideEmulation = ElemHideEmulation; 831 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