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-2016 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 |
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 let {createSandbox} = require("./_common"); | 20 let {createSandbox} = require("./_common"); |
21 | 21 |
22 let Filter = null; | 22 let Filter = null; |
23 let Subscription = null; | 23 let Subscription = null; |
24 let SpecialSubscription = null; | 24 let SpecialSubscription = null; |
25 let DownloadableSubscription = null; | 25 let DownloadableSubscription = null; |
26 let RegularSubscription = null; | 26 let RegularSubscription = null; |
27 let ExternalSubscription = null; | 27 let ExternalSubscription = null; |
28 | 28 |
29 exports.setUp = function(callback) | 29 exports.setUp = function(callback) |
30 { | 30 { |
31 let sandboxedRequire = createSandbox(); | 31 let sandboxedRequire = createSandbox(); |
32 ({Filter} = sandboxedRequire("../lib/filterClassesNew")); | 32 ({Filter} = sandboxedRequire("../lib/filterClasses")); |
33 ( | 33 ( |
34 { | 34 { |
35 Subscription, SpecialSubscription, DownloadableSubscription | 35 Subscription, SpecialSubscription, DownloadableSubscription |
36 } = sandboxedRequire("../lib/subscriptionClassesNew") | 36 } = sandboxedRequire("../lib/subscriptionClasses") |
37 ); | 37 ); |
38 callback(); | 38 callback(); |
39 }; | 39 }; |
40 | 40 |
41 function compareSubscription(test, url, expected, postInit) | 41 function compareSubscription(test, url, expected, postInit) |
42 { | 42 { |
43 expected.push("[Subscription]") | 43 expected.push("[Subscription]") |
44 let subscription = Subscription.fromURL(url); | 44 let subscription = Subscription.fromURL(url); |
45 if (postInit) | 45 if (postInit) |
46 postInit(subscription) | 46 postInit(subscription) |
(...skipping 12 matching lines...) Expand all Loading... |
59 }; | 59 }; |
60 | 60 |
61 exports.testSubscriptionsWithState = function(test) | 61 exports.testSubscriptionsWithState = function(test) |
62 { | 62 { |
63 compareSubscription(test, "~fl~", ["url=~fl~"]); | 63 compareSubscription(test, "~fl~", ["url=~fl~"]); |
64 compareSubscription(test, "http://test/default", ["url=http://test/default", "
title=http://test/default"]); | 64 compareSubscription(test, "http://test/default", ["url=http://test/default", "
title=http://test/default"]); |
65 compareSubscription(test, "http://test/default_titled", ["url=http://test/defa
ult_titled", "title=test"], function(subscription) | 65 compareSubscription(test, "http://test/default_titled", ["url=http://test/defa
ult_titled", "title=test"], function(subscription) |
66 { | 66 { |
67 subscription.title = "test"; | 67 subscription.title = "test"; |
68 }); | 68 }); |
69 compareSubscription(test, "http://test/non_default", ["url=http://test/non_def
ault", "title=test", "fixedTitle=true", | 69 compareSubscription(test, "http://test/non_default", [ |
70 "disabled=true", "lastSuccess=
8", "lastDownload=12", "lastCheck=16", "softExpiration=18", "expires=20", "downl
oadStatus=foo", | 70 "url=http://test/non_default", "title=test", "fixedTitle=true", |
71 "errors=3", "version=24", "req
uiredVersion=0.6"], function(subscription) | 71 "disabled=true", "lastSuccess=20015998341138", |
| 72 "lastDownload=5124097847590911", "lastCheck=18446744069414584320", |
| 73 "softExpiration=2682143778081159", "expires=4294967295", |
| 74 "downloadStatus=foo", "errors=3", "version=24", "requiredVersion=0.6" |
| 75 ], function(subscription) |
72 { | 76 { |
73 subscription.title = "test"; | 77 subscription.title = "test"; |
74 subscription.fixedTitle = true; | 78 subscription.fixedTitle = true; |
75 subscription.disabled = true; | 79 subscription.disabled = true; |
76 subscription.lastSuccess = 8; | 80 subscription.lastSuccess = 20015998341138; // 0x123456789012 |
77 subscription.lastDownload = 12; | 81 subscription.lastDownload = 5124097847590911; // 0x123456FFFFFFFF |
78 subscription.lastCheck = 16; | 82 subscription.lastCheck = 18446744069414584320; // 0xFFFFFFFF00000000 |
79 subscription.softExpiration = 18; | 83 subscription.softExpiration = 2682143778081159; // 0x9876543210987 |
80 subscription.expires = 20; | 84 subscription.expires = 4294967295; // 0xFFFFFFFF |
81 subscription.downloadStatus = "foo"; | 85 subscription.downloadStatus = "foo"; |
82 subscription.errors = 3; | 86 subscription.errors = 3; |
83 subscription.version = 24 | 87 subscription.version = 24 |
84 subscription.requiredVersion = "0.6"; | 88 subscription.requiredVersion = "0.6"; |
85 }); | 89 }); |
86 compareSubscription(test, "~wl~", ["url=~wl~", "disabled=true", "title=Test gr
oup"], function(subscription) | 90 compareSubscription(test, "~wl~", ["url=~wl~", "disabled=true", "title=Test gr
oup"], function(subscription) |
87 { | 91 { |
88 subscription.title = "Test group"; | 92 subscription.title = "Test group"; |
89 subscription.disabled = true; | 93 subscription.disabled = true; |
90 }); | 94 }); |
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
247 | 251 |
248 subscription.removeFilterAt(0); | 252 subscription.removeFilterAt(0); |
249 test.equal(subscription.serializeFilters(), "[Subscription filters]\nfilter2\n
filter1\n", "One filter removed"); | 253 test.equal(subscription.serializeFilters(), "[Subscription filters]\nfilter2\n
filter1\n", "One filter removed"); |
250 | 254 |
251 subscription.delete(); | 255 subscription.delete(); |
252 filter1.delete(); | 256 filter1.delete(); |
253 filter2.delete(); | 257 filter2.delete(); |
254 | 258 |
255 test.done(); | 259 test.done(); |
256 }; | 260 }; |
LEFT | RIGHT |