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

Side by Side Diff: chrome/browser/apps/guest_view/web_view_interactive_browsertest.cc

Issue 1879453002: Reset Text Input State for RenderWidgetHostView before RenderWidgetHost Detaches from Delegate (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Addressing creis@ comments Created 4 years, 8 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 unified diff | Download patch
OLDNEW
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
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.
1420 IN_PROC_BROWSER_TEST_P(WebViewTextInputStateInteractiveTest, 1418 IN_PROC_BROWSER_TEST_P(WebViewTextInputStateInteractiveTest,
1421 CrashingWebViewResetsState) { 1419 CrashingWebViewResetsState) {
1422 SetupTest("web_view/text_input_state", 1420 SetupTest("web_view/text_input_state",
1423 "/extensions/platform_apps/web_view/text_input_state/guest.html"); 1421 "/extensions/platform_apps/web_view/text_input_state/guest.html");
1424 1422
1425 // Press tab key twice to end up in the <input> of the <webview>, 1423 // Press tab key twice to end up in the <input> of the <webview>.
1426 ExtensionTestMessageListener listener("GUEST-FOCUSED", false); 1424 ExtensionTestMessageListener listener("GUEST-FOCUSED", false);
1427 for (size_t i = 0; i < 2; ++i) 1425 for (size_t i = 0; i < 2; ++i)
1428 SendKeyPressToPlatformApp(ui::VKEY_TAB); 1426 SendKeyPressToPlatformApp(ui::VKEY_TAB);
1429 1427
1430 listener.WaitUntilSatisfied(); 1428 listener.WaitUntilSatisfied();
1431 1429
1432 // Now wait for a text input state change. 1430 // Now wait for a text input state change.
1433 TextInputStateHelper::WaitForDesiredState( 1431 TextInputStateHelper::WaitForDesiredState(
1434 embedder_web_contents(), 1432 embedder_web_contents(),
1435 base::Bind(&TextInputStateHelper::HasGivenValue, "guest")); 1433 base::Bind(&TextInputStateHelper::HasGivenValue, "guest"));
1436 1434
1437 // Now crash the <webview>. 1435 // Now crash the <webview>.
1438 guest_web_contents()->GetRenderProcessHost()->Shutdown(false, 0); 1436 guest_web_contents()->GetRenderProcessHost()->Shutdown(false, 0);
1439 1437
1440 // State should reset to none. 1438 // State should reset to none.
1441 TextInputStateHelper::WaitForDesiredState( 1439 TextInputStateHelper::WaitForDesiredState(
1442 embedder_web_contents(), 1440 embedder_web_contents(),
1443 base::Bind(&TextInputStateHelper::IsStateOfGivenType, 1441 base::Bind(&TextInputStateHelper::IsStateOfGivenType,
1444 ui::TEXT_INPUT_TYPE_NONE)); 1442 ui::TEXT_INPUT_TYPE_NONE));
1445 } 1443 }
1444
1445 // This test creates a <webview> with a text input field inside, gives focus to
1446 // the input field, and then detaches the <webview>. It monitors the embedder
1447 // WebContents text input state to make sure it tracks the state properly.
1448 IN_PROC_BROWSER_TEST_P(WebViewTextInputStateInteractiveTest,
1449 OuterWebContentsResetsStateAfterDetach) {
1450 SetupTest("web_view/text_input_state",
1451 "/extensions/platform_apps/web_view/text_input_state/guest.html");
1452
1453 // Press tab key twice to end up in the <input> of the <webview>.
1454 ExtensionTestMessageListener listener("GUEST-FOCUSED", false);
1455 for (size_t i = 0; i < 2; ++i)
1456 SendKeyPressToPlatformApp(ui::VKEY_TAB);
1457
1458 listener.WaitUntilSatisfied();
1459
1460 // Now wait for a text input state change.
1461 TextInputStateHelper::WaitForDesiredState(
1462 embedder_web_contents(),
1463 base::Bind(&TextInputStateHelper::HasGivenValue, "guest"));
1464
1465 // Now detach the <webview>.
1466 ExtensionTestMessageListener detach_listener("detached", false);
1467 EXPECT_TRUE(
1468 content::ExecuteScript(embedder_web_contents(), "detachWebView();"));
1469 detach_listener.WaitUntilSatisfied();
1470
1471 // State should reset to none.
lazyboy 2016/04/12 04:11:54 nit: TextInputState should reset.
EhsanK 2016/04/12 15:06:49 Done.
1472 TextInputStateHelper::WaitForDesiredState(
1473 embedder_web_contents(),
1474 base::Bind(&TextInputStateHelper::IsStateOfGivenType,
1475 ui::TEXT_INPUT_TYPE_NONE));
1476 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698