Chromium Code Reviews| Index: chrome/test/data/extensions/context_menus/onclick_null/test.js |
| diff --git a/chrome/test/data/extensions/context_menus/onclick_null/test.js b/chrome/test/data/extensions/context_menus/onclick_null/test.js |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..ca6602c3493ed4ac0d60eef6ea2264db4c5306de |
| --- /dev/null |
| +++ b/chrome/test/data/extensions/context_menus/onclick_null/test.js |
| @@ -0,0 +1,45 @@ |
| +// Copyright (c) 2015 The Chromium Authors. All rights reserved. |
|
lazyboy
2015/02/26 00:39:47
nit: new style is to ommit "(c)"
robwu
2015/02/26 09:33:46
Done.
|
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +window.onload = function() { |
| + chrome.contextMenus.create({ |
| + id: 'id', |
| + title: 'Menu item', |
| + onclick: function() { |
| + chrome.runtime.sendMessage('onclick-unexpected'); |
| + } |
| + }, onCreatedFirstMenu); |
| +}; |
| + |
| +function onCreatedFirstMenu() { |
| + chrome.contextMenus.update('id', { |
| + onclick: null |
| + }, function() { |
| + chrome.runtime.sendMessage('update1', function() { |
| + // Now create another context menu item, to test whether adding and |
| + // updating a context menu with a new onclick handler works. |
| + // Upon completing that test, we will also know whether menu 1's initial |
| + // onclick attribute has been triggered unexpectedly. |
| + createSecondMenu(); |
| + }); |
| + }); |
| +} |
| + |
| +function createSecondMenu() { |
| + chrome.contextMenus.create({ |
| + id: 'id2', |
| + title: 'Menu item 2', |
| + onclick: function() { |
| + chrome.runtime.sendMessage('onclick2-unexpected'); |
| + } |
| + }, function() { |
| + chrome.contextMenus.update('id2', { |
| + onclick: function() { |
| + chrome.runtime.sendMessage('onclick2'); |
| + } |
| + }, function() { |
| + chrome.runtime.sendMessage('update2'); |
| + }); |
| + }); |
| +} |