| 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-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 11 matching lines...) Expand all Loading... |
| 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 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 153 | 157 |
| 154 subscription1.delete(); | 158 subscription1.delete(); |
| 155 subscription2.delete(); | 159 subscription2.delete(); |
| 156 | 160 |
| 157 let subscription3 = Subscription.fromURL("http://example.com/"); | 161 let subscription3 = Subscription.fromURL("http://example.com/"); |
| 158 test.equal(subscription3.lastDownload, 0, "Subscription data has been reset on
ce previous instances have been released"); | 162 test.equal(subscription3.lastDownload, 0, "Subscription data has been reset on
ce previous instances have been released"); |
| 159 subscription3.delete(); | 163 subscription3.delete(); |
| 160 | 164 |
| 161 test.done(); | 165 test.done(); |
| 162 }; | 166 }; |
| LEFT | RIGHT |