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

Side by Side Diff: chrome/content/tests/elemhide.js

Issue 6439460933730304: Issue 616 - Add tests for $generichide and $genericblock (Closed)
Patch Set: Fixed contentpolicy tests with recent changes to underlying logic Created Sept. 5, 2015, 2:41 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 | chrome/content/tests/filterClasses.js » ('j') | chrome/content/tests/matcher.js » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
99 [["localhost,~foo###test1", "localhost#@##test1"], ["visible", "visible"]], 99 [["localhost,~foo###test1", "localhost#@##test1"], ["visible", "visible"]],
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
110 [["#div(test1)", "@@localhost$generichide"], ["visible", "visible"]],
111 [["#div(test1)", "@@localhost$genericblock"], ["hidden", "visible"]],
112 [["localhost#div(test1)", "@@localhost$generichide"], ["hidden", "visible"]] ,
113 [["~example.com#div(test1)", "@@localhost$generichide"], ["visible", "visibl e"]],
114 [["~example.com#div(test1)", "@@localhost$genericblock"], ["hidden", "visibl e"]],
115 [["~example.com,localhost#div(test1)", "@@localhost$generichide"], ["hidden" , "visible"]],
109 ]; 116 ];
110 117
111 function runTest([filters, expected], stage) 118 function runTest([filters, expected], stage)
112 { 119 {
113 let listener = function(action) 120 let listener = function(action)
114 { 121 {
115 if (action != "elemhideupdate") 122 if (action != "elemhideupdate")
116 return; 123 return;
117 FilterNotifier.removeListener(listener); 124 FilterNotifier.removeListener(listener);
118 125
(...skipping 12 matching lines...) Expand all
131 Utils.runAsync(function() 138 Utils.runAsync(function()
132 { 139 {
133 let doc = frame.contentDocument; 140 let doc = frame.contentDocument;
134 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");
135 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");
136 143
137 start(); 144 start();
138 }); 145 });
139 }, false, true); 146 }, false, true);
140 frame.setAttribute("src", "http://localhost:1234/test"); 147 frame.setAttribute("src", "http://localhost:1234/test");
141 } 148 };
142 FilterNotifier.addListener(listener);
143 149
144 for (let filter of filters) 150 for (let filter of filters)
145 ElemHide.add(Filter.fromText(filter)); 151 if (filter.substr(0, 2) == "@@")
Felix Dahlke 2015/09/28 18:24:07 How I understand it, what you want to check for he
kzar 2015/09/29 11:07:01 Done.
152 defaultMatcher.add(Filter.fromText(filter));
153 else
154 ElemHide.add(Filter.fromText(filter));
155
156 FilterNotifier.addListener(listener);
146 ElemHide.isDirty = true; 157 ElemHide.isDirty = true;
147 ElemHide.apply(); 158 ElemHide.apply();
148 } 159 }
149 160
150 let stageDescriptions = { 161 let stageDescriptions = {
151 1: "running without exceptions", 162 1: "running without exceptions",
152 2: "running with whitelisted document", 163 2: "running with whitelisted document",
153 3: "running with exception not applying to documents", 164 3: "running with exception not applying to documents",
154 4: "running with element hiding exception", 165 4: "running with element hiding exception",
155 }; 166 };
156 167
157 for (let test = 0; test < tests.length; test++) 168 for (let test = 0; test < tests.length; test++)
158 { 169 {
159 let [filters, expected] = tests[test]; 170 let [filters, expected] = tests[test];
160 for (let stage = 1; stage in stageDescriptions; stage++) 171 for (let stage = 1; stage in stageDescriptions; stage++)
161 asyncTest(filters.join(", ") + " (" + stageDescriptions[stage] + ")", runT est.bind(null, tests[test], stage)); 172 asyncTest(filters.join(", ") + " (" + stageDescriptions[stage] + ")", runT est.bind(null, tests[test], stage));
162 } 173 }
163 })(); 174 })();
OLDNEW
« no previous file with comments | « no previous file | chrome/content/tests/filterClasses.js » ('j') | chrome/content/tests/matcher.js » ('J')

Powered by Google App Engine
This is Rietveld