| OLD | NEW |
| 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 |
| (...skipping 240 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 251 filterStorage.addFilter(Filter.fromText("foo##bar")); | 251 filterStorage.addFilter(Filter.fromText("foo##bar")); |
| 252 compareFiltersList(test, "Adding hiding rule", [["foo"], ["@@bar", "foo##bar"]
, []]); | 252 compareFiltersList(test, "Adding hiding rule", [["foo"], ["@@bar", "foo##bar"]
, []]); |
| 253 test.deepEqual(changes, ["filter.added foo##bar"], "Received changes"); | 253 test.deepEqual(changes, ["filter.added foo##bar"], "Received changes"); |
| 254 | 254 |
| 255 changes = []; | 255 changes = []; |
| 256 filterStorage.addFilter(Filter.fromText("foo#@#bar")); | 256 filterStorage.addFilter(Filter.fromText("foo#@#bar")); |
| 257 compareFiltersList(test, "Adding hiding exception", [["foo"], ["@@bar", "foo##
bar", "foo#@#bar"], []]); | 257 compareFiltersList(test, "Adding hiding exception", [["foo"], ["@@bar", "foo##
bar", "foo#@#bar"], []]); |
| 258 test.deepEqual(changes, ["filter.added foo#@#bar"], "Received changes"); | 258 test.deepEqual(changes, ["filter.added foo#@#bar"], "Received changes"); |
| 259 | 259 |
| 260 changes = []; | 260 changes = []; |
| 261 filterStorage.addFilter(Filter.fromText("example.com#$#foobar")); |
| 262 compareFiltersList(test, "Adding snippet filter", [["foo"], ["@@bar", "foo##ba
r", "foo#@#bar"], ["example.com#$#foobar"]]); |
| 263 test.deepEqual(changes, ["filter.added example.com#$#foobar"], "Received chang
es"); |
| 264 |
| 265 changes = []; |
| 261 filterStorage.addFilter(Filter.fromText("!foobar")); | 266 filterStorage.addFilter(Filter.fromText("!foobar")); |
| 262 compareFiltersList(test, "Adding comment", [["foo"], ["@@bar", "foo##bar", "fo
o#@#bar"], ["!foobar"]]); | 267 compareFiltersList(test, "Adding comment", [["foo", "!foobar"], ["@@bar", "foo
##bar", "foo#@#bar"], ["example.com#$#foobar"]]); |
| 263 test.deepEqual(changes, ["filter.added !foobar"], "Received changes"); | 268 test.deepEqual(changes, ["filter.added !foobar"], "Received changes"); |
| 264 | 269 |
| 265 changes = []; | 270 changes = []; |
| 266 filterStorage.addFilter(Filter.fromText("foo")); | 271 filterStorage.addFilter(Filter.fromText("foo")); |
| 267 compareFiltersList(test, "Adding already added filter", [["foo"], ["@@bar", "f
oo##bar", "foo#@#bar"], ["!foobar"]]); | 272 compareFiltersList(test, "Adding already added filter", [["foo", "!foobar"], [
"@@bar", "foo##bar", "foo#@#bar"], ["example.com#$#foobar"]]); |
| 268 test.deepEqual(changes, [], "Received changes"); | 273 test.deepEqual(changes, [], "Received changes"); |
| 269 | 274 |
| 270 subscription1.disabled = true; | 275 subscription1.disabled = true; |
| 271 | 276 |
| 272 changes = []; | 277 changes = []; |
| 273 filterStorage.addFilter(Filter.fromText("foo")); | 278 filterStorage.addFilter(Filter.fromText("foo")); |
| 274 compareFiltersList(test, "Adding filter already in a disabled subscription", [
["foo"], ["@@bar", "foo##bar", "foo#@#bar"], ["!foobar", "foo"]]); | 279 compareFiltersList(test, "Adding filter already in a disabled subscription", [
["foo", "!foobar"], ["@@bar", "foo##bar", "foo#@#bar"], ["example.com#$#foobar",
"foo"]]); |
| 275 test.deepEqual(changes, ["filter.added foo"], "Received changes"); | 280 test.deepEqual(changes, ["filter.added foo"], "Received changes"); |
| 276 | 281 |
| 277 changes = []; | 282 changes = []; |
| 278 filterStorage.addFilter(Filter.fromText("foo"), subscription1); | 283 filterStorage.addFilter(Filter.fromText("foo"), subscription1); |
| 279 compareFiltersList(test, "Adding filter to an explicit subscription", [["foo",
"foo"], ["@@bar", "foo##bar", "foo#@#bar"], ["!foobar", "foo"]]); | 284 compareFiltersList(test, "Adding filter to an explicit subscription", [["foo",
"!foobar", "foo"], ["@@bar", "foo##bar", "foo#@#bar"], ["example.com#$#foobar",
"foo"]]); |
| 280 test.deepEqual(changes, ["filter.added foo"], "Received changes"); | 285 test.deepEqual(changes, ["filter.added foo"], "Received changes"); |
| 281 | 286 |
| 282 changes = []; | 287 changes = []; |
| 283 filterStorage.addFilter(Filter.fromText("!foobar"), subscription2, 0); | 288 filterStorage.addFilter(Filter.fromText("example.com#$#foobar"), subscription2
, 0); |
| 284 compareFiltersList(test, "Adding filter to an explicit subscription with posit
ion", [["foo", "foo"], ["!foobar", "@@bar", "foo##bar", "foo#@#bar"], ["!foobar"
, "foo"]]); | 289 compareFiltersList(test, "Adding filter to an explicit subscription with posit
ion", [["foo", "!foobar", "foo"], ["example.com#$#foobar", "@@bar", "foo##bar",
"foo#@#bar"], ["example.com#$#foobar", "foo"]]); |
| 285 test.deepEqual(changes, ["filter.added !foobar"], "Received changes"); | 290 test.deepEqual(changes, ["filter.added example.com#$#foobar"], "Received chang
es"); |
| 286 | 291 |
| 287 test.done(); | 292 test.done(); |
| 288 }; | 293 }; |
| 289 | 294 |
| 290 exports.testRemovingFilters = function(test) | 295 exports.testRemovingFilters = function(test) |
| 291 { | 296 { |
| 292 let subscription1 = Subscription.fromURL("~foo"); | 297 let subscription1 = Subscription.fromURL("~foo"); |
| 293 subscription1.addFilter(Filter.fromText("foo")); | 298 subscription1.addFilter(Filter.fromText("foo")); |
| 294 subscription1.addFilter(Filter.fromText("foo")); | 299 subscription1.addFilter(Filter.fromText("foo")); |
| 295 subscription1.addFilter(Filter.fromText("bar")); | 300 subscription1.addFilter(Filter.fromText("bar")); |
| (...skipping 216 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 512 compareFilterSubscriptions(test, "filter3 subscriptions after updating http://
test3/ filters", filter3, [subscription2]); | 517 compareFilterSubscriptions(test, "filter3 subscriptions after updating http://
test3/ filters", filter3, [subscription2]); |
| 513 | 518 |
| 514 filterStorage.removeSubscription(subscription3); | 519 filterStorage.removeSubscription(subscription3); |
| 515 | 520 |
| 516 compareFilterSubscriptions(test, "filter1 subscriptions after removing http://
test3/", filter1, []); | 521 compareFilterSubscriptions(test, "filter1 subscriptions after removing http://
test3/", filter1, []); |
| 517 compareFilterSubscriptions(test, "filter2 subscriptions after removing http://
test3/", filter2, [subscription2]); | 522 compareFilterSubscriptions(test, "filter2 subscriptions after removing http://
test3/", filter2, [subscription2]); |
| 518 compareFilterSubscriptions(test, "filter3 subscriptions after removing http://
test3/", filter3, [subscription2]); | 523 compareFilterSubscriptions(test, "filter3 subscriptions after removing http://
test3/", filter3, [subscription2]); |
| 519 | 524 |
| 520 test.done(); | 525 test.done(); |
| 521 }; | 526 }; |
| OLD | NEW |