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

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

Issue 8177022: Add onChanged events to the extension settings API, both from sync and between (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 9 years, 2 months 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
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 1a8fb7bab04d6a499a9aae06143600ddf42e0a0e..33aa64cacb05cac03b1d8ef5962c474221687b03 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,10 +1,7 @@
<script>
var settings = chrome.experimental.settings;
-
-// A different "waiting" message depending on whether this background page runs
-// in incognito mode or not. This is so that the C++ test can differentiate
-// between messages.
+var assertEq = chrome.test.assertEq;
// Returns a function that asserts a result is expected.
function assertResultEq(expected) {
@@ -13,6 +10,14 @@ function assertResultEq(expected) {
};
}
+// All notifications received.
+var notifications = [];
+settings.onChanged.addListener(function(changes) {
+ changes.forEach(function(change) {
+ notifications.push(change);
+ });
+});
+
// The test from C++ runs "actions", where each action is defined here.
// This allows the test to be tightly controlled between incognito and
// non-incognito modes.
@@ -23,10 +28,10 @@ var testActions = {
assertEmpty: function() {
settings.get(null, assertResultEq({}));
},
- assertFoobar: function() {
+ assertFoo: function() {
settings.get(null, assertResultEq({foo: "bar"}));
},
- setFoobar: function() {
+ setFoo: function() {
settings.set({foo: "bar"}, assertResultEq({foo: "bar"}));
},
removeFoo: function() {
@@ -34,6 +39,24 @@ var testActions = {
},
clear: function() {
settings.clear(assertResultEq(undefined));
+ },
+ assertNoNotifications: function() {
+ assertEq([], notifications);
+ },
+ clearNotifications: function() {
+ notifications = [];
+ },
+ assertAddFooNotification: function() {
+ assertEq(1, notifications.length);
+ assertEq("foo", notifications[0].key);
+ assertEq(undefined, notifications[0].oldValue);
+ assertEq("bar", notifications[0].newValue);
+ },
+ assertDeleteFooNotification: function() {
+ assertEq(1, notifications.length);
+ assertEq("foo", notifications[0].key);
+ assertEq("bar", notifications[0].oldValue);
+ assertEq(undefined, notifications[0].newValue);
}
};

Powered by Google App Engine
This is Rietveld 408576698