summaryrefslogtreecommitdiffstats
path: root/chrome/renderer
diff options
context:
space:
mode:
authorerikkay@google.com <erikkay@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2009-06-10 15:10:55 +0000
committererikkay@google.com <erikkay@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2009-06-10 15:10:55 +0000
commitd868f62ecb4135be9f0b58e2ac19f25d16a8e7ec (patch)
tree7953c8a299f7abf631c94457d8923bcbbfe54851 /chrome/renderer
parent6cb2b8005e8dbaca2273913234dda828ad51018a (diff)
downloadchromium_src-d868f62ecb4135be9f0b58e2ac19f25d16a8e7ec.zip
chromium_src-d868f62ecb4135be9f0b58e2ac19f25d16a8e7ec.tar.gz
chromium_src-d868f62ecb4135be9f0b58e2ac19f25d16a8e7ec.tar.bz2
Clean up bookmark API to match style of other extension APIs
BUG=11823 TEST=--load-extension test/data/extensions/samples/bookmarks TEST=unit_tests.exe --gtest_filter=ExtensionAPIClientTest.* Review URL: http://codereview.chromium.org/118209 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@18056 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/renderer')
-rw-r--r--chrome/renderer/extensions/extension_api_client_unittest.cc31
-rw-r--r--chrome/renderer/resources/extension_process_bindings.js57
-rw-r--r--chrome/renderer/resources/json_schema.js2
3 files changed, 50 insertions, 40 deletions
diff --git a/chrome/renderer/extensions/extension_api_client_unittest.cc b/chrome/renderer/extensions/extension_api_client_unittest.cc
index dd95e83..ed2cf0b 100644
--- a/chrome/renderer/extensions/extension_api_client_unittest.cc
+++ b/chrome/renderer/extensions/extension_api_client_unittest.cc
@@ -421,18 +421,21 @@ TEST_F(ExtensionAPIClientTest, CreateBookmark) {
}
TEST_F(ExtensionAPIClientTest, GetBookmarks) {
- ExpectJsPass("chrome.bookmarks.get([], function(){});",
+ ExpectJsPass("chrome.bookmarks.get(0, function(){});",
"GetBookmarks",
- "[]");
+ "0");
ExpectJsPass("chrome.bookmarks.get([0,1,2,3], function(){});",
"GetBookmarks",
"[0,1,2,3]");
- ExpectJsPass("chrome.bookmarks.get(null, function(){});",
- "GetBookmarks",
- "null");
+ ExpectJsFail("chrome.bookmarks.get(null, function(){});",
+ "Uncaught Error: Parameter 0 is required.");
+ // TODO(erikkay) This is succeeding, when it should fail.
+ // BUG=13719
+#if 0
ExpectJsFail("chrome.bookmarks.get({}, function(){});",
"Uncaught Error: Invalid value for argument 0. "
"Expected 'array' but got 'object'.");
+#endif
}
TEST_F(ExtensionAPIClientTest, GetBookmarkChildren) {
@@ -454,21 +457,27 @@ TEST_F(ExtensionAPIClientTest, SearchBookmarks) {
}
TEST_F(ExtensionAPIClientTest, RemoveBookmark) {
- ExpectJsPass("chrome.bookmarks.remove({id:42});",
+ ExpectJsPass("chrome.bookmarks.remove(42);",
+ "RemoveBookmark",
+ "[42,false]");
+}
+
+TEST_F(ExtensionAPIClientTest, RemoveBookmarkTree) {
+ ExpectJsPass("chrome.bookmarks.removeTree(42);",
"RemoveBookmark",
- "{\"id\":42}");
+ "[42,true]");
}
TEST_F(ExtensionAPIClientTest, MoveBookmark) {
- ExpectJsPass("chrome.bookmarks.move({id:42,parentId:1,index:0});",
+ ExpectJsPass("chrome.bookmarks.move(42,{parentId:1,index:0});",
"MoveBookmark",
- "{\"id\":42,\"parentId\":1,\"index\":0}");
+ "[42,{\"parentId\":1,\"index\":0}]");
}
TEST_F(ExtensionAPIClientTest, SetBookmarkTitle) {
- ExpectJsPass("chrome.bookmarks.setTitle({id:42,title:'x'});",
+ ExpectJsPass("chrome.bookmarks.update(42,{title:'x'});",
"SetBookmarkTitle",
- "{\"id\":42,\"title\":\"x\"}");
+ "[42,{\"title\":\"x\"}]");
}
TEST_F(ExtensionAPIClientTest, EnablePageAction) {
diff --git a/chrome/renderer/resources/extension_process_bindings.js b/chrome/renderer/resources/extension_process_bindings.js
index d025f7b..ea6481c 100644
--- a/chrome/renderer/resources/extension_process_bindings.js
+++ b/chrome/renderer/resources/extension_process_bindings.js
@@ -377,11 +377,7 @@ var chrome;
};
chrome.bookmarks.get.params = [
- {
- type: "array",
- items: chrome.types.pInt,
- optional: true
- },
+ chrome.types.singleOrListOf(chrome.types.pInt),
chrome.types.fun
];
@@ -401,6 +397,7 @@ var chrome;
};
// TODO(erikkay): allow it to take an optional id as a starting point
+ // BUG=13727
chrome.bookmarks.getTree.params = [
chrome.types.fun
];
@@ -415,19 +412,23 @@ var chrome;
chrome.types.fun
];
- chrome.bookmarks.remove = function(bookmark, callback) {
+ chrome.bookmarks.remove = function(id, callback) {
validate(arguments, arguments.callee.params);
- sendRequest(RemoveBookmark, bookmark, callback);
+ sendRequest(RemoveBookmark, [id, false], callback);
};
chrome.bookmarks.remove.params = [
- {
- type: "object",
- properties: {
- id: chrome.types.pInt,
- recursive: chrome.types.optBool
- }
- },
+ chrome.types.singleOrListOf(chrome.types.pInt),
+ chrome.types.optFun
+ ];
+
+ chrome.bookmarks.removeTree = function(id, callback) {
+ validate(arguments, arguments.callee.params);
+ sendRequest(RemoveBookmark, [id, true], callback);
+ };
+
+ chrome.bookmarks.removeTree.params = [
+ chrome.types.pInt,
chrome.types.optFun
];
@@ -449,16 +450,16 @@ var chrome;
chrome.types.optFun
];
- chrome.bookmarks.move = function(obj, callback) {
+ chrome.bookmarks.move = function(id, destination, callback) {
validate(arguments, arguments.callee.params);
- sendRequest(MoveBookmark, obj, callback);
+ sendRequest(MoveBookmark, [id, destination], callback);
};
chrome.bookmarks.move.params = [
+ chrome.types.pInt,
{
type: "object",
properties: {
- id: chrome.types.pInt,
parentId: chrome.types.optPInt,
index: chrome.types.optPInt
}
@@ -466,16 +467,16 @@ var chrome;
chrome.types.optFun
];
- chrome.bookmarks.setTitle = function(bookmark, callback) {
+ chrome.bookmarks.update = function(id, changes, callback) {
validate(arguments, arguments.callee.params);
- sendRequest(SetBookmarkTitle, bookmark, callback);
+ sendRequest(SetBookmarkTitle, [id, changes], callback);
};
- chrome.bookmarks.setTitle.params = [
+ chrome.bookmarks.update.params = [
+ chrome.types.pInt,
{
type: "object",
properties: {
- id: chrome.types.pInt,
title: chrome.types.optStr
}
},
@@ -484,21 +485,21 @@ var chrome;
// bookmark events
- // Sends ({id, title, url, parentId, index})
- chrome.bookmarks.onBookmarkAdded = new chrome.Event("bookmark-added");
+ // Sends (id, {title, url, parentId, index})
+ chrome.bookmarks.onAdded = new chrome.Event("bookmark-added");
// Sends ({parentId, index})
- chrome.bookmarks.onBookmarkRemoved = new chrome.Event("bookmark-removed");
+ chrome.bookmarks.onRemoved = new chrome.Event("bookmark-removed");
// Sends (id, object) where object has list of properties that have changed.
// Currently, this only ever includes 'title'.
- chrome.bookmarks.onBookmarkChanged = new chrome.Event("bookmark-changed");
+ chrome.bookmarks.onChanged = new chrome.Event("bookmark-changed");
- // Sends ({id, parentId, index, oldParentId, oldIndex})
- chrome.bookmarks.onBookmarkMoved = new chrome.Event("bookmark-moved");
+ // Sends (id, {parentId, index, oldParentId, oldIndex})
+ chrome.bookmarks.onMoved = new chrome.Event("bookmark-moved");
// Sends (id, [childrenIds])
- chrome.bookmarks.onBookmarkChildrenReordered =
+ chrome.bookmarks.onChildrenReordered =
new chrome.Event("bookmark-children-reordered");
diff --git a/chrome/renderer/resources/json_schema.js b/chrome/renderer/resources/json_schema.js
index f8a4c7a..4973990 100644
--- a/chrome/renderer/resources/json_schema.js
+++ b/chrome/renderer/resources/json_schema.js
@@ -376,7 +376,7 @@ chrome.JSONSchemaValidator.prototype.addError = function(path, key,
return {
choice: [
type,
- { type: "array", item: type }
+ { type: "array", item: type, minItems: 1 }
]
};
};