Chromium Code Reviews| 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(); |