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: Created March 7, 2017, 6:33 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 | test/browser/elemHideEmulation.js » ('j') | no next file with comments »
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) {
97 {
98 if (pattern.regexp.test(style)) 98 if (pattern.regexp.test(style))
99 { 99 {
100 let subSelectors = splitSelector(rule.selectorText); 100 var subSelectors = splitSelector(rule.selectorText);
101 for (let subSelector of subSelectors) 101 subSelectors.forEach(function(subSelector) {
102 {
103 selectors.push(pattern.prefix + subSelector + pattern.suffix); 102 selectors.push(pattern.prefix + subSelector + pattern.suffix);
104 filters.push(pattern.text); 103 filters.push(pattern.text);
105 } 104 });
106 } 105 }
107 } 106 });
108 } 107 }
109 }, 108 },
110 109
111 addSelectors: function(stylesheets) 110 addSelectors: function(stylesheets)
112 { 111 {
113 var selectors = []; 112 var selectors = [];
114 var filters = []; 113 var filters = [];
115 for (var i = 0; i < stylesheets.length; i++) 114 for (var i = 0; i < stylesheets.length; i++)
116 this.findSelectors(stylesheets[i], selectors, filters); 115 this.findSelectors(stylesheets[i], selectors, filters);
117 this.addSelectorsFunc(selectors, filters); 116 this.addSelectorsFunc(selectors, filters);
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
155 154
156 if (this.patterns.length > 0) 155 if (this.patterns.length > 0)
157 { 156 {
158 var document = this.window.document; 157 var document = this.window.document;
159 this.addSelectors(document.styleSheets); 158 this.addSelectors(document.styleSheets);
160 document.addEventListener("load", this.onLoad.bind(this), true); 159 document.addEventListener("load", this.onLoad.bind(this), true);
161 } 160 }
162 }.bind(this)); 161 }.bind(this));
163 } 162 }
164 }; 163 };
OLDNEW
« no previous file with comments | « no previous file | test/browser/elemHideEmulation.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld