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

Unified Diff: chrome/test/data/extensions/platform_apps/web_view/focus/embedder.js

Issue 1934703002: Fix keyboard focus for OOPIF-<webview>. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fixed test flakiness and comments in PS 7,8. Created 4 years, 6 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 side-by-side diff with in-line comments
Download patch
Index: chrome/test/data/extensions/platform_apps/web_view/focus/embedder.js
diff --git a/chrome/test/data/extensions/platform_apps/web_view/focus/embedder.js b/chrome/test/data/extensions/platform_apps/web_view/focus/embedder.js
index 51bf561d29de7f6e94db79fbd6e0c7fdec59b2e2..34fa20cde7f219fe4148436f9ada20f4ad31ff1a 100644
--- a/chrome/test/data/extensions/platform_apps/web_view/focus/embedder.js
+++ b/chrome/test/data/extensions/platform_apps/web_view/focus/embedder.js
@@ -33,6 +33,10 @@ window.runCommand = function(command, opt_step) {
break;
case 'testFocusRestoredRunNextStep':
testFocusRestoredRunNextStep(opt_step);
+ break;
+ case 'testKeyboardFocusRunNextStep':
+ testKeyboardFocusRunNextStep(opt_step);
+ break;
default:
embedder.test.fail();
}
@@ -389,6 +393,50 @@ function testBlurEvent() {
});
}
+// This test verifies that keyboard input is correctly routed into the guest.
+//
+// 1) Load the guest and attach an <input> to the guest dom. Count the number of
+// input events sent to that element.
+// 2) C++ simulates a mouse over and click of the <input> element and waits for
+// the browser to see the guest main frame as focused.
+// 3) Injects the key sequence: a, Shift+b, c.
+// 4) In the second step, the test waits for the input events to be processed
+// and then expects the vaue of the <input> to be what the test sent, notably:
+// aBc.
+function testKeyboardFocus() {
+ embedder.testFocus_(function(webview) {
+ var created = function(e) {
+ var data = JSON.parse(e.data);
+ if (data[0] === 'response-createdInput') {
+ chrome.test.sendMessage('TEST_PASSED');
+ window.removeEventListener('message', created);
+ }
+ };
+ window.addEventListener('message', created);
+
+ g_webview = webview;
+ var msg = ['request-createInput', 3];
+ webview.contentWindow.postMessage(JSON.stringify(msg), '*');
+ }, null, null);
+}
+
+function testKeyboardFocusRunNextStep(expected) {
+ g_webview.contentWindow.postMessage(
+ JSON.stringify(['request-getInputValue']), '*');
+
+ window.addEventListener('message', function(e) {
+ var data = JSON.parse(e.data);
+ LOG('send window.message, data: ' + data);
+ if (data[0] == 'response-inputValue') {
+ if(data[1] == expected) {
alexmos 2016/06/24 01:38:49 nit: space after if
avallee 2016/07/25 19:02:05 Done.
+ chrome.test.sendMessage('TEST_STEP_PASSED');
+ } else {
+ chrome.test.sendMessage('TEST_STEP_FAILED');
+ }
+ }
+ });
+}
+
// This test verifies IME related stuff for guest.
//
// Briefly:
@@ -598,6 +646,7 @@ embedder.test.testList = {
'testFocusEvent': testFocusEvent,
'testFocusTracksEmbedder': testFocusTracksEmbedder,
'testInputMethod': testInputMethod,
+ 'testKeyboardFocus': testKeyboardFocus,
'testFocusRestored': testFocusRestored
};

Powered by Google App Engine
This is Rietveld 408576698