Commit f69da7c8 authored by lazyboy's avatar lazyboy Committed by Commit bot

Fix and enable WebViewInteractiveTest.Focus_InputMethod

There were couple issues that were fixed:
1. If oninput listener fires before the guest is requested to "wait
for oninput", we would timeout. This is taken care of by a flag.
2. TextInputClient::SetCompositionText() call sends an IPC to the
renderer/, if the next JavaScript step runs before the IPC is sent
then that would fail the test. This is taken care of by sending
executing empty JavaScript code on the embedder.

BUG=387956
Test=Internal test only change, nothing visible.

Review URL: https://codereview.chromium.org/532883003

Cr-Commit-Position: refs/heads/master@{#293341}
parent f50622c5
...@@ -1010,7 +1010,7 @@ IN_PROC_BROWSER_TEST_F(WebViewInteractiveTest, Focus_FocusRestored) { ...@@ -1010,7 +1010,7 @@ IN_PROC_BROWSER_TEST_F(WebViewInteractiveTest, Focus_FocusRestored) {
// ui::TextInputClient is NULL for mac and android. // ui::TextInputClient is NULL for mac and android.
#if !defined(OS_MACOSX) && !defined(OS_ANDROID) #if !defined(OS_MACOSX) && !defined(OS_ANDROID)
IN_PROC_BROWSER_TEST_F(WebViewInteractiveTest, DISABLED_Focus_InputMethod) { IN_PROC_BROWSER_TEST_F(WebViewInteractiveTest, Focus_InputMethod) {
content::WebContents* embedder_web_contents = NULL; content::WebContents* embedder_web_contents = NULL;
scoped_ptr<ExtensionTestMessageListener> done_listener( scoped_ptr<ExtensionTestMessageListener> done_listener(
RunAppHelper("testInputMethod", "web_view/focus", NO_TEST_SERVER, RunAppHelper("testInputMethod", "web_view/focus", NO_TEST_SERVER,
...@@ -1062,6 +1062,10 @@ IN_PROC_BROWSER_TEST_F(WebViewInteractiveTest, DISABLED_Focus_InputMethod) { ...@@ -1062,6 +1062,10 @@ IN_PROC_BROWSER_TEST_F(WebViewInteractiveTest, DISABLED_Focus_InputMethod) {
ui::CompositionText composition; ui::CompositionText composition;
composition.text = base::UTF8ToUTF16("InputTest789"); composition.text = base::UTF8ToUTF16("InputTest789");
text_input_client->SetCompositionText(composition); text_input_client->SetCompositionText(composition);
// Do a roundtrip to the renderer so that in-flight IPC from
// SetCompositionText() above gets routed before the next step.
// The test becomes flaky otherwise.
EXPECT_TRUE(content::ExecuteScript(embedder_web_contents, std::string()));
EXPECT_TRUE(content::ExecuteScript( EXPECT_TRUE(content::ExecuteScript(
embedder_web_contents, embedder_web_contents,
"window.runCommand('testInputMethodRunNextStep', 3);")); "window.runCommand('testInputMethodRunNextStep', 3);"));
......
...@@ -15,6 +15,18 @@ var sendMessage = function(data) { ...@@ -15,6 +15,18 @@ var sendMessage = function(data) {
embedder.postMessage(JSON.stringify(data), '*'); embedder.postMessage(JSON.stringify(data), '*');
}; };
var waitingForInput = false;
var onInputFired = function() {
sendMessage(['response-waitForOnInput', onInputState.value]);
onInputState.fired = false;
if (inputElement1.value == 'InputTest456') {
// Prepare for next step, step 3.
inputElement1.value = '';
}
waitingForInput = false;
};
var onInputState = {fired: false, value: ''}; var onInputState = {fired: false, value: ''};
// Waits for oninput event to fire on |inputElement1|. // Waits for oninput event to fire on |inputElement1|.
// Upon receiving the event, we ping back the embedder with the value of // Upon receiving the event, we ping back the embedder with the value of
...@@ -23,13 +35,9 @@ var waitForOnInput = function() { ...@@ -23,13 +35,9 @@ var waitForOnInput = function() {
var inputElement1 = document.querySelector('input'); var inputElement1 = document.querySelector('input');
LOG('inputElement1: ' + inputElement1); LOG('inputElement1: ' + inputElement1);
if (onInputState.fired) { if (onInputState.fired) {
sendMessage(['response-waitForOnInput', onInputState.value]); onInputFired();
} else {
onInputState.fired = false; waitingForInput = true;
if (inputElement1.value == 'InputTest456') {
// Prepare for next step, step 3.
inputElement1.value = '';
}
} }
}; };
...@@ -41,6 +49,9 @@ var waitForFocus = function() { ...@@ -41,6 +49,9 @@ var waitForFocus = function() {
LOG('inputElement1.oninput: ' + inputElement1.value); LOG('inputElement1.oninput: ' + inputElement1.value);
onInputState.fired = true; onInputState.fired = true;
onInputState.value = inputElement1.value; onInputState.value = inputElement1.value;
if (waitingForInput) {
onInputFired();
}
}; };
var inputElement1FocusListener = function() { var inputElement1FocusListener = function() {
LOG('inputElement1.focus'); LOG('inputElement1.focus');
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment