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.
5 // Keeps track of who should be receiving keystrokes sent:
6 // The 'webPage' or the 'backgroundPage'.
7 var expectedListener = 'webPage';
9 function gotCommand(command) {
10 if (expectedListener == 'backgroundPage') {
11 expectedListener = 'webPage';
12 chrome.commands.onCommand.removeListener(gotCommand);
13 chrome.test.notifyPass();
15 chrome.test.notifyFail('Webpage expected keystroke, but sent to extension');
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();
26 chrome.test.notifyFail('Extension expected keystroke, but sent to' +
32 chrome.test.notifyPass();