| 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-2016 Eyeo GmbH |   3  * Copyright (C) 2006-2016 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"); | 
 |  21 let sandboxedRequire = createSandbox(); | 
 |  22  | 
|  20 let { |  23 let { | 
|  21   Subscription, SpecialSubscription, DownloadableSubscription, |  24   Subscription, SpecialSubscription, DownloadableSubscription, | 
|  22   RegularSubscription, ExternalSubscription |  25   RegularSubscription, ExternalSubscription | 
|  23 } = require("../lib/subscriptionClasses"); |  26 } = sandboxedRequire("subscriptionClasses"); | 
|  24  |  27  | 
|  25 function compareSubscription(test, url, expected, postInit) |  28 function compareSubscription(test, url, expected, postInit) | 
|  26 { |  29 { | 
|  27   expected.push("[Subscription]") |  30   expected.push("[Subscription]"); | 
|  28   let subscription = Subscription.fromURL(url); |  31   let subscription = Subscription.fromURL(url); | 
|  29   if (postInit) |  32   if (postInit) | 
|  30     postInit(subscription) |  33     postInit(subscription); | 
|  31   let result = []; |  34   let result = []; | 
|  32   subscription.serialize(result); |  35   subscription.serialize(result); | 
|  33   test.equal(result.sort().join("\n"), expected.sort().join("\n"), url); |  36   test.equal(result.sort().join("\n"), expected.sort().join("\n"), url); | 
|  34  |  37  | 
|  35   let map = Object.create(null); |  38   let map = Object.create(null); | 
|  36   for (let line of result.slice(1)) |  39   for (let line of result.slice(1)) | 
|  37   { |  40   { | 
|  38     if (/(.*?)=(.*)/.test(line)) |  41     if (/(.*?)=(.*)/.test(line)) | 
|  39       map[RegExp.$1] = RegExp.$2; |  42       map[RegExp.$1] = RegExp.$2; | 
|  40   } |  43   } | 
| (...skipping 26 matching lines...) Expand all  Loading... | 
|  67   { |  70   { | 
|  68     subscription.title = "test"; |  71     subscription.title = "test"; | 
|  69     subscription.disabled = true; |  72     subscription.disabled = true; | 
|  70     subscription.lastSuccess = 8; |  73     subscription.lastSuccess = 8; | 
|  71     subscription.lastDownload = 12; |  74     subscription.lastDownload = 12; | 
|  72     subscription.lastCheck = 16; |  75     subscription.lastCheck = 16; | 
|  73     subscription.softExpiration = 18; |  76     subscription.softExpiration = 18; | 
|  74     subscription.expires = 20; |  77     subscription.expires = 20; | 
|  75     subscription.downloadStatus = "foo"; |  78     subscription.downloadStatus = "foo"; | 
|  76     subscription.errors = 3; |  79     subscription.errors = 3; | 
|  77     subscription.version = 24 |  80     subscription.version = 24; | 
|  78     subscription.requiredVersion = "0.6"; |  81     subscription.requiredVersion = "0.6"; | 
|  79   }); |  82   }); | 
|  80   compareSubscription(test, "~wl~", ["url=~wl~", "disabled=true", "title=Test gr
    oup"], function(subscription) |  83   compareSubscription(test, "~wl~", ["url=~wl~", "disabled=true", "title=Test gr
    oup"], function(subscription) | 
|  81   { |  84   { | 
|  82     subscription.title = "Test group"; |  85     subscription.title = "Test group"; | 
|  83     subscription.disabled = true; |  86     subscription.disabled = true; | 
|  84   }); |  87   }); | 
|  85  |  88  | 
|  86   test.done(); |  89   test.done(); | 
|  87 }; |  90 }; | 
| OLD | NEW |