| Left: | ||
| Right: |
| LEFT | RIGHT |
|---|---|
| 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 |
| 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 12 * GNU General Public License for more details. | 12 * GNU General Public License for more details. |
| 13 * | 13 * |
| 14 * You should have received a copy of the GNU General Public License | 14 * You should have received a copy of the GNU General Public License |
| 15 * along with Adblock Plus. If not, see <http://www.gnu.org/licenses/>. | 15 * along with Adblock Plus. If not, see <http://www.gnu.org/licenses/>. |
| 16 */ | 16 */ |
| 17 | 17 |
| 18 "use strict"; | 18 "use strict"; |
| 19 | 19 |
| 20 const {createSandbox} = require("./_common"); | 20 const {createSandbox} = require("./_common"); |
| 21 const {withNAD} = require("./_test-utils"); | |
| 21 | 22 |
| 22 let ElemHide = null; | 23 let ElemHide = null; |
| 23 let Filter = null; | 24 let Filter = null; |
| 24 | 25 |
| 25 exports.setUp = function(callback) | 26 exports.setUp = function(callback) |
| 26 { | 27 { |
| 27 let sandboxedRequire = createSandbox(); | 28 let sandboxedRequire = createSandbox(); |
| 28 ( | 29 ( |
| 29 {ElemHide} = sandboxedRequire("../lib/elemHide"), | 30 {ElemHide} = sandboxedRequire("../lib/elemHide"), |
| 30 {Filter} = sandboxedRequire("../lib/filterClasses") | 31 {Filter} = sandboxedRequire("../lib/filterClasses") |
| (...skipping 28 matching lines...) Expand all Loading... | |
| 59 let normalizedExpectedSelectors = normalizeSelectors(expectedSelectors); | 60 let normalizedExpectedSelectors = normalizeSelectors(expectedSelectors); |
| 60 | 61 |
| 61 test.deepEqual( | 62 test.deepEqual( |
| 62 normalizeSelectors(elemHide.getSelectorsForDomain(domain, criteria)), | 63 normalizeSelectors(elemHide.getSelectorsForDomain(domain, criteria)), |
| 63 normalizedExpectedSelectors | 64 normalizedExpectedSelectors |
| 64 ); | 65 ); |
| 65 } | 66 } |
| 66 | 67 |
| 67 exports.testGetSelectorsForDomain = function(test) | 68 exports.testGetSelectorsForDomain = function(test) |
| 68 { | 69 { |
| 69 let elemHide = ElemHide.create(); | 70 withNAD(0, elemHide => |
| 70 | 71 { |
| 71 let addFilter = filterText => elemHide.add(Filter.fromText(filterText)); | 72 let addFilter = filterText => withNAD( |
| 72 let removeFilter = filterText => elemHide.remove(Filter.fromText(filterText)); | 73 0, filter => elemHide.add(filter))(Filter.fromText(filterText)); |
| 73 | 74 let removeFilter = filterText => withNAD( |
| 74 testResult(test, elemHide, "", []); | 75 0, filter => elemHide.remove(filter))(Filter.fromText(filterText)); |
| 75 | 76 |
| 76 addFilter("~foo.example.com,example.com##foo"); | 77 testResult(test, elemHide, "", []); |
| 77 testResult(test, elemHide, "barfoo.example.com", ["foo"]); | 78 |
| 78 testResult(test, elemHide, "bar.foo.example.com", []); | 79 addFilter("~foo.example.com,example.com##foo"); |
| 79 testResult(test, elemHide, "foo.example.com", []); | 80 testResult(test, elemHide, "barfoo.example.com", ["foo"]); |
| 80 testResult(test, elemHide, "example.com", ["foo"]); | 81 testResult(test, elemHide, "bar.foo.example.com", []); |
| 81 testResult(test, elemHide, "com", []); | 82 testResult(test, elemHide, "foo.example.com", []); |
| 82 testResult(test, elemHide, "", []); | 83 testResult(test, elemHide, "example.com", ["foo"]); |
| 83 | 84 testResult(test, elemHide, "com", []); |
| 84 addFilter("foo.example.com##turnip"); | 85 testResult(test, elemHide, "", []); |
| 85 testResult(test, elemHide, "foo.example.com", ["turnip"]); | 86 |
| 86 testResult(test, elemHide, "example.com", ["foo"]); | 87 addFilter("foo.example.com##turnip"); |
| 87 testResult(test, elemHide, "com", []); | 88 testResult(test, elemHide, "foo.example.com", ["turnip"]); |
| 88 testResult(test, elemHide, "", []); | 89 testResult(test, elemHide, "example.com", ["foo"]); |
| 89 | 90 testResult(test, elemHide, "com", []); |
| 90 addFilter("example.com#@#foo"); | 91 testResult(test, elemHide, "", []); |
| 91 testResult(test, elemHide, "foo.example.com", ["turnip"]); | 92 |
| 92 testResult(test, elemHide, "example.com", []); | 93 addFilter("example.com#@#foo"); |
| 93 testResult(test, elemHide, "com", []); | 94 testResult(test, elemHide, "foo.example.com", ["turnip"]); |
| 94 testResult(test, elemHide, "", []); | 95 testResult(test, elemHide, "example.com", []); |
| 95 | 96 testResult(test, elemHide, "com", []); |
| 96 addFilter("com##bar"); | 97 testResult(test, elemHide, "", []); |
| 97 testResult(test, elemHide, "foo.example.com", ["turnip", "bar"]); | 98 |
| 98 testResult(test, elemHide, "example.com", ["bar"]); | 99 addFilter("com##bar"); |
| 99 testResult(test, elemHide, "com", ["bar"]); | 100 testResult(test, elemHide, "foo.example.com", ["turnip", "bar"]); |
| 100 testResult(test, elemHide, "", []); | 101 testResult(test, elemHide, "example.com", ["bar"]); |
| 101 | 102 testResult(test, elemHide, "com", ["bar"]); |
| 102 addFilter("example.com#@#bar"); | 103 testResult(test, elemHide, "", []); |
| 103 testResult(test, elemHide, "foo.example.com", ["turnip"]); | 104 |
| 104 testResult(test, elemHide, "example.com", []); | 105 addFilter("example.com#@#bar"); |
| 105 testResult(test, elemHide, "com", ["bar"]); | 106 testResult(test, elemHide, "foo.example.com", ["turnip"]); |
| 106 testResult(test, elemHide, "", []); | 107 testResult(test, elemHide, "example.com", []); |
| 107 | 108 testResult(test, elemHide, "com", ["bar"]); |
| 108 removeFilter("example.com#@#foo"); | 109 testResult(test, elemHide, "", []); |
| 109 testResult(test, elemHide, "foo.example.com", ["turnip"]); | 110 |
| 110 testResult(test, elemHide, "example.com", ["foo"]); | 111 removeFilter("example.com#@#foo"); |
| 111 testResult(test, elemHide, "com", ["bar"]); | 112 testResult(test, elemHide, "foo.example.com", ["turnip"]); |
| 112 testResult(test, elemHide, "", []); | 113 testResult(test, elemHide, "example.com", ["foo"]); |
| 113 | 114 testResult(test, elemHide, "com", ["bar"]); |
| 114 removeFilter("example.com#@#bar"); | 115 testResult(test, elemHide, "", []); |
| 115 testResult(test, elemHide, "foo.example.com", ["turnip", "bar"]); | 116 |
| 116 testResult(test, elemHide, "example.com", ["foo", "bar"]); | 117 removeFilter("example.com#@#bar"); |
| 117 testResult(test, elemHide, "com", ["bar"]); | 118 testResult(test, elemHide, "foo.example.com", ["turnip", "bar"]); |
| 118 testResult(test, elemHide, "", []); | 119 testResult(test, elemHide, "example.com", ["foo", "bar"]); |
| 119 | 120 testResult(test, elemHide, "com", ["bar"]); |
| 120 addFilter("##generic"); | 121 testResult(test, elemHide, "", []); |
| 121 testResult(test, elemHide, "foo.example.com", ["turnip", "bar", "generic"]); | 122 |
| 122 testResult(test, elemHide, "example.com", ["foo", "bar", "generic"]); | 123 addFilter("##generic"); |
| 123 testResult(test, elemHide, "com", ["bar", "generic"]); | 124 testResult(test, elemHide, "foo.example.com", ["turnip", "bar", "generic"]); |
| 124 testResult(test, elemHide, "", ["generic"]); | 125 testResult(test, elemHide, "example.com", ["foo", "bar", "generic"]); |
| 125 testResult(test, elemHide, "foo.example.com", ["turnip", "bar"], ElemHide.SPEC IFIC_ONLY); | 126 testResult(test, elemHide, "com", ["bar", "generic"]); |
| 126 testResult(test, elemHide, "example.com", ["foo", "bar"], ElemHide.SPECIFIC_ON LY); | 127 testResult(test, elemHide, "", ["generic"]); |
| 127 testResult(test, elemHide, "com", ["bar"], ElemHide.SPECIFIC_ONLY); | 128 testResult(test, elemHide, "foo.example.com", ["turnip", "bar"], ElemHide.SP ECIFIC_ONLY); |
| 128 testResult(test, elemHide, "", [], ElemHide.SPECIFIC_ONLY); | 129 testResult(test, elemHide, "example.com", ["foo", "bar"], ElemHide.SPECIFIC_ ONLY); |
| 129 removeFilter("##generic"); | 130 testResult(test, elemHide, "com", ["bar"], ElemHide.SPECIFIC_ONLY); |
| 130 | 131 testResult(test, elemHide, "", [], ElemHide.SPECIFIC_ONLY); |
| 131 addFilter("~adblockplus.org##example"); | 132 removeFilter("##generic"); |
| 132 testResult(test, elemHide, "adblockplus.org", []); | 133 |
| 133 testResult(test, elemHide, "", ["example"]); | 134 addFilter("~adblockplus.org##example"); |
| 134 testResult(test, elemHide, "foo.example.com", ["turnip", "bar", "example"]); | 135 testResult(test, elemHide, "adblockplus.org", []); |
| 135 testResult(test, elemHide, "foo.example.com", ["turnip", "bar"], ElemHide.SPEC IFIC_ONLY); | 136 testResult(test, elemHide, "", ["example"]); |
| 136 removeFilter("~adblockplus.org##example"); | 137 testResult(test, elemHide, "foo.example.com", ["turnip", "bar", "example"]); |
| 137 | 138 testResult(test, elemHide, "foo.example.com", ["turnip", "bar"], ElemHide.SP ECIFIC_ONLY); |
| 138 removeFilter("~foo.example.com,example.com##foo"); | 139 removeFilter("~adblockplus.org##example"); |
| 139 testResult(test, elemHide, "foo.example.com", ["turnip", "bar"]); | 140 |
| 140 testResult(test, elemHide, "example.com", ["bar"]); | 141 removeFilter("~foo.example.com,example.com##foo"); |
| 141 testResult(test, elemHide, "com", ["bar"]); | 142 testResult(test, elemHide, "foo.example.com", ["turnip", "bar"]); |
| 142 testResult(test, elemHide, "", []); | 143 testResult(test, elemHide, "example.com", ["bar"]); |
| 143 | 144 testResult(test, elemHide, "com", ["bar"]); |
| 144 removeFilter("com##bar"); | 145 testResult(test, elemHide, "", []); |
| 145 testResult(test, elemHide, "foo.example.com", ["turnip"]); | 146 |
| 146 testResult(test, elemHide, "example.com", []); | 147 removeFilter("com##bar"); |
| 147 testResult(test, elemHide, "com", []); | 148 testResult(test, elemHide, "foo.example.com", ["turnip"]); |
| 148 testResult(test, elemHide, "", []); | 149 testResult(test, elemHide, "example.com", []); |
| 149 | 150 testResult(test, elemHide, "com", []); |
| 150 removeFilter("foo.example.com##turnip"); | 151 testResult(test, elemHide, "", []); |
| 151 testResult(test, elemHide, "foo.example.com", []); | 152 |
| 152 testResult(test, elemHide, "example.com", []); | 153 removeFilter("foo.example.com##turnip"); |
| 153 testResult(test, elemHide, "com", []); | 154 testResult(test, elemHide, "foo.example.com", []); |
| 154 testResult(test, elemHide, "", []); | 155 testResult(test, elemHide, "example.com", []); |
| 155 | 156 testResult(test, elemHide, "com", []); |
| 156 addFilter("example.com##dupe"); | 157 testResult(test, elemHide, "", []); |
| 157 addFilter("example.com##dupe"); | 158 |
| 158 testResult(test, elemHide, "example.com", ["dupe"]); | 159 addFilter("example.com##dupe"); |
| 159 removeFilter("example.com##dupe"); | 160 addFilter("example.com##dupe"); |
| 160 testResult(test, elemHide, "example.com", []); | 161 testResult(test, elemHide, "example.com", ["dupe"]); |
| 161 removeFilter("example.com##dupe"); | 162 removeFilter("example.com##dupe"); |
| 162 | 163 testResult(test, elemHide, "example.com", []); |
| 163 addFilter("~foo.example.com,example.com##foo"); | 164 removeFilter("example.com##dupe"); |
| 164 | 165 |
| 165 addFilter("##foo"); | 166 addFilter("~foo.example.com,example.com##foo"); |
| 166 testResult(test, elemHide, "foo.example.com", ["foo"]); | 167 |
| 167 testResult(test, elemHide, "example.com", ["foo"]); | 168 addFilter("##foo"); |
| 168 testResult(test, elemHide, "com", ["foo"]); | 169 testResult(test, elemHide, "foo.example.com", ["foo"]); |
| 169 testResult(test, elemHide, "", ["foo"]); | 170 testResult(test, elemHide, "example.com", ["foo"]); |
| 170 removeFilter("##foo"); | 171 testResult(test, elemHide, "com", ["foo"]); |
| 171 | 172 testResult(test, elemHide, "", ["foo"]); |
| 172 addFilter("example.org##foo"); | 173 removeFilter("##foo"); |
| 173 testResult(test, elemHide, "foo.example.com", []); | 174 |
| 174 testResult(test, elemHide, "example.com", ["foo"]); | 175 addFilter("example.org##foo"); |
| 175 testResult(test, elemHide, "com", []); | 176 testResult(test, elemHide, "foo.example.com", []); |
| 176 testResult(test, elemHide, "", []); | 177 testResult(test, elemHide, "example.com", ["foo"]); |
| 177 removeFilter("example.org##foo"); | 178 testResult(test, elemHide, "com", []); |
| 178 | 179 testResult(test, elemHide, "", []); |
| 179 addFilter("~example.com##foo"); | 180 removeFilter("example.org##foo"); |
| 180 testResult(test, elemHide, "foo.example.com", []); | 181 |
| 181 testResult(test, elemHide, "example.com", ["foo"]); | 182 addFilter("~example.com##foo"); |
| 182 testResult(test, elemHide, "com", ["foo"]); | 183 testResult(test, elemHide, "foo.example.com", []); |
| 183 testResult(test, elemHide, "", ["foo"]); | 184 testResult(test, elemHide, "example.com", ["foo"]); |
| 184 removeFilter("~example.com##foo"); | 185 testResult(test, elemHide, "com", ["foo"]); |
| 185 | 186 testResult(test, elemHide, "", ["foo"]); |
| 186 removeFilter("~foo.example.com,example.com##foo"); | 187 removeFilter("~example.com##foo"); |
| 187 | 188 |
| 188 // Test criteria | 189 removeFilter("~foo.example.com,example.com##foo"); |
| 189 addFilter("##hello"); | 190 |
| 190 addFilter("~example.com##world"); | 191 // Test criteria |
| 191 addFilter("foo.com##specific"); | 192 addFilter("##hello"); |
| 192 testResult(test, elemHide, "foo.com", ["specific"], ElemHide.SPECIFIC_ONLY); | 193 addFilter("~example.com##world"); |
| 193 testResult(test, elemHide, "foo.com", ["specific", "world"], ElemHide.NO_UNCON DITIONAL); | 194 addFilter("foo.com##specific"); |
| 194 testResult(test, elemHide, "foo.com", ["hello", "specific", "world"], ElemHide .ALL_MATCHING); | 195 testResult(test, elemHide, "foo.com", ["specific"], ElemHide.SPECIFIC_ONLY); |
| 195 testResult(test, elemHide, "foo.com", ["hello", "specific", "world"]); | 196 testResult(test, elemHide, "foo.com", ["specific", "world"], ElemHide.NO_UNC ONDITIONAL); |
| 196 removeFilter("foo.com##specific"); | 197 testResult(test, elemHide, "foo.com", ["hello", "specific", "world"], ElemHi de.ALL_MATCHING); |
| 197 removeFilter("~example.com##world"); | 198 testResult(test, elemHide, "foo.com", ["hello", "specific", "world"]); |
| 198 removeFilter("##hello"); | 199 removeFilter("foo.com##specific"); |
| 199 testResult(test, elemHide, "foo.com", []); | 200 removeFilter("~example.com##world"); |
| 200 | 201 removeFilter("##hello"); |
| 201 addFilter("##hello"); | 202 testResult(test, elemHide, "foo.com", []); |
| 202 testResult(test, elemHide, "foo.com", [], ElemHide.SPECIFIC_ONLY); | 203 |
| 203 testResult(test, elemHide, "foo.com", [], ElemHide.NO_UNCONDITIONAL); | 204 addFilter("##hello"); |
| 204 testResult(test, elemHide, "foo.com", ["hello"], ElemHide.ALL_MATCHING); | 205 testResult(test, elemHide, "foo.com", [], ElemHide.SPECIFIC_ONLY); |
| 205 testResult(test, elemHide, "foo.com", ["hello"]); | 206 testResult(test, elemHide, "foo.com", [], ElemHide.NO_UNCONDITIONAL); |
| 206 testResult(test, elemHide, "bar.com", [], ElemHide.SPECIFIC_ONLY); | 207 testResult(test, elemHide, "foo.com", ["hello"], ElemHide.ALL_MATCHING); |
| 207 testResult(test, elemHide, "bar.com", [], ElemHide.NO_UNCONDITIONAL); | 208 testResult(test, elemHide, "foo.com", ["hello"]); |
| 208 testResult(test, elemHide, "bar.com", ["hello"], ElemHide.ALL_MATCHING); | 209 testResult(test, elemHide, "bar.com", [], ElemHide.SPECIFIC_ONLY); |
| 209 testResult(test, elemHide, "bar.com", ["hello"]); | 210 testResult(test, elemHide, "bar.com", [], ElemHide.NO_UNCONDITIONAL); |
| 210 addFilter("foo.com#@#hello"); | 211 testResult(test, elemHide, "bar.com", ["hello"], ElemHide.ALL_MATCHING); |
| 211 testResult(test, elemHide, "foo.com", [], ElemHide.SPECIFIC_ONLY); | 212 testResult(test, elemHide, "bar.com", ["hello"]); |
| 212 testResult(test, elemHide, "foo.com", [], ElemHide.NO_UNCONDITIONAL); | 213 addFilter("foo.com#@#hello"); |
| 213 testResult(test, elemHide, "foo.com", [], ElemHide.ALL_MATCHING); | 214 testResult(test, elemHide, "foo.com", [], ElemHide.SPECIFIC_ONLY); |
| 214 testResult(test, elemHide, "foo.com", []); | 215 testResult(test, elemHide, "foo.com", [], ElemHide.NO_UNCONDITIONAL); |
| 215 testResult(test, elemHide, "bar.com", [], ElemHide.SPECIFIC_ONLY); | 216 testResult(test, elemHide, "foo.com", [], ElemHide.ALL_MATCHING); |
| 216 testResult(test, elemHide, "bar.com", ["hello"], ElemHide.NO_UNCONDITIONAL); | 217 testResult(test, elemHide, "foo.com", []); |
| 217 testResult(test, elemHide, "bar.com", ["hello"], ElemHide.ALL_MATCHING); | 218 testResult(test, elemHide, "bar.com", [], ElemHide.SPECIFIC_ONLY); |
| 218 testResult(test, elemHide, "bar.com", ["hello"]); | 219 testResult(test, elemHide, "bar.com", ["hello"], ElemHide.NO_UNCONDITIONAL); |
| 219 removeFilter("foo.com#@#hello"); | 220 testResult(test, elemHide, "bar.com", ["hello"], ElemHide.ALL_MATCHING); |
| 220 testResult(test, elemHide, "foo.com", [], ElemHide.SPECIFIC_ONLY); | 221 testResult(test, elemHide, "bar.com", ["hello"]); |
| 221 // Note: We don't take care to track conditional selectors which became | 222 removeFilter("foo.com#@#hello"); |
| 222 // unconditional when a filter was removed. This was too expensive. | 223 testResult(test, elemHide, "foo.com", [], ElemHide.SPECIFIC_ONLY); |
| 223 // testResult(test, elemHide, "foo.com", [], ElemHide.NO_UNCONDITIONAL); | 224 // Note: We don't take care to track conditional selectors which became |
| 224 testResult(test, elemHide, "foo.com", ["hello"], ElemHide.ALL_MATCHING); | 225 // unconditional when a filter was removed. This was too expensive. |
| 225 testResult(test, elemHide, "foo.com", ["hello"]); | 226 // testResult(test, elemHide, "foo.com", [], ElemHide.NO_UNCONDITIONAL); |
| 226 testResult(test, elemHide, "bar.com", [], ElemHide.SPECIFIC_ONLY); | 227 testResult(test, elemHide, "foo.com", ["hello"], ElemHide.ALL_MATCHING); |
| 227 testResult(test, elemHide, "bar.com", ["hello"], ElemHide.NO_UNCONDITIONAL); | 228 testResult(test, elemHide, "foo.com", ["hello"]); |
| 228 testResult(test, elemHide, "bar.com", ["hello"], ElemHide.ALL_MATCHING); | 229 testResult(test, elemHide, "bar.com", [], ElemHide.SPECIFIC_ONLY); |
| 229 testResult(test, elemHide, "bar.com", ["hello"]); | 230 testResult(test, elemHide, "bar.com", ["hello"], ElemHide.NO_UNCONDITIONAL); |
| 230 removeFilter("##hello"); | 231 testResult(test, elemHide, "bar.com", ["hello"], ElemHide.ALL_MATCHING); |
| 231 testResult(test, elemHide, "foo.com", []); | 232 testResult(test, elemHide, "bar.com", ["hello"]); |
| 232 testResult(test, elemHide, "bar.com", []); | 233 removeFilter("##hello"); |
| 233 | 234 testResult(test, elemHide, "foo.com", []); |
| 234 addFilter("##hello"); | 235 testResult(test, elemHide, "bar.com", []); |
| 235 addFilter("foo.com##hello"); | 236 |
| 236 testResult(test, elemHide, "foo.com", ["hello"]); | 237 addFilter("##hello"); |
| 237 removeFilter("foo.com##hello"); | 238 addFilter("foo.com##hello"); |
| 238 testResult(test, elemHide, "foo.com", ["hello"]); | 239 testResult(test, elemHide, "foo.com", ["hello"]); |
| 239 removeFilter("##hello"); | 240 removeFilter("foo.com##hello"); |
| 240 testResult(test, elemHide, "foo.com", []); | 241 testResult(test, elemHide, "foo.com", ["hello"]); |
| 241 | 242 removeFilter("##hello"); |
| 242 addFilter("##hello"); | 243 testResult(test, elemHide, "foo.com", []); |
| 243 addFilter("foo.com##hello"); | 244 |
| 244 testResult(test, elemHide, "foo.com", ["hello"]); | 245 addFilter("##hello"); |
| 245 removeFilter("##hello"); | 246 addFilter("foo.com##hello"); |
| 246 testResult(test, elemHide, "foo.com", ["hello"]); | 247 testResult(test, elemHide, "foo.com", ["hello"]); |
| 247 removeFilter("foo.com##hello"); | 248 removeFilter("##hello"); |
| 248 testResult(test, elemHide, "foo.com", []); | 249 testResult(test, elemHide, "foo.com", ["hello"]); |
| 249 | 250 removeFilter("foo.com##hello"); |
| 250 elemHide.delete(); | 251 testResult(test, elemHide, "foo.com", []); |
| 252 })(ElemHide.create()); | |
| 253 | |
| 251 test.done(); | 254 test.done(); |
| 252 }; | 255 }; |
| 253 | 256 |
| 254 exports.testZeroFilterKey = function(test) | 257 exports.testFilterException = function(test) |
| 255 { | 258 { |
| 256 let elemHide = ElemHide.create(); | 259 withNAD([0, 1, 2], (elemHide, filter, exception) => |
| 257 | 260 { |
| 258 elemHide.add(Filter.fromText("##test")); | 261 elemHide.add(filter); |
|
sergei
2018/01/22 15:40:07
there is a memory leak, Filter.fromText should be
hub
2018/01/22 16:49:17
This is the kind of changes that are self containe
| |
| 259 elemHide.add(Filter.fromText("foo.com#@#test")); | 262 elemHide.add(exception); |
| 260 testResult(test, elemHide, "foo.com", []); | 263 testResult(test, elemHide, "foo.com", []); |
| 261 testResult(test, elemHide, "bar.com", ["test"]); | 264 testResult(test, elemHide, "bar.com", ["test"]); |
| 262 | 265 })(ElemHide.create(), Filter.fromText("##test"), Filter.fromText("foo.com#@#te st")); |
| 263 elemHide.delete(); | 266 |
| 264 test.done(); | 267 test.done(); |
| 265 }; | 268 }; |
| LEFT | RIGHT |