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

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 lazyboy@ comment 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
« no previous file with comments | « no previous file | chrome/test/data/extensions/platform_apps/web_view/text_input_state/window.js » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 // Wait for the outer WebContentsImpl |text_input_state_->type| to be reset to
1439 // none.
1441 TextInputStateHelper::WaitForDesiredState( 1440 TextInputStateHelper::WaitForDesiredState(
1442 embedder_web_contents(), 1441 embedder_web_contents(),
1443 base::Bind(&TextInputStateHelper::IsStateOfGivenType, 1442 base::Bind(&TextInputStateHelper::IsStateOfGivenType,
1443 ui::TEXT_INPUT_TYPE_NONE));
1444 }
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,
1444 ui::TEXT_INPUT_TYPE_NONE)); 1478 ui::TEXT_INPUT_TYPE_NONE));
1445 } 1479 }
OLDNEW
« no previous file with comments | « no previous file | chrome/test/data/extensions/platform_apps/web_view/text_input_state/window.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698