Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(5408)

Unified Diff: chrome/test/data/extensions/api_test/settings/split_incognito/background.html

Issue 8670012: Extension Settings API: move the API functions into an object SettingsNamepace, (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix bug / sync Created 9 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/test/data/extensions/api_test/settings/simple_test/background.html ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/test/data/extensions/api_test/settings/split_incognito/background.html
diff --git a/chrome/test/data/extensions/api_test/settings/split_incognito/background.html b/chrome/test/data/extensions/api_test/settings/split_incognito/background.html
index ad65ef5022b86cffe621a90256265fa574bdbbd5..9dae9f111ec7d0c3dd1f38de2e08c00ae0b0804f 100644
--- a/chrome/test/data/extensions/api_test/settings/split_incognito/background.html
+++ b/chrome/test/data/extensions/api_test/settings/split_incognito/background.html
@@ -1,13 +1,16 @@
<script>
-var settings = chrome.experimental.settings;
+var api = chrome.experimental.settings;
var assertEq = chrome.test.assertEq;
var inIncognitoContext = chrome.extension.inIncognitoContext;
-// All notifications received.
-var notifications = [];
-settings.onChanged.addListener(function(changes) {
- changes.forEach(function(change) {
- notifications.push(change);
+['sync', 'local'].forEach(function(namespace) {
+ api[namespace].notifications = [];
+ api.onChanged.addListener(function(changes, event_namespace) {
+ if (event_namespace == namespace) {
+ changes.forEach(function(change) {
+ api[namespace].notifications.push(change);
+ });
+ }
});
});
@@ -18,49 +21,43 @@ settings.onChanged.addListener(function(changes) {
// operation fully completes.
var testActions = {
noop: function(callback) {
- settings.get("", callback);
+ this.get("", callback);
},
assertEmpty: function(callback) {
- settings.get(null, function(settings) {
+ this.get(null, function(settings) {
chrome.test.assertEq({}, settings);
callback();
});
},
assertFoo: function(callback) {
- settings.get(null, function(settings) {
+ this.get(null, function(settings) {
chrome.test.assertEq({foo: "bar"}, settings);
callback();
});
},
setFoo: function(callback) {
- settings.set({foo: "bar"}, callback);
+ this.set({foo: "bar"}, callback);
},
removeFoo: function(callback) {
- settings.remove("foo", callback);
+ this.remove("foo", callback);
},
clear: function(callback) {
- settings.clear(callback);
+ this.clear(callback);
},
assertNoNotifications: function(callback) {
- assertEq([], notifications);
+ assertEq([], this.notifications);
callback();
},
clearNotifications: function(callback) {
- notifications = [];
+ this.notifications.length = 0;
callback();
},
assertAddFooNotification: function(callback) {
- assertEq(1, notifications.length);
- assertEq("foo", notifications[0].key);
- assertEq(undefined, notifications[0].oldValue);
- assertEq("bar", notifications[0].newValue);
+ assertEq([{ key: 'foo', newValue: 'bar' }], this.notifications);
callback();
},
assertDeleteFooNotification: function(callback) {
- assertEq(1, notifications.length);
- assertEq("foo", notifications[0].key);
- assertEq("bar", notifications[0].oldValue);
- assertEq(undefined, notifications[0].newValue);
+ assertEq([{ key: 'foo', oldValue: 'bar' }], this.notifications);
callback();
}
};
@@ -73,7 +70,12 @@ function testEverything() {
chrome.test.sendMessage(waiting, function(messageJson) {
var message = JSON.parse(messageJson);
var action = testActions[message.action];
- action(message.isFinalAction ? chrome.test.succeed : next);
+ if (!action) {
+ chrome.test.fail("Unknown action: " + message.action);
+ return;
+ }
+ action.bind(api[message.namespace])(
+ message.isFinalAction ? chrome.test.succeed : next);
});
}
next();
« no previous file with comments | « chrome/test/data/extensions/api_test/settings/simple_test/background.html ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698