Chromium Code Reviews| 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 1338 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1349 // Now verify that the selection text propagates properly to RWHV. | 1349 // Now verify that the selection text propagates properly to RWHV. |
| 1350 content::RenderWidgetHostView* guest_rwhv = | 1350 content::RenderWidgetHostView* guest_rwhv = |
| 1351 guest_web_contents()->GetRenderWidgetHostView(); | 1351 guest_web_contents()->GetRenderWidgetHostView(); |
| 1352 ASSERT_TRUE(guest_rwhv); | 1352 ASSERT_TRUE(guest_rwhv); |
| 1353 std::string selected_text = base::UTF16ToUTF8(guest_rwhv->GetSelectedText()); | 1353 std::string selected_text = base::UTF16ToUTF8(guest_rwhv->GetSelectedText()); |
| 1354 ASSERT_TRUE(selected_text.size() >= 10u); | 1354 ASSERT_TRUE(selected_text.size() >= 10u); |
| 1355 ASSERT_EQ("AAAAAAAAAA", selected_text.substr(0, 10)); | 1355 ASSERT_EQ("AAAAAAAAAA", selected_text.substr(0, 10)); |
| 1356 } | 1356 } |
| 1357 #endif | 1357 #endif |
| 1358 | 1358 |
| 1359 // Flaky on MacOS builders. https://crbug.com/670008 | 1359 IN_PROC_BROWSER_TEST_P(WebViewFocusInteractiveTest, FocusAndVisibility) { |
| 1360 #if defined(OS_MACOSX) | |
| 1361 #define MAYBE_FocusAndVisibility DISABLED_FocusAndVisibility | |
| 1362 #else | |
| 1363 #define MAYBE_FocusAndVisibility FocusAndVisibility | |
| 1364 #endif | |
| 1365 | |
| 1366 IN_PROC_BROWSER_TEST_P(WebViewFocusInteractiveTest, MAYBE_FocusAndVisibility) { | |
| 1367 ASSERT_TRUE(StartEmbeddedTestServer()); | 1360 ASSERT_TRUE(StartEmbeddedTestServer()); |
| 1368 LoadAndLaunchPlatformApp("web_view/focus_visibility", | 1361 LoadAndLaunchPlatformApp("web_view/focus_visibility", |
| 1369 "WebViewInteractiveTest.LOADED"); | 1362 "WebViewInteractiveTest.LOADED"); |
| 1370 ExtensionTestMessageListener test_init_listener( | 1363 ExtensionTestMessageListener test_init_listener( |
| 1371 "WebViewInteractiveTest.WebViewInitialized", false); | 1364 "WebViewInteractiveTest.WebViewInitialized", false); |
| 1372 SendMessageToEmbedder("init"); | 1365 SendMessageToEmbedder(GetParam() ? "init-oopif" : "init"); |
| 1373 test_init_listener.WaitUntilSatisfied(); | 1366 test_init_listener.WaitUntilSatisfied(); |
| 1374 | 1367 |
| 1375 // In oopif-webview, wait until the tab key triggers a focus change. | 1368 ExtensionTestMessageListener key_processed_listener( |
| 1376 std::unique_ptr<content::FrameFocusedObserver> frame_focus_observer = | 1369 "WebViewInteractiveTest.KeyUp", false); |
| 1377 GetParam() ? base::MakeUnique<content::FrameFocusedObserver>( | |
| 1378 GetGuestViewManager() | |
| 1379 ->WaitForSingleGuestCreated() | |
| 1380 ->GetMainFrame()) | |
| 1381 : nullptr; | |
| 1382 | 1370 |
| 1383 // Send several tab-keys. The button inside webview should receive focus at | 1371 // Send several tab-keys. The button inside webview should receive focus at |
| 1384 // least once. | 1372 // least once. |
| 1385 for (size_t i = 0; i < 2; ++i) | 1373 #if defined(OS_MACOSX) |
| 1374 // On mac, the event listener seems one key even behind and deadlocks. Send an | |
|
EhsanK
2017/01/25 17:57:58
s/even/event?
Also is there a short explanation on
avallee
2017/01/25 18:50:18
Done.
EhsanK
2017/01/25 19:31:36
Acknowledged.
| |
| 1375 // extra tab to get things unblocked. | |
| 1376 SendKeyPressToPlatformApp(ui::VKEY_TAB); | |
| 1377 #endif | |
| 1378 for (size_t i = 0; i < 4; ++i) { | |
| 1379 key_processed_listener.Reset(); | |
| 1386 SendKeyPressToPlatformApp(ui::VKEY_TAB); | 1380 SendKeyPressToPlatformApp(ui::VKEY_TAB); |
| 1387 if (frame_focus_observer) { | 1381 EXPECT_TRUE(key_processed_listener.WaitUntilSatisfied()); |
| 1388 frame_focus_observer->Wait(); | |
| 1389 frame_focus_observer.reset(); | |
| 1390 } | 1382 } |
| 1391 for (size_t i = 0; i < 2; ++i) | |
| 1392 SendKeyPressToPlatformApp(ui::VKEY_TAB); | |
| 1393 ExtensionTestMessageListener webview_button_focused_listener( | 1383 ExtensionTestMessageListener webview_button_focused_listener( |
| 1394 "WebViewInteractiveTest.WebViewButtonWasFocused", false); | 1384 "WebViewInteractiveTest.WebViewButtonWasFocused", false); |
| 1395 webview_button_focused_listener.set_failure_message( | 1385 webview_button_focused_listener.set_failure_message( |
| 1396 "WebViewInteractiveTest.WebViewButtonWasNotFocused"); | 1386 "WebViewInteractiveTest.WebViewButtonWasNotFocused"); |
| 1397 SendMessageToEmbedder("verify"); | 1387 SendMessageToEmbedder("verify"); |
| 1398 EXPECT_TRUE(webview_button_focused_listener.WaitUntilSatisfied()); | 1388 EXPECT_TRUE(webview_button_focused_listener.WaitUntilSatisfied()); |
| 1399 // Now make the <webview> invisible. | 1389 // Now make the <webview> invisible. |
|
EhsanK
2017/01/25 17:57:58
Given that the next couple of lines first reset th
avallee
2017/01/25 18:50:18
Done.
EhsanK
2017/01/25 19:31:36
Acknowledged.
| |
| 1400 ExtensionTestMessageListener reset_listener("WebViewInteractiveTest.DidReset", | 1390 ExtensionTestMessageListener reset_listener("WebViewInteractiveTest.DidReset", |
| 1401 false); | 1391 false); |
| 1402 SendMessageToEmbedder("reset"); | 1392 SendMessageToEmbedder("reset"); |
| 1403 reset_listener.WaitUntilSatisfied(); | 1393 reset_listener.WaitUntilSatisfied(); |
| 1404 ExtensionTestMessageListener did_hide_webview_listener( | 1394 ExtensionTestMessageListener did_hide_webview_listener( |
| 1405 "WebViewInteractiveTest.DidHideWebView", false); | 1395 "WebViewInteractiveTest.DidHideWebView", false); |
| 1406 SendMessageToEmbedder("hide-webview"); | 1396 SendMessageToEmbedder("hide-webview"); |
| 1407 did_hide_webview_listener.WaitUntilSatisfied(); | 1397 did_hide_webview_listener.WaitUntilSatisfied(); |
| 1408 // Send the same number of keys and verify that the webview button was not | 1398 // Send the same number of keys and verify that the webview button was not |
| 1409 // this time. | 1399 // this time. |
| 1410 for (size_t i = 0; i < 4; ++i) | 1400 for (size_t i = 0; i < 4; ++i) { |
| 1401 key_processed_listener.Reset(); | |
| 1411 SendKeyPressToPlatformApp(ui::VKEY_TAB); | 1402 SendKeyPressToPlatformApp(ui::VKEY_TAB); |
| 1403 EXPECT_TRUE(key_processed_listener.WaitUntilSatisfied()); | |
| 1404 } | |
| 1412 ExtensionTestMessageListener webview_button_not_focused_listener( | 1405 ExtensionTestMessageListener webview_button_not_focused_listener( |
| 1413 "WebViewInteractiveTest.WebViewButtonWasNotFocused", false); | 1406 "WebViewInteractiveTest.WebViewButtonWasNotFocused", false); |
| 1414 webview_button_not_focused_listener.set_failure_message( | 1407 webview_button_not_focused_listener.set_failure_message( |
| 1415 "WebViewInteractiveTest.WebViewButtonWasFocused"); | 1408 "WebViewInteractiveTest.WebViewButtonWasFocused"); |
| 1416 SendMessageToEmbedder("verify"); | 1409 SendMessageToEmbedder("verify"); |
| 1417 EXPECT_TRUE(webview_button_not_focused_listener.WaitUntilSatisfied()); | 1410 EXPECT_TRUE(webview_button_not_focused_listener.WaitUntilSatisfied()); |
| 1418 } | 1411 } |
| 1419 | 1412 |
| 1420 IN_PROC_BROWSER_TEST_P(WebViewInteractiveTest, KeyboardFocusSimple) { | 1413 IN_PROC_BROWSER_TEST_P(WebViewInteractiveTest, KeyboardFocusSimple) { |
| 1421 TestHelper("testKeyboardFocusSimple", "web_view/focus", NO_TEST_SERVER); | 1414 TestHelper("testKeyboardFocusSimple", "web_view/focus", NO_TEST_SERVER); |
| (...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1510 ASSERT_TRUE(ui_test_utils::SendKeyPressToWindowSync( | 1503 ASSERT_TRUE(ui_test_utils::SendKeyPressToWindowSync( |
| 1511 GetPlatformAppWindow(), ui::VKEY_Z, false, false, false, false)); | 1504 GetPlatformAppWindow(), ui::VKEY_Z, false, false, false, false)); |
| 1512 | 1505 |
| 1513 next_step_listener.Reset(); | 1506 next_step_listener.Reset(); |
| 1514 EXPECT_TRUE(content::ExecuteScript( | 1507 EXPECT_TRUE(content::ExecuteScript( |
| 1515 embedder_web_contents(), | 1508 embedder_web_contents(), |
| 1516 "window.runCommand('testKeyboardFocusRunNextStep', 'aBcxYz');")); | 1509 "window.runCommand('testKeyboardFocusRunNextStep', 'aBcxYz');")); |
| 1517 | 1510 |
| 1518 ASSERT_TRUE(next_step_listener.WaitUntilSatisfied()); | 1511 ASSERT_TRUE(next_step_listener.WaitUntilSatisfied()); |
| 1519 } | 1512 } |
| OLD | NEW |