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

Delta Between Two Patch Sets: lib/content/elemHideEmulation.js

Issue 29723684: Issue 6382 - Catch InvalidAccessError exception when checking styles. (Closed) Base URL: https://hg.adblockplus.org/adblockpluscore/
Left Patch Set: Shrink the try{} block Created March 20, 2018, 2:53 p.m.
Right 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:
Left: Side by side diff | Download
Right: Side by side diff | Download
« no previous file with change/comment | « no previous file | no next file » | no next file with change/comment »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
LEFTRIGHT
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 600 matching lines...) Expand 10 before | Expand all | Expand 10 after
611 let rules; 611 let rules;
612 try 612 try
613 { 613 {
614 rules = stylesheet.cssRules; 614 rules = stylesheet.cssRules;
615 } 615 }
616 catch (e) 616 catch (e)
617 { 617 {
618 // On Firefox, there is a chance that an InvalidAccessError 618 // On Firefox, there is a chance that an InvalidAccessError
619 // get thrown when accessing cssRules. Just skip the stylesheet 619 // get thrown when accessing cssRules. Just skip the stylesheet
620 // in that case. 620 // in that case.
621 // See https://issues.adblockplus.org/ticket/6382 621 // See https://searchfox.org/mozilla-central/rev/f65d7528e34ef1a7665b4a1 a7b7cdb1388fcd3aa/layout/style/StyleSheet.cpp#699
622 continue; 622 continue;
kzar 2018/04/18 16:12:30 I wonder if we should check that the exception rea
hub 2018/04/18 18:48:23 The intent here is to catch the exception to not i
kzar 2018/04/19 07:29:29 Acknowledged.
623 } 623 }
624 624
625 if (!rules) 625 if (!rules)
626 continue; 626 continue;
627 627
628 for (let rule of rules) 628 for (let rule of rules)
629 { 629 {
630 if (rule.type != rule.STYLE_RULE) 630 if (rule.type != rule.STYLE_RULE)
631 continue; 631 continue;
632 632
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
729 this.queueFiltering(params.stylesheets, params.mutations); 729 this.queueFiltering(params.stylesheets, params.mutations);
730 } 730 }
731 }; 731 };
732 732
733 if (this._scheduledProcessing) 733 if (this._scheduledProcessing)
734 { 734 {
735 if (!stylesheets && !mutations) 735 if (!stylesheets && !mutations)
736 { 736 {
737 this._scheduledProcessing = {}; 737 this._scheduledProcessing = {};
738 } 738 }
739 else 739 else if (this._scheduledProcessing.stylesheets ||
740 this._scheduledProcessing.mutations)
740 { 741 {
741 if (stylesheets) 742 if (stylesheets)
742 { 743 {
743 if (!this._scheduledProcessing.stylesheets) 744 if (!this._scheduledProcessing.stylesheets)
744 this._scheduledProcessing.stylesheets = []; 745 this._scheduledProcessing.stylesheets = [];
745 this._scheduledProcessing.stylesheets.push(...stylesheets); 746 this._scheduledProcessing.stylesheets.push(...stylesheets);
746 } 747 }
747 if (mutations) 748 if (mutations)
748 { 749 {
749 if (!this._scheduledProcessing.mutations) 750 if (!this._scheduledProcessing.mutations)
(...skipping 16 matching lines...) Expand all
766 this._scheduledProcessing = null; 767 this._scheduledProcessing = null;
767 this._addSelectors(params.stylesheets, params.mutations, completion); 768 this._addSelectors(params.stylesheets, params.mutations, completion);
768 }, 769 },
769 MIN_INVOCATION_INTERVAL - (performance.now() - this._lastInvocation)); 770 MIN_INVOCATION_INTERVAL - (performance.now() - this._lastInvocation));
770 } 771 }
771 else if (this.document.readyState == "loading") 772 else if (this.document.readyState == "loading")
772 { 773 {
773 this._scheduledProcessing = {stylesheets, mutations}; 774 this._scheduledProcessing = {stylesheets, mutations};
774 let handler = () => 775 let handler = () =>
775 { 776 {
776 document.removeEventListener("DOMContentLoaded", handler); 777 this.document.removeEventListener("DOMContentLoaded", handler);
777 let params = Object.assign({}, this._scheduledProcessing); 778 let params = Object.assign({}, this._scheduledProcessing);
778 this._filteringInProgress = true; 779 this._filteringInProgress = true;
779 this._scheduledProcessing = null; 780 this._scheduledProcessing = null;
780 this._addSelectors(params.stylesheets, params.mutations, completion); 781 this._addSelectors(params.stylesheets, params.mutations, completion);
781 }; 782 };
782 document.addEventListener("DOMContentLoaded", handler); 783 this.document.addEventListener("DOMContentLoaded", handler);
783 } 784 }
784 else 785 else
785 { 786 {
786 this._filteringInProgress = true; 787 this._filteringInProgress = true;
787 this._addSelectors(stylesheets, mutations, completion); 788 this._addSelectors(stylesheets, mutations, completion);
788 } 789 }
789 }, 790 },
790 791
791 onLoad(event) 792 onLoad(event)
792 { 793 {
(...skipping 28 matching lines...) Expand all
821 characterData: shouldObserveCharacterData(this.patterns), 822 characterData: shouldObserveCharacterData(this.patterns),
822 subtree: true 823 subtree: true
823 } 824 }
824 ); 825 );
825 this.document.addEventListener("load", this.onLoad.bind(this), true); 826 this.document.addEventListener("load", this.onLoad.bind(this), true);
826 } 827 }
827 } 828 }
828 }; 829 };
829 830
830 exports.ElemHideEmulation = ElemHideEmulation; 831 exports.ElemHideEmulation = ElemHideEmulation;
LEFTRIGHT
« no previous file | no next file » | Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Toggle Comments ('s')

Powered by Google App Engine
This is Rietveld