| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include <stddef.h> | 5 #include <stddef.h> |
| 6 | 6 |
| 7 #include "base/location.h" | 7 #include "base/location.h" |
| 8 #include "base/macros.h" | 8 #include "base/macros.h" |
| 9 #include "base/single_thread_task_runner.h" | 9 #include "base/single_thread_task_runner.h" |
| 10 #include "base/strings/stringprintf.h" | 10 #include "base/strings/stringprintf.h" |
| (...skipping 1397 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1408 embedder_web_contents(), get_type_checker(ui::TEXT_INPUT_TYPE_TEXT)); | 1408 embedder_web_contents(), get_type_checker(ui::TEXT_INPUT_TYPE_TEXT)); |
| 1409 | 1409 |
| 1410 // Press the tab key one more time to get back to embedder's second <input>. | 1410 // Press the tab key one more time to get back to embedder's second <input>. |
| 1411 // The value should be "last one". | 1411 // The value should be "last one". |
| 1412 press_tab_to_focus(this, "EMBEDDER-FOCUSED-2"); | 1412 press_tab_to_focus(this, "EMBEDDER-FOCUSED-2"); |
| 1413 TextInputStateHelper::WaitForDesiredState( | 1413 TextInputStateHelper::WaitForDesiredState( |
| 1414 embedder_web_contents(), | 1414 embedder_web_contents(), |
| 1415 base::Bind(&TextInputStateHelper::HasGivenValue, "last one")); | 1415 base::Bind(&TextInputStateHelper::HasGivenValue, "last one")); |
| 1416 } | 1416 } |
| 1417 | 1417 |
| 1418 // TODO(ekaramad): Activate this test for OOPIF when input event routing for |
| 1419 // OOPIF-<webview> is fixed. |
| 1418 IN_PROC_BROWSER_TEST_P(WebViewTextInputStateInteractiveTest, | 1420 IN_PROC_BROWSER_TEST_P(WebViewTextInputStateInteractiveTest, |
| 1419 CrashingWebViewResetsState) { | 1421 CrashingWebViewResetsState) { |
| 1420 SetupTest("web_view/text_input_state", | 1422 SetupTest("web_view/text_input_state", |
| 1421 "/extensions/platform_apps/web_view/text_input_state/guest.html"); | 1423 "/extensions/platform_apps/web_view/text_input_state/guest.html"); |
| 1422 | 1424 |
| 1423 // Press tab key twice to end up in the <input> of the <webview>. | 1425 // Press tab key twice to end up in the <input> of the <webview>, |
| 1424 ExtensionTestMessageListener listener("GUEST-FOCUSED", false); | 1426 ExtensionTestMessageListener listener("GUEST-FOCUSED", false); |
| 1425 for (size_t i = 0; i < 2; ++i) | 1427 for (size_t i = 0; i < 2; ++i) |
| 1426 SendKeyPressToPlatformApp(ui::VKEY_TAB); | 1428 SendKeyPressToPlatformApp(ui::VKEY_TAB); |
| 1427 | 1429 |
| 1428 listener.WaitUntilSatisfied(); | 1430 listener.WaitUntilSatisfied(); |
| 1429 | 1431 |
| 1430 // Now wait for a text input state change. | 1432 // Now wait for a text input state change. |
| 1431 TextInputStateHelper::WaitForDesiredState( | 1433 TextInputStateHelper::WaitForDesiredState( |
| 1432 embedder_web_contents(), | 1434 embedder_web_contents(), |
| 1433 base::Bind(&TextInputStateHelper::HasGivenValue, "guest")); | 1435 base::Bind(&TextInputStateHelper::HasGivenValue, "guest")); |
| 1434 | 1436 |
| 1435 // Now crash the <webview>. | 1437 // Now crash the <webview>. |
| 1436 guest_web_contents()->GetRenderProcessHost()->Shutdown(false, 0); | 1438 guest_web_contents()->GetRenderProcessHost()->Shutdown(false, 0); |
| 1437 | 1439 |
| 1438 // Wait for the outer WebContentsImpl |text_input_state_->type| to be reset to | 1440 // State should reset to none. |
| 1439 // none. | |
| 1440 TextInputStateHelper::WaitForDesiredState( | 1441 TextInputStateHelper::WaitForDesiredState( |
| 1441 embedder_web_contents(), | 1442 embedder_web_contents(), |
| 1442 base::Bind(&TextInputStateHelper::IsStateOfGivenType, | 1443 base::Bind(&TextInputStateHelper::IsStateOfGivenType, |
| 1443 ui::TEXT_INPUT_TYPE_NONE)); | 1444 ui::TEXT_INPUT_TYPE_NONE)); |
| 1444 } | 1445 } |
| 1445 | |
| 1446 // This test creates a <webview> with a text input field inside, gives focus to | |
| 1447 // the input field, and then detaches the <webview>. It monitors the embedder | |
| 1448 // WebContents text input state to make sure it tracks the state properly. | |
| 1449 IN_PROC_BROWSER_TEST_P(WebViewTextInputStateInteractiveTest, | |
| 1450 OuterWebContentsResetsStateAfterDetach) { | |
| 1451 SetupTest("web_view/text_input_state", | |
| 1452 "/extensions/platform_apps/web_view/text_input_state/guest.html"); | |
| 1453 | |
| 1454 // Press tab key twice to end up in the <input> of the <webview>. | |
| 1455 ExtensionTestMessageListener listener("GUEST-FOCUSED", false); | |
| 1456 for (size_t i = 0; i < 2; ++i) | |
| 1457 SendKeyPressToPlatformApp(ui::VKEY_TAB); | |
| 1458 | |
| 1459 listener.WaitUntilSatisfied(); | |
| 1460 | |
| 1461 // Now wait for a text input state change. | |
| 1462 TextInputStateHelper::WaitForDesiredState( | |
| 1463 embedder_web_contents(), | |
| 1464 base::Bind(&TextInputStateHelper::HasGivenValue, "guest")); | |
| 1465 | |
| 1466 // Now detach the <webview>. | |
| 1467 ExtensionTestMessageListener detach_listener("detached", false); | |
| 1468 detach_listener.set_failure_message("failed-to-detach"); | |
| 1469 EXPECT_TRUE( | |
| 1470 content::ExecuteScript(embedder_web_contents(), "detachWebView();")); | |
| 1471 detach_listener.WaitUntilSatisfied(); | |
| 1472 | |
| 1473 // Wait for the outer WebContentsImpl |text_input_state_->type| to be reset to | |
| 1474 // none. | |
| 1475 TextInputStateHelper::WaitForDesiredState( | |
| 1476 embedder_web_contents(), | |
| 1477 base::Bind(&TextInputStateHelper::IsStateOfGivenType, | |
| 1478 ui::TEXT_INPUT_TYPE_NONE)); | |
| 1479 } | |
| OLD | NEW |