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

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

Issue 29378674: Issue 4962 - Fix the tests.- Fix syntax in chrome/content/elemHideEmulation.js to use ES5Regress… (Closed) Base URL: https://hg.adblockplus.org/adblockpluscore
Patch Set: formatting fixes Created March 8, 2017, 12:42 a.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 | test/browser/elemHideEmulation.js » ('j') | test/browser/elemHideEmulation.js » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // We are currently limited to ECMAScript 5 in this file, because it is being 1 // We are currently limited to ECMAScript 5 in this file, because it is being
2 // used in the browser tests. See https://issues.adblockplus.org/ticket/4796 2 // used in the browser tests. See https://issues.adblockplus.org/ticket/4796
3 3
4 var propertySelectorRegExp = /\[\-abp\-properties=(["'])([^"']+)\1\]/; 4 var propertySelectorRegExp = /\[\-abp\-properties=(["'])([^"']+)\1\]/;
5 5
6 function splitSelector(selector) 6 function splitSelector(selector)
7 { 7 {
8 if (selector.indexOf(",") == -1) 8 if (selector.indexOf(",") == -1)
9 return [selector]; 9 return [selector];
10 10
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
76 } 76 }
77 }, 77 },
78 78
79 findSelectors: function(stylesheet, selectors, filters) 79 findSelectors: function(stylesheet, selectors, filters)
80 { 80 {
81 // Explicitly ignore third-party stylesheets to ensure consistent behavior 81 // Explicitly ignore third-party stylesheets to ensure consistent behavior
82 // between Firefox and Chrome. 82 // between Firefox and Chrome.
83 if (!this.isSameOrigin(stylesheet)) 83 if (!this.isSameOrigin(stylesheet))
84 return; 84 return;
85 85
86 let rules = stylesheet.cssRules; 86 var rules = stylesheet.cssRules;
87 if (!rules) 87 if (!rules)
88 return; 88 return;
89 89
90 for (let rule of rules) 90 for (var i = 0; i < rules.length; i++)
91 { 91 {
92 var rule = rules[i];
92 if (rule.type != rule.STYLE_RULE) 93 if (rule.type != rule.STYLE_RULE)
93 continue; 94 continue;
94 95
95 let style = this.stringifyStyle(rule.style); 96 var style = this.stringifyStyle(rule.style);
96 for (let pattern of this.patterns) 97 this.patterns.forEach(function(pattern)
Wladimir Palant 2017/03/08 10:31:50 Last I checked, calling forEach caused suboptimal
97 { 98 {
98 if (pattern.regexp.test(style)) 99 if (pattern.regexp.test(style))
99 { 100 {
100 let subSelectors = splitSelector(rule.selectorText); 101 var subSelectors = splitSelector(rule.selectorText);
101 for (let subSelector of subSelectors) 102 subSelectors.forEach(function(subSelector)
102 { 103 {
103 selectors.push(pattern.prefix + subSelector + pattern.suffix); 104 selectors.push(pattern.prefix + subSelector + pattern.suffix);
104 filters.push(pattern.text); 105 filters.push(pattern.text);
105 } 106 });
106 } 107 }
107 } 108 });
108 } 109 }
109 }, 110 },
110 111
111 addSelectors: function(stylesheets) 112 addSelectors: function(stylesheets)
112 { 113 {
113 var selectors = []; 114 var selectors = [];
114 var filters = []; 115 var filters = [];
115 for (var i = 0; i < stylesheets.length; i++) 116 for (var i = 0; i < stylesheets.length; i++)
116 this.findSelectors(stylesheets[i], selectors, filters); 117 this.findSelectors(stylesheets[i], selectors, filters);
117 this.addSelectorsFunc(selectors, filters); 118 this.addSelectorsFunc(selectors, filters);
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
155 156
156 if (this.patterns.length > 0) 157 if (this.patterns.length > 0)
157 { 158 {
158 var document = this.window.document; 159 var document = this.window.document;
159 this.addSelectors(document.styleSheets); 160 this.addSelectors(document.styleSheets);
160 document.addEventListener("load", this.onLoad.bind(this), true); 161 document.addEventListener("load", this.onLoad.bind(this), true);
161 } 162 }
162 }.bind(this)); 163 }.bind(this));
163 } 164 }
164 }; 165 };
OLDNEW
« no previous file with comments | « no previous file | test/browser/elemHideEmulation.js » ('j') | test/browser/elemHideEmulation.js » ('J')

Powered by Google App Engine
This is Rietveld