OLD | NEW |
(Empty) | |
| 1 // Copyright 2015 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 window.onload = function() { |
| 6 chrome.contextMenus.create({ |
| 7 id: 'id1', |
| 8 title: 'Menu item 1', |
| 9 onclick: function() { |
| 10 chrome.test.sendMessage('onclick1-unexpected'); |
| 11 } |
| 12 }, onCreatedFirstMenu); |
| 13 }; |
| 14 |
| 15 function onCreatedFirstMenu() { |
| 16 chrome.contextMenus.update('id1', { |
| 17 onclick: null |
| 18 }, function() { |
| 19 chrome.test.sendMessage('update1', function() { |
| 20 // Now create another context menu item, to test whether adding and |
| 21 // updating a context menu with a new onclick handler works. |
| 22 // Upon completing that test, we will also know whether menu 1's initial |
| 23 // onclick attribute has been triggered unexpectedly. |
| 24 createSecondMenu(); |
| 25 }); |
| 26 }); |
| 27 } |
| 28 |
| 29 function createSecondMenu() { |
| 30 chrome.contextMenus.create({ |
| 31 id: 'id2', |
| 32 title: 'Menu item 2', |
| 33 onclick: function() { |
| 34 chrome.test.sendMessage('onclick2-unexpected'); |
| 35 } |
| 36 }, function() { |
| 37 chrome.contextMenus.update('id2', { |
| 38 onclick: function() { |
| 39 chrome.test.sendMessage('onclick2'); |
| 40 } |
| 41 }, function() { |
| 42 chrome.test.sendMessage('update2'); |
| 43 }); |
| 44 }); |
| 45 } |
OLD | NEW |