Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(5296)

Unified Diff: chrome/test/data/extensions/context_menus/onclick_null/test.js

Issue 948243005: Merge custom bindings for context menus (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Nits and tests Created 5 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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');
+ });
+ });
+}

Powered by Google App Engine
This is Rietveld 408576698