OLD | NEW |
(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(); |
OLD | NEW |