OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 // A generic onclick callback function. | 5 // A generic onclick callback function. |
6 function genericOnClick(info, tab) { | 6 function genericOnClick(info, tab) { |
7 console.log("item " + info.menuItemId + " was clicked"); | 7 console.log("item " + info.menuItemId + " was clicked"); |
8 console.log("info: " + JSON.stringify(info)); | 8 console.log("info: " + JSON.stringify(info)); |
9 console.log("tab: " + JSON.stringify(tab)); | 9 console.log("tab: " + JSON.stringify(tab)); |
10 } | 10 } |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
56 var checkbox2 = chrome.contextMenus.create( | 56 var checkbox2 = chrome.contextMenus.create( |
57 {"title": "Checkbox2", "type": "checkbox", "onclick":checkboxOnClick}); | 57 {"title": "Checkbox2", "type": "checkbox", "onclick":checkboxOnClick}); |
58 console.log("checkbox1:" + checkbox1 + " checkbox2:" + checkbox2); | 58 console.log("checkbox1:" + checkbox1 + " checkbox2:" + checkbox2); |
59 | 59 |
60 | 60 |
61 // Intentionally create an invalid item, to show off error checking in the | 61 // Intentionally create an invalid item, to show off error checking in the |
62 // create callback. | 62 // create callback. |
63 console.log("About to try creating an invalid item - an error about " + | 63 console.log("About to try creating an invalid item - an error about " + |
64 "item 999 should show up"); | 64 "item 999 should show up"); |
65 chrome.contextMenus.create({"title": "Oops", "parentId":999}, function() { | 65 chrome.contextMenus.create({"title": "Oops", "parentId":999}, function() { |
66 if (chrome.extension.lastError) { | 66 if (chrome.runtime.lastError) { |
67 console.log("Got expected error: " + chrome.extension.lastError.message); | 67 console.log("Got expected error: " + chrome.runtime.lastError.message); |
68 } | 68 } |
69 }); | 69 }); |
OLD | NEW |