Chromium Code Reviews| Index: chrome/test/data/extensions/platform_apps/web_view/focus/inject_focus.js |
| diff --git a/chrome/test/data/extensions/platform_apps/web_view/focus/inject_focus.js b/chrome/test/data/extensions/platform_apps/web_view/focus/inject_focus.js |
| index c8c3c81045b7ce7aca4200ea35431b4925898b60..76619a2960598752544c7e87ee078484de4e1e5e 100644 |
| --- a/chrome/test/data/extensions/platform_apps/web_view/focus/inject_focus.js |
| +++ b/chrome/test/data/extensions/platform_apps/web_view/focus/inject_focus.js |
| @@ -12,6 +12,7 @@ var LOG = function(msg) { |
| }; |
| var sendMessage = function(data) { |
| + window.console.log('replying with data" '+ JSON.stringify(data)); |
|
alexmos
2016/06/24 01:38:50
Was this for debugging? (Or, if you wanted to kee
avallee
2016/07/25 19:02:05
It was, delorted.
alexmos
2016/07/26 21:08:30
This is still present in PS12.
avallee
2016/07/27 21:35:01
Done.
|
| embedder.postMessage(JSON.stringify(data), '*'); |
| }; |
| @@ -47,6 +48,28 @@ var waitForFocus = function() { |
| inputElement.focus(); |
| }; |
| +var createInput = function(count) { |
| + inputElement = document.createElement('input'); |
| + inputElement.eventCount = count; |
| + inputElement.addEventListener('input', function(e) { |
| + inputElement.eventCount -= 1; |
| + if (inputElement.eventCount <= 0 && inputElement.signalOnInput) { |
| + sendMessage(['response-inputValue', inputElement.value]); |
| + } |
| + }); |
| + |
| + document.body.appendChild(inputElement); |
| + sendMessage(['response-createdInput']); |
| +}; |
| + |
| +var getInputValue = function() { |
| + if (inputElement.eventCount <= 0) { |
| + sendMessage(['response-inputValue', inputElement.value]); |
| + } else { |
| + inputElement.signalOnInput = true; |
| + } |
| +} |
| + |
| window.addEventListener('message', function(e) { |
| var data = JSON.parse(e.data); |
| if (data[0] == 'connect') { |
| @@ -59,6 +82,10 @@ window.addEventListener('message', function(e) { |
| waitForFocus(); |
| } else if (data[0] == 'request-waitForBlurAfterFocus') { |
| waitForBlurAfterFocus(); |
| + } else if (data[0] == 'request-createInput') { |
| + createInput(data[1]); |
| + } else if (data[0] == 'request-getInputValue') { |
| + getInputValue(); |
| } |
| }); |