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

Side by Side 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 unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 // Keeps track of who should be receiving keystrokes sent:
6 // The 'webPage' or the 'backgroundPage'.
7 var expectedListener = 'webPage';
8
9 function gotCommand(command) {
10 if (expectedListener == 'backgroundPage') {
11 expectedListener = 'webPage';
12 chrome.commands.onCommand.removeListener(gotCommand);
13 chrome.test.notifyPass();
14 } else {
15 chrome.test.notifyFail('Webpage expected keystroke, but sent to extension');
16 }
17 }
18
19 chrome.extension.onConnect.addListener(function(port) {
20 port.onMessage.addListener(function(message) {
21 if (expectedListener == 'webPage') {
22 expectedListener = 'backgroundPage';
23 chrome.commands.onCommand.addListener(gotCommand);
24 chrome.test.notifyPass();
25 } else {
26 chrome.test.notifyFail('Extension expected keystroke, but sent to' +
27 ' webpage');
28 }
29 });
30 });
31
32 chrome.test.notifyPass();
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698