Fixed ExtensionApiTest.Bookmarks and enabled it again.

Also fixed a little nit in the chrome.bookmarks.create() call, which would return the wrong error code when given an invalid URL.

BUG=18979,89762
TEST=ExtensionApiTest.Bookmarks in the browser_tests is green


Review URL: https://chromiumcodereview.appspot.com/10831012

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@148556 0039d316-1c4b-4281-b951-d872f2087c98
parent 64ae25c1
...@@ -504,7 +504,7 @@ bool CreateBookmarkFunction::RunImpl() { ...@@ -504,7 +504,7 @@ bool CreateBookmarkFunction::RunImpl() {
std::string url_string; std::string url_string;
json->GetString(keys::kUrlKey, &url_string); // Optional. json->GetString(keys::kUrlKey, &url_string); // Optional.
GURL url(url_string); GURL url(url_string);
if (!url.is_empty() && !url.is_valid()) { if (!url_string.empty() && !url.is_valid()) {
error_ = keys::kInvalidUrlError; error_ = keys::kInvalidUrlError;
return false; return false;
} }
......
...@@ -4,7 +4,6 @@ ...@@ -4,7 +4,6 @@
#include "chrome/browser/extensions/extension_apitest.h" #include "chrome/browser/extensions/extension_apitest.h"
// Flaky test, http://crbug.com/89762. IN_PROC_BROWSER_TEST_F(ExtensionApiTest, Bookmarks) {
IN_PROC_BROWSER_TEST_F(ExtensionApiTest, DISABLED_Bookmarks) {
ASSERT_TRUE(RunExtensionTest("bookmarks")) << message_; ASSERT_TRUE(RunExtensionTest("bookmarks")) << message_;
} }
...@@ -67,7 +67,7 @@ function compareTrees(left, right, verbose) { ...@@ -67,7 +67,7 @@ function compareTrees(left, right, verbose) {
return true; return true;
} }
if (left == null || right == null) if (left == null || right == null)
return left + " !+ " + right; return left + " != " + right;
if (left.length != right.length) if (left.length != right.length)
return "count mismatch: " + left.length + " != " + right.length; return "count mismatch: " + left.length + " != " + right.length;
for (var i = 0; i < left.length; i++) { for (var i = 0; i < left.length; i++) {
...@@ -177,6 +177,7 @@ chrome.test.runTests([ ...@@ -177,6 +177,7 @@ chrome.test.runTests([
// Make sure the parentId defaults to the Other Bookmarks folder. // Make sure the parentId defaults to the Other Bookmarks folder.
chrome.test.assertEq(expected[0].children[1].id, created.parentId); chrome.test.assertEq(expected[0].children[1].id, created.parentId);
chrome.test.assertTrue(compareNode(node, created)); chrome.test.assertTrue(compareNode(node, created));
expected[0].children[1].children.push(node);
}); });
chrome.bookmarks.create(node, pass(function(results) { chrome.bookmarks.create(node, pass(function(results) {
node.id = results.id; // since we couldn't know this going in node.id = results.id; // since we couldn't know this going in
...@@ -276,12 +277,11 @@ chrome.test.runTests([ ...@@ -276,12 +277,11 @@ chrome.test.runTests([
pass(function(results) { pass(function(results) {
chrome.test.assertEq(results.parentId, other.id); chrome.test.assertEq(results.parentId, other.id);
folder.parentId = results.parentId; folder.parentId = results.parentId;
folder.index = results.index;
var folder2 = expected[0].children[0].children.pop(); var folder2 = expected[0].children[0].children.pop();
folder2.parentId = other.parentId; chrome.test.assertEq(folder2.id, folder.id);
folder2.index = 0;
expected[0].children[1].children.push(folder2); expected[0].children[1].children.push(folder2);
verifyTreeIsExpected(pass()); verifyTreeIsExpected(pass());
})); }));
}, },
...@@ -361,9 +361,9 @@ chrome.test.runTests([ ...@@ -361,9 +361,9 @@ chrome.test.runTests([
// Update expected to match. // Update expected to match.
// We removed node1, which means that the index of the other two nodes // We removed node1, which means that the index of the other two nodes
// changes as well. // changes as well.
expected[0].children[1].children[0].children.shift(); expected[0].children[1].children[1].children.shift();
expected[0].children[1].children[0].children[0].index = 0; expected[0].children[1].children[1].children[0].index = 0;
expected[0].children[1].children[0].children[1].index = 1; expected[0].children[1].children[1].children[1].index = 1;
verifyTreeIsExpected(pass()); verifyTreeIsExpected(pass());
})); }));
...@@ -371,7 +371,7 @@ chrome.test.runTests([ ...@@ -371,7 +371,7 @@ chrome.test.runTests([
function removeTree() { function removeTree() {
var parentId = node2.parentId; var parentId = node2.parentId;
var folder = expected[0].children[1].children[0]; var folder = expected[0].children[1].children[1];
chrome.test.listenOnce(chrome.bookmarks.onRemoved, chrome.test.listenOnce(chrome.bookmarks.onRemoved,
function(id, removeInfo) { function(id, removeInfo) {
chrome.test.assertEq(id, folder.id); chrome.test.assertEq(id, folder.id);
...@@ -380,8 +380,7 @@ chrome.test.runTests([ ...@@ -380,8 +380,7 @@ chrome.test.runTests([
}); });
chrome.bookmarks.removeTree(parentId, pass(function(){ chrome.bookmarks.removeTree(parentId, pass(function(){
// Update expected to match. // Update expected to match.
expected[0].children[1].children.shift(); expected[0].children[1].children.pop();
verifyTreeIsExpected(pass()); verifyTreeIsExpected(pass());
})); }));
}, },
...@@ -436,9 +435,8 @@ chrome.test.runTests([ ...@@ -436,9 +435,8 @@ chrome.test.runTests([
chrome.bookmarks.getChildren(id, pass(function(children) { chrome.bookmarks.getChildren(id, pass(function(children) {
children.forEach(function(child, i) { children.forEach(function(child, i) {
chrome.bookmarks.removeTree(child.id, pass(function() {})); chrome.bookmarks.removeTree(child.id, pass(function() {}));
// When we have removed the last child we can continue. // When we have removed the last child we can continue.
if (i == children.length - 1) if (id == "2" && i == children.length - 1)
afterRemove(); afterRemove();
}); });
})); }));
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment