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

Unified 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.
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « test/stub-modules/info.js ('k') | test/synchronizer.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/stub-modules/prefs.js
===================================================================
--- a/test/stub-modules/prefs.js
+++ b/test/stub-modules/prefs.js
@@ -1,6 +1,42 @@
-exports.Prefs = {
+let listeners = [];
+
+let Prefs = exports.Prefs = {
+ enabled: true,
savestats: true,
subscriptions_autoupdate: true,
subscriptions_fallbackerrors: 5,
- subscriptions_fallbackurl: ""
+ subscriptions_fallbackurl: "",
+ notificationurl: "http://example.com/notification.json",
+ notificationdata: {},
+ notifications_ignoredcategories: []
};
+
+for (let key of Object.keys(Prefs))
+{
+ let value = Prefs[key];
+ Object.defineProperty(Prefs, key, {
+ get: () => value,
+ set: newValue =>
+ {
+ if (newValue == value)
+ return;
+
+ value = newValue;
+ for (let listener of listeners)
+ listener(key);
+ }
+ });
+}
+
+Prefs.addListener = function(listener)
+{
+ if (listeners.indexOf(listener) < 0)
+ listeners.push(listener);
+};
+
+Prefs.removeListener = function(listener)
+{
+ let index = listeners.indexOf(listener);
+ if (index >= 0)
+ listeners.splice(index, 1);
+};
« 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