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

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: Change manifest to use MacCtrl. Created 6 years, 3 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..88338a1a0f1cb0e6e3a1be5dc7be24ffcf1e6b68
--- /dev/null
+++ b/chrome/test/data/extensions/api_test/keybinding/continue_propagation/background.js
@@ -0,0 +1,32 @@
+// 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.
+
+// Keeps track of who should be receiving keystrokes sent:
+// The 'webPage' or the 'backgroundPage'.
+var expectedListener = 'webPage';
+
+function gotCommand(command) {
+ if (expectedListener == 'backgroundPage') {
+ expectedListener = 'webPage';
+ chrome.commands.onCommand.removeListener(gotCommand);
+ chrome.test.notifyPass();
+ } else {
+ chrome.test.notifyFail('Webpage expected keystroke, but sent to extension');
+ }
+}
+
+chrome.extension.onConnect.addListener(function(port) {
+ port.onMessage.addListener(function(message) {
+ if (expectedListener == 'webPage') {
+ expectedListener = 'backgroundPage';
+ chrome.commands.onCommand.addListener(gotCommand);
+ chrome.test.notifyPass();
+ } else {
+ chrome.test.notifyFail('Extension expected keystroke, but sent to' +
+ ' webpage');
+ }
+ });
+});
+
+chrome.test.notifyPass();

Powered by Google App Engine
This is Rietveld 408576698