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

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

Issue 2451143003: <webview>: Correctly shift focus between WebContents. (Closed)
Patch Set: Address comments from alexmos and lfg. Created 4 years, 1 month 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 1343 matching lines...) Expand 10 before | Expand all | Expand 10 after
1354 "WebViewInteractiveTest.WebViewButtonWasFocused"); 1354 "WebViewInteractiveTest.WebViewButtonWasFocused");
1355 SendMessageToEmbedder("verify"); 1355 SendMessageToEmbedder("verify");
1356 EXPECT_TRUE(webview_button_not_focused_listener.WaitUntilSatisfied()); 1356 EXPECT_TRUE(webview_button_not_focused_listener.WaitUntilSatisfied());
1357 } 1357 }
1358 1358
1359 IN_PROC_BROWSER_TEST_P(WebViewInteractiveTest, KeyboardFocus) { 1359 IN_PROC_BROWSER_TEST_P(WebViewInteractiveTest, KeyboardFocus) {
1360 TestHelper("testKeyboardFocus", "web_view/focus", NO_TEST_SERVER); 1360 TestHelper("testKeyboardFocus", "web_view/focus", NO_TEST_SERVER);
1361 1361
1362 EXPECT_EQ(embedder_web_contents()->GetFocusedFrame(), 1362 EXPECT_EQ(embedder_web_contents()->GetFocusedFrame(),
1363 embedder_web_contents()->GetMainFrame()); 1363 embedder_web_contents()->GetMainFrame());
1364 content::FrameFocusedObserver focus_observer(
1365 guest_web_contents()->GetMainFrame());
1366 ExtensionTestMessageListener next_step_listener("TEST_STEP_PASSED", false); 1364 ExtensionTestMessageListener next_step_listener("TEST_STEP_PASSED", false);
1367 next_step_listener.set_failure_message("TEST_STEP_FAILED"); 1365 next_step_listener.set_failure_message("TEST_STEP_FAILED");
1368 { 1366 {
1369 gfx::Rect offset = embedder_web_contents()->GetContainerBounds(); 1367 gfx::Rect offset = embedder_web_contents()->GetContainerBounds();
1370 // Click the <input> element inside the <webview>. 1368 // Click the <input> element inside the <webview>.
1371 // If we wanted, we could ask the embedder to compute an appropriate point. 1369 // If we wanted, we could ask the embedder to compute an appropriate point.
1372 MoveMouseInsideWindow(gfx::Point(offset.x() + 40, offset.y() + 40)); 1370 MoveMouseInsideWindow(gfx::Point(offset.x() + 40, offset.y() + 40));
1373 SendMouseClick(ui_controls::LEFT); 1371 SendMouseClick(ui_controls::LEFT);
1374 } 1372 }
1375 1373
1376 // Waits for the renderer to know the input has focus. 1374 // Waits for the renderer to know the input has focus.
1377 ASSERT_TRUE(next_step_listener.WaitUntilSatisfied()); 1375 ASSERT_TRUE(next_step_listener.WaitUntilSatisfied());
1378 // Wait for the browser to know which frame has focus.
1379 focus_observer.Wait();
1380 if (GetParam())
1381 EXPECT_EQ(embedder_web_contents()->GetFocusedFrame(), nullptr);
1382 1376
1383 ASSERT_TRUE(ui_test_utils::SendKeyPressToWindowSync( 1377 ASSERT_TRUE(ui_test_utils::SendKeyPressToWindowSync(
1384 GetPlatformAppWindow(), ui::VKEY_A, false, false, false, false)); 1378 GetPlatformAppWindow(), ui::VKEY_A, false, false, false, false));
1385 ASSERT_TRUE(ui_test_utils::SendKeyPressToWindowSync( 1379 ASSERT_TRUE(ui_test_utils::SendKeyPressToWindowSync(
1386 GetPlatformAppWindow(), ui::VKEY_B, false, true, false, false)); 1380 GetPlatformAppWindow(), ui::VKEY_B, false, true, false, false));
1387 ASSERT_TRUE(ui_test_utils::SendKeyPressToWindowSync( 1381 ASSERT_TRUE(ui_test_utils::SendKeyPressToWindowSync(
1388 GetPlatformAppWindow(), ui::VKEY_C, false, false, false, false)); 1382 GetPlatformAppWindow(), ui::VKEY_C, false, false, false, false));
1389 1383
1390 next_step_listener.Reset(); 1384 next_step_listener.Reset();
1391 EXPECT_TRUE(content::ExecuteScript( 1385 EXPECT_TRUE(content::ExecuteScript(
1392 embedder_web_contents(), 1386 embedder_web_contents(),
1393 "window.runCommand('testKeyboardFocusRunNextStep', 'aBc');")); 1387 "window.runCommand('testKeyboardFocusRunNextStep', 'aBc');"));
1394 1388
1395 ASSERT_TRUE(next_step_listener.WaitUntilSatisfied()); 1389 ASSERT_TRUE(next_step_listener.WaitUntilSatisfied());
1396 } 1390 }
OLDNEW
« no previous file with comments | « no previous file | content/browser/frame_host/frame_tree.cc » ('j') | content/browser/renderer_host/render_widget_host_impl.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698