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

Delta Between Two Patch Sets: chrome/content/tests/prefs.js

Issue 5203041586249728: Issue 2040 - Adapted tests for chrome.storage.local (Closed)
Left Patch Set: Created Feb. 26, 2015, 12:12 p.m.
Right Patch Set: Addressed comments Created Feb. 26, 2015, 4:03 p.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
Left: Side by side diff | Download
Right: Side by side diff | Download
« no previous file with change/comment | « no previous file | no next file » | no next file with change/comment »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
LEFTRIGHT
1 (function() 1 (function()
2 { 2 {
3 module("Preferences", 3 module("Preferences",
4 { 4 {
5 setup: function() 5 setup: function()
6 { 6 {
7 preparePrefs.call(this); 7 preparePrefs.call(this);
8 }, 8 },
9 9
10 teardown: function() 10 teardown: function()
11 { 11 {
12 restorePrefs.call(this); 12 restorePrefs.call(this);
13 } 13 }
14 }); 14 });
15 15
16 function checkPrefExists(name, expectedValue, description, assert) 16 function checkPrefExists(name, expectedValue, description, assert)
17 { 17 {
18 if ("chrome" in window) 18 if ("chrome" in window)
Wladimir Palant 2015/02/26 14:43:11 Looks like this test doesn't consider Safari. Is t
Sebastian Noack 2015/02/26 16:03:43 Tests are currently and ever since pretty much bro
19 { 19 {
20 let done = assert.async(); 20 let done = assert.async();
21 » let key = "pref:" + name; 21 let key = "pref:" + name;
Wladimir Palant 2015/02/26 14:43:11 Nit: no smart tabs please.
Sebastian Noack 2015/02/26 16:03:43 Just regular tabs. I'm still not a fan of spaces.
22 chrome.storage.local.get([key], function(items) 22 chrome.storage.local.get(key, function(items)
Wladimir Palant 2015/02/26 14:43:11 According to documentation, passing in key without
Sebastian Noack 2015/02/26 16:03:43 Yes, it does, but I find it weird. Since you alway
23 { 23 {
24 equal(key in items, expectedValue, description); 24 equal(key in items, expectedValue, description);
25 done(); 25 done();
26 }); 26 });
27 } 27 }
28 else 28 else
29 { 29 {
30 equal(Services.prefs.prefHasUserValue("extensions.adblockplus." + name), e xpectedValue, description); 30 equal(Services.prefs.prefHasUserValue("extensions.adblockplus." + name), e xpectedValue, description);
31 } 31 }
32 } 32 }
33 33
34 function checkPref(name, expectedValue, description, assert) 34 function checkPref(name, expectedValue, description, assert)
35 { 35 {
36 if ("chrome" in window) 36 if ("chrome" in window)
37 { 37 {
38 let done = assert.async(); 38 let done = assert.async();
39 » let key = "pref:" + name; 39 let key = "pref:" + name;
Wladimir Palant 2015/02/26 14:43:11 Nit: no smart tabs please.
Sebastian Noack 2015/02/26 16:03:43 Done, here as well.
40 chrome.storage.local.get([key], function(items) 40 chrome.storage.local.get(key, function(items)
Wladimir Palant 2015/02/26 14:43:11 As above, passing in key without wrapping it in an
Sebastian Noack 2015/02/26 16:03:43 Done, here as wel.
41 { 41 {
42 deepEqual(items[key], expectedValue, description); 42 deepEqual(items[key], expectedValue, description);
43 done(); 43 done();
44 }); 44 });
45 } 45 }
46 else 46 else
47 { 47 {
48 let pref = "extensions.adblockplus." + name; 48 let pref = "extensions.adblockplus." + name;
49 let value = null; 49 let value = null;
50 50
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
126 deepEqual(Prefs.notificationdata, {foo:1, bar: 2}, "Prefs object returns the correct value after setting pref to non-default value"); 126 deepEqual(Prefs.notificationdata, {foo:1, bar: 2}, "Prefs object returns the correct value after setting pref to non-default value");
127 checkPrefExists("notificationdata", true, "User-defined pref has been create d", assert); 127 checkPrefExists("notificationdata", true, "User-defined pref has been create d", assert);
128 checkPref("notificationdata", {foo:1, bar: 2}, "Value has been written", ass ert); 128 checkPref("notificationdata", {foo:1, bar: 2}, "Value has been written", ass ert);
129 129
130 delete Prefs.notificationdata.foo; 130 delete Prefs.notificationdata.foo;
131 delete Prefs.notificationdata.bar; 131 delete Prefs.notificationdata.bar;
132 Prefs.notificationdata = JSON.parse(JSON.stringify(Prefs.notificationdata)); 132 Prefs.notificationdata = JSON.parse(JSON.stringify(Prefs.notificationdata));
133 deepEqual(Prefs.notificationdata, {}, "Prefs object returns the correct valu e after setting pref to default value"); 133 deepEqual(Prefs.notificationdata, {}, "Prefs object returns the correct valu e after setting pref to default value");
134 }); 134 });
135 })(); 135 })();
LEFTRIGHT
« no previous file | no next file » | Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Toggle Comments ('s')

Powered by Google App Engine
This is Rietveld