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

Side by Side Diff: chrome/test/data/extensions/api_test/bookmark_manager/standard/test.js

Issue 606923002: Protect against setting meta info on unmodifiable nodes. (Closed) Base URL: https://chromium.googlesource.com/chromium/src@master
Patch Set: Extra test Created 6 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 unified diff | Download patch
« no previous file with comments | « chrome/browser/extensions/api/bookmark_manager_private/bookmark_manager_private_api.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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;
(...skipping 323 matching lines...) Expand 10 before | Expand all | Expand 10 after
334 bookmarkManager.setMetaInfo(nodeA.id, 'meta2', 'foo'); 334 bookmarkManager.setMetaInfo(nodeA.id, 'meta2', 'foo');
335 bookmarkManager.getMetaInfo(nodeA.id, 'meta', pass(function(result) { 335 bookmarkManager.getMetaInfo(nodeA.id, 'meta', pass(function(result) {
336 assertEq('bla', result); 336 assertEq('bla', result);
337 })); 337 }));
338 338
339 bookmarkManager.getMetaInfo(nodeA.id, pass(function(result) { 339 bookmarkManager.getMetaInfo(nodeA.id, pass(function(result) {
340 assertEq({meta: 'bla', meta2: 'foo'}, result); 340 assertEq({meta: 'bla', meta2: 'foo'}, result);
341 })); 341 }));
342 }, 342 },
343 343
344 function setMetaInfoPermanent() {
345 bookmarks.getTree(pass(function(nodes) {
346 var unmodifiableFolder = nodes[0].children[0];
347 bookmarkManager.setMetaInfo(unmodifiableFolder.id, 'meta', 'foo', fail(
348 "Can't modify the root bookmark folders."));
349 bookmarkManager.updateMetaInfo(unmodifiableFolder.id, {a: 'a', b: 'b'},
350 fail("Can't modify the root bookmark folders."));
351 }));
352 },
353
354 function setMetaInfoManaged() {
355 bookmarks.getChildren('4', pass(function(result) {
356 assertTrue(result.length > 0);
357 bookmarkManager.setMetaInfo(result[0].id, 'meta', 'foo', fail(
358 "Can't modify managed bookmarks."));
359 bookmarkManager.updateMetaInfo(result[0].id, {a: 'a', b: 'b'},
360 fail("Can't modify managed bookmarks."));
361 }));
362 },
363
344 function updateMetaInfo() { 364 function updateMetaInfo() {
345 bookmarkManager.getMetaInfo(nodeB.id, pass(function(result){ 365 bookmarkManager.getMetaInfo(nodeB.id, pass(function(result){
346 assertEq({}, result); 366 assertEq({}, result);
347 })); 367 }));
348 368
349 chrome.test.listenOnce(bookmarkManager.onMetaInfoChanged, pass( 369 chrome.test.listenOnce(bookmarkManager.onMetaInfoChanged, pass(
350 function(id, changes) { 370 function(id, changes) {
351 assertEq(nodeB.id, id); 371 assertEq(nodeB.id, id);
352 assertEq({a: 'a', b: 'b', c: 'c'}, changes); 372 assertEq({a: 'a', b: 'b', c: 'c'}, changes);
353 })); 373 }));
(...skipping 23 matching lines...) Expand all
377 })); 397 }));
378 bookmarkManager.createWithMetaInfo(node, metaInfo, pass( 398 bookmarkManager.createWithMetaInfo(node, metaInfo, pass(
379 function(createdNode) { 399 function(createdNode) {
380 assertEq(node.title, createdNode.title); 400 assertEq(node.title, createdNode.title);
381 assertEq(node.url, createdNode.url); 401 assertEq(node.url, createdNode.url);
382 })); 402 }));
383 } 403 }
384 ]; 404 ];
385 405
386 chrome.test.runTests(tests); 406 chrome.test.runTests(tests);
OLDNEW
« no previous file with comments | « chrome/browser/extensions/api/bookmark_manager_private/bookmark_manager_private_api.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698