| 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-2017 eyeo GmbH | 3 * Copyright (C) 2006-2017 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 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 72 if (action.indexOf("subscription.") == 0) | 72 if (action.indexOf("subscription.") == 0) |
| 73 changes.push(action + " " + subscription.url); | 73 changes.push(action + " " + subscription.url); |
| 74 } | 74 } |
| 75 FilterNotifier.addListener(listener); | 75 FilterNotifier.addListener(listener); |
| 76 | 76 |
| 77 compareSubscriptionList(test, "Initial state", []); | 77 compareSubscriptionList(test, "Initial state", []); |
| 78 test.deepEqual(changes, [], "Received changes"); | 78 test.deepEqual(changes, [], "Received changes"); |
| 79 | 79 |
| 80 changes = []; | 80 changes = []; |
| 81 FilterStorage.addSubscription(subscription1); | 81 FilterStorage.addSubscription(subscription1); |
| 82 compareSubscriptionList(test, "Regular add", [subscription1]); | 82 compareSubscriptionList(test, "Adding first subscription", [subscription1]); |
| 83 test.deepEqual(changes, ["subscription.added http://test1/"], "Received change
s"); | 83 test.deepEqual(changes, ["subscription.added http://test1/"], "Received change
s"); |
| 84 | 84 |
| 85 changes = []; | 85 changes = []; |
| 86 FilterStorage.addSubscription(subscription1); | 86 FilterStorage.addSubscription(subscription1); |
| 87 compareSubscriptionList(test, "Adding already added subscription", [subscripti
on1]); | 87 compareSubscriptionList(test, "Adding already added subscription", [subscripti
on1]); |
| 88 test.deepEqual(changes, [], "Received changes"); | 88 test.deepEqual(changes, [], "Received changes"); |
| 89 | 89 |
| 90 changes = []; | 90 changes = []; |
| 91 FilterStorage.addSubscription(subscription2, true); | 91 FilterStorage.addSubscription(subscription2); |
| 92 compareSubscriptionList(test, "Silent add", [subscription1, subscription2]); | 92 compareSubscriptionList(test, "Adding second", [subscription1, subscription2])
; |
| 93 test.deepEqual(changes, [], "Received changes"); | 93 test.deepEqual(changes, ["subscription.added http://test2/"], "Received change
s"); |
| 94 | 94 |
| 95 FilterStorage.removeSubscription(subscription1); | 95 FilterStorage.removeSubscription(subscription1); |
| 96 compareSubscriptionList(test, "Remove", [subscription2]); | 96 compareSubscriptionList(test, "Remove", [subscription2]); |
| 97 | 97 |
| 98 changes = []; | 98 changes = []; |
| 99 FilterStorage.addSubscription(subscription1); | 99 FilterStorage.addSubscription(subscription1); |
| 100 compareSubscriptionList(test, "Re-adding previously removed subscription", [su
bscription2, subscription1]); | 100 compareSubscriptionList(test, "Re-adding previously removed subscription", [su
bscription2, subscription1]); |
| 101 test.deepEqual(changes, ["subscription.added http://test1/"], "Received change
s"); | 101 test.deepEqual(changes, ["subscription.added http://test1/"], "Received change
s"); |
| 102 | 102 |
| 103 test.done(); | 103 test.done(); |
| (...skipping 12 matching lines...) Expand all Loading... |
| 116 if (action.indexOf("subscription.") == 0) | 116 if (action.indexOf("subscription.") == 0) |
| 117 changes.push(action + " " + subscription.url); | 117 changes.push(action + " " + subscription.url); |
| 118 } | 118 } |
| 119 FilterNotifier.addListener(listener); | 119 FilterNotifier.addListener(listener); |
| 120 | 120 |
| 121 compareSubscriptionList(test, "Initial state", [subscription1, subscription2])
; | 121 compareSubscriptionList(test, "Initial state", [subscription1, subscription2])
; |
| 122 test.deepEqual(changes, [], "Received changes"); | 122 test.deepEqual(changes, [], "Received changes"); |
| 123 | 123 |
| 124 changes = []; | 124 changes = []; |
| 125 FilterStorage.removeSubscription(subscription1); | 125 FilterStorage.removeSubscription(subscription1); |
| 126 compareSubscriptionList(test, "Regular remove", [subscription2]); | 126 compareSubscriptionList(test, "Removing first subscription", [subscription2]); |
| 127 test.deepEqual(changes, ["subscription.removed http://test1/"], "Received chan
ges"); | 127 test.deepEqual(changes, ["subscription.removed http://test1/"], "Received chan
ges"); |
| 128 | 128 |
| 129 changes = []; | 129 changes = []; |
| 130 FilterStorage.removeSubscription(subscription1); | 130 FilterStorage.removeSubscription(subscription1); |
| 131 compareSubscriptionList(test, "Removing already removed subscription", [subscr
iption2]); | 131 compareSubscriptionList(test, "Removing already removed subscription", [subscr
iption2]); |
| 132 test.deepEqual(changes, [], "Received changes"); | 132 test.deepEqual(changes, [], "Received changes"); |
| 133 | 133 |
| 134 changes = []; | 134 changes = []; |
| 135 FilterStorage.removeSubscription(subscription2, true); | 135 FilterStorage.removeSubscription(subscription2); |
| 136 compareSubscriptionList(test, "Silent remove", []); | 136 compareSubscriptionList(test, "Removing remaining subscription", []); |
| 137 test.deepEqual(changes, [], "Received changes"); | 137 test.deepEqual(changes, ["subscription.removed http://test2/"], "Received chan
ges"); |
| 138 | 138 |
| 139 FilterStorage.addSubscription(subscription1); | 139 FilterStorage.addSubscription(subscription1); |
| 140 compareSubscriptionList(test, "Add", [subscription1]); | 140 compareSubscriptionList(test, "Add", [subscription1]); |
| 141 | 141 |
| 142 changes = []; | 142 changes = []; |
| 143 FilterStorage.removeSubscription(subscription1); | 143 FilterStorage.removeSubscription(subscription1); |
| 144 compareSubscriptionList(test, "Re-removing previously added subscription", [])
; | 144 compareSubscriptionList(test, "Re-removing previously added subscription", [])
; |
| 145 test.deepEqual(changes, ["subscription.removed http://test1/"], "Received chan
ges"); | 145 test.deepEqual(changes, ["subscription.removed http://test1/"], "Received chan
ges"); |
| 146 | 146 |
| 147 test.done(); | 147 test.done(); |
| (...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 243 FilterStorage.addFilter(Filter.fromText("foo#bar")); | 243 FilterStorage.addFilter(Filter.fromText("foo#bar")); |
| 244 compareFiltersList(test, "Adding hiding rule", [["foo"], ["@@bar", "foo#bar"],
[]]); | 244 compareFiltersList(test, "Adding hiding rule", [["foo"], ["@@bar", "foo#bar"],
[]]); |
| 245 test.deepEqual(changes, ["filter.added foo#bar"], "Received changes"); | 245 test.deepEqual(changes, ["filter.added foo#bar"], "Received changes"); |
| 246 | 246 |
| 247 changes = []; | 247 changes = []; |
| 248 FilterStorage.addFilter(Filter.fromText("foo#@#bar")); | 248 FilterStorage.addFilter(Filter.fromText("foo#@#bar")); |
| 249 compareFiltersList(test, "Adding hiding exception", [["foo"], ["@@bar", "foo#b
ar", "foo#@#bar"], []]); | 249 compareFiltersList(test, "Adding hiding exception", [["foo"], ["@@bar", "foo#b
ar", "foo#@#bar"], []]); |
| 250 test.deepEqual(changes, ["filter.added foo#@#bar"], "Received changes"); | 250 test.deepEqual(changes, ["filter.added foo#@#bar"], "Received changes"); |
| 251 | 251 |
| 252 changes = []; | 252 changes = []; |
| 253 FilterStorage.addFilter(Filter.fromText("!foobar"), undefined, undefined, true
); | 253 FilterStorage.addFilter(Filter.fromText("!foobar")); |
| 254 compareFiltersList(test, "Adding comment silent", [["foo"], ["@@bar", "foo#bar
", "foo#@#bar"], ["!foobar"]]); | 254 compareFiltersList(test, "Adding comment", [["foo"], ["@@bar", "foo#bar", "foo
#@#bar"], ["!foobar"]]); |
| 255 test.deepEqual(changes, [], "Received changes"); | 255 test.deepEqual(changes, ["filter.added !foobar"], "Received changes"); |
| 256 | 256 |
| 257 changes = []; | 257 changes = []; |
| 258 FilterStorage.addFilter(Filter.fromText("foo")); | 258 FilterStorage.addFilter(Filter.fromText("foo")); |
| 259 compareFiltersList(test, "Adding already added filter", [["foo"], ["@@bar", "f
oo#bar", "foo#@#bar"], ["!foobar"]]); | 259 compareFiltersList(test, "Adding already added filter", [["foo"], ["@@bar", "f
oo#bar", "foo#@#bar"], ["!foobar"]]); |
| 260 test.deepEqual(changes, [], "Received changes"); | 260 test.deepEqual(changes, [], "Received changes"); |
| 261 | 261 |
| 262 subscription1.disabled = true; | 262 subscription1.disabled = true; |
| 263 | 263 |
| 264 changes = []; | 264 changes = []; |
| 265 FilterStorage.addFilter(Filter.fromText("foo")); | 265 FilterStorage.addFilter(Filter.fromText("foo")); |
| (...skipping 225 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 491 compareFilterSubscriptions(test, "filter3 subscriptions after updating http://
test3/ filters", filter3, [subscription2]); | 491 compareFilterSubscriptions(test, "filter3 subscriptions after updating http://
test3/ filters", filter3, [subscription2]); |
| 492 | 492 |
| 493 FilterStorage.removeSubscription(subscription3); | 493 FilterStorage.removeSubscription(subscription3); |
| 494 | 494 |
| 495 compareFilterSubscriptions(test, "filter1 subscriptions after removing http://
test3/", filter1, []); | 495 compareFilterSubscriptions(test, "filter1 subscriptions after removing http://
test3/", filter1, []); |
| 496 compareFilterSubscriptions(test, "filter2 subscriptions after removing http://
test3/", filter2, [subscription2]); | 496 compareFilterSubscriptions(test, "filter2 subscriptions after removing http://
test3/", filter2, [subscription2]); |
| 497 compareFilterSubscriptions(test, "filter3 subscriptions after removing http://
test3/", filter3, [subscription2]); | 497 compareFilterSubscriptions(test, "filter3 subscriptions after removing http://
test3/", filter3, [subscription2]); |
| 498 | 498 |
| 499 test.done(); | 499 test.done(); |
| 500 }; | 500 }; |
| OLD | NEW |