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..06d173f4beadf7a58a3d801b71c7edb04e4bcb38 |
--- /dev/null |
+++ b/chrome/test/data/extensions/context_menus/onclick_null/test.js |
@@ -0,0 +1,45 @@ |
+// Copyright 2015 The Chromium Authors. All rights reserved. |
+// 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: 'id1', |
+ title: 'Menu item 1', |
+ onclick: function() { |
+ chrome.test.sendMessage('onclick1-unexpected'); |
+ } |
+ }, onCreatedFirstMenu); |
+}; |
+ |
+function onCreatedFirstMenu() { |
+ chrome.contextMenus.update('id1', { |
+ onclick: null |
+ }, function() { |
+ chrome.test.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.test.sendMessage('onclick2-unexpected'); |
+ } |
+ }, function() { |
+ chrome.contextMenus.update('id2', { |
+ onclick: function() { |
+ chrome.test.sendMessage('onclick2'); |
+ } |
+ }, function() { |
+ chrome.test.sendMessage('update2'); |
+ }); |
+ }); |
+} |