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

Unified Diff: chrome/test/data/extensions/api_test/keybinding/continue_propagation/background.js

Issue 504183004: Continue key propagation for extensions without any listeners to chrome.commands.onCommand. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@lkcr
Patch Set: Add new test. Created 6 years, 4 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/api_test/keybinding/continue_propagation/background.js
diff --git a/chrome/test/data/extensions/api_test/keybinding/continue_propagation/background.js b/chrome/test/data/extensions/api_test/keybinding/continue_propagation/background.js
new file mode 100644
index 0000000000000000000000000000000000000000..ddb0cc6a8c34d02e72c360c6f1dede65fa328635
--- /dev/null
+++ b/chrome/test/data/extensions/api_test/keybinding/continue_propagation/background.js
@@ -0,0 +1,29 @@
+// Copyright 2014 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.
+
+var stage = 'DOM';
Finnur 2014/08/28 11:15:39 Add: // Keeps track of who should be receiving key
David Tseng 2014/08/28 23:37:11 Done.
+
+function gotCommand(command) {
+ if (stage == 'onCommand') {
+ stage = 'DOM';
+ chrome.commands.onCommand.removeListener(gotCommand);
+ chrome.test.notifyPass();
+ } else {
+ chrome.test.notifyFail('Unexpected call to onCommand');
Finnur 2014/08/28 11:15:39 nit: Change error to something like: 'Webpage expe
David Tseng 2014/08/28 23:37:11 Done.
+ }
+}
+
+chrome.extension.onConnect.addListener(function(port) {
+ port.onMessage.addListener(function(message) {
+ if (stage == 'DOM') {
+ stage = 'onCommand';
+ chrome.commands.onCommand.addListener(gotCommand);
+ chrome.test.notifyPass();
+ } else {
+ chrome.test.notifyFail('Unexpected key event on page');
Finnur 2014/08/28 11:15:39 nit: Change error to something like: 'Extension ex
+ }
+ });
+} );
Finnur 2014/08/28 11:15:39 nit: Extra spaces.
+
+chrome.test.notifyPass();

Powered by Google App Engine
This is Rietveld 408576698