- add sources.
[platform/framework/web/crosswalk.git] / src / chrome / test / data / extensions / api_test / context_menus / item_ids / test.js
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
3 // found in the LICENSE file.
4
5 chrome.test.runTests([
6   function stringID() {
7     var id1 = chrome.contextMenus.create(
8         {"id": "id1", "title": "title1"}, function() {
9           chrome.test.assertNoLastError();
10           chrome.test.assertEq("id1", id1);
11           chrome.contextMenus.remove("id1", chrome.test.callbackPass());
12     });
13   },
14
15   function parentStringID() {
16     chrome.contextMenus.create({"id": "id1", "title": "title1"}, function() {
17       chrome.test.assertNoLastError();
18       chrome.contextMenus.create(
19           {"title": "title2", "parentId": "id1"}, function() {
20         chrome.test.assertNoLastError();
21         chrome.contextMenus.create(
22             {"id": "id3", "title": "title3"}, function() {
23           chrome.test.assertNoLastError();
24           chrome.contextMenus.update("id3", {"parentId": "id1"},
25                                      chrome.test.callbackPass());
26         });
27       });
28     });
29   },
30
31   function idCollision() {
32     chrome.contextMenus.create({"id": "mine", "title": "first"}, function() {
33       chrome.contextMenus.create({"id": "mine", "title": "second"},
34       chrome.test.callbackFail("Cannot create item with duplicate id mine"));
35     });
36   },
37
38   function idNonCollision() {
39     var intId = chrome.contextMenus.create({"title": "int17"}, function() {
40       chrome.test.assertNoLastError();
41       var stringId = String(intId);
42       chrome.contextMenus.create(
43           {"id": stringId, "title": "string17"}, function() {
44         chrome.test.assertNoLastError();
45         chrome.contextMenus.remove(intId, function() {
46           chrome.test.assertNoLastError();
47           chrome.contextMenus.remove(stringId, chrome.test.callbackPass());
48         });
49       });
50     });
51   }
52 ]);