Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Side by Side Diff: test/stub-modules/prefs.js

Issue 29356001: Issue 4223 - Adapt notification tests to work in adblockpluscore repository (Closed) Base URL: https://hg.adblockplus.org/adblockpluscore
Patch Set: Addressed comments Created Oct. 5, 2016, 12:50 p.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff | Download patch
« no previous file with comments | « test/stub-modules/info.js ('k') | test/synchronizer.js » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 exports.Prefs = { 1 let listeners = [];
2
3 let Prefs = exports.Prefs = {
4 enabled: true,
2 savestats: true, 5 savestats: true,
3 subscriptions_autoupdate: true, 6 subscriptions_autoupdate: true,
4 subscriptions_fallbackerrors: 5, 7 subscriptions_fallbackerrors: 5,
5 subscriptions_fallbackurl: "" 8 subscriptions_fallbackurl: "",
9 notificationurl: "http://example.com/notification.json",
10 notificationdata: {},
11 notifications_ignoredcategories: []
6 }; 12 };
13
14 for (let key of Object.keys(Prefs))
15 {
16 let value = Prefs[key];
17 Object.defineProperty(Prefs, key, {
18 get: () => value,
19 set: newValue =>
20 {
21 if (newValue == value)
22 return;
23
24 value = newValue;
25 for (let listener of listeners)
26 listener(key);
27 }
28 });
29 }
30
31 Prefs.addListener = function(listener)
32 {
33 if (listeners.indexOf(listener) < 0)
34 listeners.push(listener);
35 };
36
37 Prefs.removeListener = function(listener)
38 {
39 let index = listeners.indexOf(listener);
40 if (index >= 0)
41 listeners.splice(index, 1);
42 };
OLDNEW
« no previous file with comments | « test/stub-modules/info.js ('k') | test/synchronizer.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld