Left: | ||
Right: |
LEFT | RIGHT |
---|---|
1 (function() | 1 (function() |
2 { | 2 { |
3 let server = null; | 3 let server = null; |
4 let frame = null; | 4 let frame = null; |
5 | 5 |
6 module("Element hiding", { | 6 module("Element hiding", { |
7 setup: function() | 7 setup: function() |
8 { | 8 { |
9 prepareFilterComponents.call(this); | 9 prepareFilterComponents.call(this); |
10 preparePrefs.call(this); | 10 preparePrefs.call(this); |
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
100 [["###test1", "foo#@##test1"], ["hidden", "visible"]], | 100 [["###test1", "foo#@##test1"], ["hidden", "visible"]], |
101 [["###test1", "~foo#@##test1"], ["visible", "visible"]], | 101 [["###test1", "~foo#@##test1"], ["visible", "visible"]], |
102 [["###test1", "~localhost#@##test1"], ["hidden", "visible"]], | 102 [["###test1", "~localhost#@##test1"], ["hidden", "visible"]], |
103 [["###test1", "#@##test1"], ["visible", "visible"]], | 103 [["###test1", "#@##test1"], ["visible", "visible"]], |
104 [["localhost###test1", "#@##test1"], ["visible", "visible"]], | 104 [["localhost###test1", "#@##test1"], ["visible", "visible"]], |
105 | 105 |
106 [["localhost.###test1"], ["visible", "visible"]], | 106 [["localhost.###test1"], ["visible", "visible"]], |
107 [["localhost.,localhost###test1"], ["hidden", "visible"]], | 107 [["localhost.,localhost###test1"], ["hidden", "visible"]], |
108 [["localhost.,foo.###test1"], ["visible", "visible"]], | 108 [["localhost.,foo.###test1"], ["visible", "visible"]], |
109 | 109 |
110 [["#div(test1)", "@@localhost$generichide"], ["visible", "visible"]], | 110 [["##div#test1", "@@localhost$generichide"], ["visible", "visible"]], |
111 [["#div(test1)", "@@localhost$genericblock"], ["hidden", "visible"]], | 111 [["##div#test1", "@@localhost$genericblock"], ["hidden", "visible"]], |
112 [["localhost#div(test1)", "@@localhost$generichide"], ["hidden", "visible"]] , | 112 [["localhost##div#test1", "@@localhost$generichide"], ["hidden", "visible"]] , |
113 [["~example.com#div(test1)", "@@localhost$generichide"], ["visible", "visibl e"]], | 113 [["~example.com##div#test1", "@@localhost$generichide"], ["visible", "visibl e"]], |
114 [["~example.com#div(test1)", "@@localhost$genericblock"], ["hidden", "visibl e"]], | 114 [["~example.com##div#test1", "@@localhost$genericblock"], ["hidden", "visibl e"]], |
115 [["~example.com,localhost#div(test1)", "@@localhost$generichide"], ["hidden" , "visible"]], | 115 [["~example.com,localhost##div#test1", "@@localhost$generichide"], ["hidden" , "visible"]], |
116 ]; | 116 ]; |
117 | 117 |
118 function runTest([filters, expected], stage) | 118 function runTest([filters, expected], stage) |
119 { | 119 { |
120 let listener = function(action) | 120 let listener = function(action) |
121 { | 121 { |
122 if (action != "elemhideupdate") | 122 if (action != "elemhideupdate") |
123 return; | 123 return; |
124 FilterNotifier.removeListener(listener); | 124 FilterNotifier.removeListener(listener); |
125 | 125 |
(...skipping 13 matching lines...) Expand all Loading... | |
139 { | 139 { |
140 let doc = frame.contentDocument; | 140 let doc = frame.contentDocument; |
141 equal(doc.getElementById("test1").offsetHeight > 0 ? "visible" : "hidd en", expected[0], "First element visible"); | 141 equal(doc.getElementById("test1").offsetHeight > 0 ? "visible" : "hidd en", expected[0], "First element visible"); |
142 equal(doc.getElementById("test2").offsetHeight > 0 ? "visible" : "hidd en", expected[1], "Second element visible"); | 142 equal(doc.getElementById("test2").offsetHeight > 0 ? "visible" : "hidd en", expected[1], "Second element visible"); |
143 | 143 |
144 start(); | 144 start(); |
145 }); | 145 }); |
146 }, false, true); | 146 }, false, true); |
147 frame.setAttribute("src", "http://localhost:1234/test"); | 147 frame.setAttribute("src", "http://localhost:1234/test"); |
148 }; | 148 }; |
149 FilterNotifier.addListener(listener); | |
149 | 150 |
150 for (let filter of filters) | 151 for (let filter_text of filters) |
151 if (filter.substr(0, 2) == "@@") | 152 { |
Sebastian Noack
2015/03/19 11:58:49
How about using two seperate lists istead this ugl
kzar
2015/03/19 16:24:26
You're right the switch is a little ugly but the a
Sebastian Noack
2015/03/20 09:56:12
You are right, this seems to be consistent with ex
| |
152 defaultMatcher.add(Filter.fromText(filter));//exception_filters.push(fil ter); | 153 let filter = Filter.fromText(filter_text); |
Sebastian Noack
2015/03/19 11:58:49
I suppose you forgot to remove that comment?
kzar
2015/03/19 16:24:26
Done.
| |
154 if (filter instanceof WhitelistFilter) | |
155 defaultMatcher.add(filter); | |
153 else | 156 else |
154 ElemHide.add(Filter.fromText(filter)); | 157 ElemHide.add(filter); |
158 } | |
155 | 159 |
156 FilterNotifier.addListener(listener); | |
157 ElemHide.isDirty = true; | 160 ElemHide.isDirty = true; |
158 ElemHide.apply(); | 161 ElemHide.apply(); |
159 } | 162 } |
160 | 163 |
161 let stageDescriptions = { | 164 let stageDescriptions = { |
162 1: "running without exceptions", | 165 1: "running without exceptions", |
163 2: "running with whitelisted document", | 166 2: "running with whitelisted document", |
164 3: "running with exception not applying to documents", | 167 3: "running with exception not applying to documents", |
165 4: "running with element hiding exception", | 168 4: "running with element hiding exception", |
166 }; | 169 }; |
167 | 170 |
168 for (let test = 0; test < tests.length; test++) | 171 for (let test = 0; test < tests.length; test++) |
169 { | 172 { |
170 let [filters, expected] = tests[test]; | 173 let [filters, expected] = tests[test]; |
171 for (let stage = 1; stage in stageDescriptions; stage++) | 174 for (let stage = 1; stage in stageDescriptions; stage++) |
172 asyncTest(filters.join(", ") + " (" + stageDescriptions[stage] + ")", runT est.bind(null, tests[test], stage)); | 175 asyncTest(filters.join(", ") + " (" + stageDescriptions[stage] + ")", runT est.bind(null, tests[test], stage)); |
173 } | 176 } |
174 })(); | 177 })(); |
LEFT | RIGHT |