| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 // Bookmark Manager API test for Chrome. | 5 // Bookmark Manager API test for Chrome. |
| 6 // browser_tests.exe --gtest_filter=ExtensionApiTest.BookmarkManager | 6 // browser_tests.exe --gtest_filter=ExtensionApiTest.BookmarkManager |
| 7 | 7 |
| 8 const pass = chrome.test.callbackPass; | 8 const pass = chrome.test.callbackPass; |
| 9 const fail = chrome.test.callbackFail; | 9 const fail = chrome.test.callbackFail; |
| 10 const assertEq = chrome.test.assertEq; | 10 const assertEq = chrome.test.assertEq; |
| 11 const assertTrue = chrome.test.assertTrue; | 11 const assertTrue = chrome.test.assertTrue; |
| 12 const assertFalse = chrome.test.assertFalse; |
| 12 const bookmarks = chrome.bookmarks; | 13 const bookmarks = chrome.bookmarks; |
| 13 const bookmarkManager = chrome.bookmarkManagerPrivate; | 14 const bookmarkManager = chrome.bookmarkManagerPrivate; |
| 14 var fooNode, fooNode2, barNode, gooNode, count, emptyFolder, emptyFolder2; | 15 var fooNode, fooNode2, barNode, gooNode, count, emptyFolder, emptyFolder2; |
| 15 var folder, nodeA, nodeB; | 16 var folder, nodeA, nodeB; |
| 16 var childFolder, grandChildFolder, childNodeA, childNodeB; | 17 var childFolder, grandChildFolder, childNodeA, childNodeB; |
| 17 | 18 |
| 18 var clipboardArguments; | 19 var clipboardArguments; |
| 19 function doCopy() { | 20 function doCopy() { |
| 20 clipboardArguments = arguments; | 21 clipboardArguments = arguments; |
| 21 document.execCommand('copy'); | 22 document.execCommand('copy'); |
| (...skipping 265 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 287 assertTrue(foo2Index + 1 < result.length); | 288 assertTrue(foo2Index + 1 < result.length); |
| 288 | 289 |
| 289 emptyFolder2 = result[foo2Index + 1]; | 290 emptyFolder2 = result[foo2Index + 1]; |
| 290 | 291 |
| 291 assertEq(emptyFolder2.title, emptyFolder.title); | 292 assertEq(emptyFolder2.title, emptyFolder.title); |
| 292 assertEq(emptyFolder2.url, emptyFolder.url); | 293 assertEq(emptyFolder2.url, emptyFolder.url); |
| 293 assertEq(emptyFolder2.parentId, emptyFolder.parentId); | 294 assertEq(emptyFolder2.parentId, emptyFolder.parentId); |
| 294 })); | 295 })); |
| 295 }, | 296 }, |
| 296 | 297 |
| 298 function clipboard6() { |
| 299 // Verify that we can't cut managed folders. |
| 300 bookmarks.getChildren('4', pass(function(result) { |
| 301 assertEq(2, result.length); |
| 302 const error = "Can't modify managed bookmarks."; |
| 303 bookmarkManager.cut([ result[0].id ], fail(error)); |
| 304 |
| 305 // Copying is fine. |
| 306 bookmarkManager.copy([ result[0].id ], pass()); |
| 307 |
| 308 // Pasting to a managed folder is not allowed. |
| 309 assertTrue(result[1].url === undefined); |
| 310 bookmarkManager.canPaste(result[1].id, pass(function(result) { |
| 311 assertFalse(result, 'Should not be able to paste to managed folders.'); |
| 312 })); |
| 313 |
| 314 bookmarkManager.paste(result[1].id, fail(error)); |
| 315 })); |
| 316 }, |
| 317 |
| 297 function canEdit() { | 318 function canEdit() { |
| 298 bookmarkManager.canEdit(pass(function(result) { | 319 bookmarkManager.canEdit(pass(function(result) { |
| 299 assertTrue(result, 'Should be able to edit bookmarks'); | 320 assertTrue(result, 'Should be able to edit bookmarks'); |
| 300 })); | 321 })); |
| 301 }, | 322 }, |
| 302 | 323 |
| 303 function getSetMetaInfo() { | 324 function getSetMetaInfo() { |
| 304 bookmarkManager.getMetaInfo(nodeA.id, 'meta', pass(function(result) { | 325 bookmarkManager.getMetaInfo(nodeA.id, 'meta', pass(function(result) { |
| 305 assertTrue(!result); | 326 assertTrue(!result); |
| 306 })); | 327 })); |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 356 })); | 377 })); |
| 357 bookmarkManager.createWithMetaInfo(node, metaInfo, pass( | 378 bookmarkManager.createWithMetaInfo(node, metaInfo, pass( |
| 358 function(createdNode) { | 379 function(createdNode) { |
| 359 assertEq(node.title, createdNode.title); | 380 assertEq(node.title, createdNode.title); |
| 360 assertEq(node.url, createdNode.url); | 381 assertEq(node.url, createdNode.url); |
| 361 })); | 382 })); |
| 362 } | 383 } |
| 363 ]; | 384 ]; |
| 364 | 385 |
| 365 chrome.test.runTests(tests); | 386 chrome.test.runTests(tests); |
| OLD | NEW |