| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 "base/command_line.h" | 5 #include "base/command_line.h" |
| 6 #include "base/strings/string_number_conversions.h" | 6 #include "base/strings/string_number_conversions.h" |
| 7 #include "chrome/browser/ui/browser.h" | 7 #include "chrome/browser/ui/browser.h" |
| 8 #include "chrome/browser/ui/browser_window.h" | 8 #include "chrome/browser/ui/browser_window.h" |
| 9 #include "chrome/browser/ui/exclusive_access/fullscreen_controller_test.h" | 9 #include "chrome/browser/ui/exclusive_access/fullscreen_controller_test.h" |
| 10 #include "chrome/browser/ui/tabs/tab_strip_model.h" | 10 #include "chrome/browser/ui/tabs/tab_strip_model.h" |
| (...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 143 ChildFrameAt(web_contents->GetMainFrame(), 0); | 143 ChildFrameAt(web_contents->GetMainFrame(), 0); |
| 144 std::string result; | 144 std::string result; |
| 145 EXPECT_TRUE(ExecuteScriptAndExtractString( | 145 EXPECT_TRUE(ExecuteScriptAndExtractString( |
| 146 child, "window.focus(); focusInputField();", &result)); | 146 child, "window.focus(); focusInputField();", &result)); |
| 147 EXPECT_EQ("input-focus", result); | 147 EXPECT_EQ("input-focus", result); |
| 148 | 148 |
| 149 // The subframe should now be focused. | 149 // The subframe should now be focused. |
| 150 EXPECT_EQ(child, web_contents->GetFocusedFrame()); | 150 EXPECT_EQ(child, web_contents->GetFocusedFrame()); |
| 151 | 151 |
| 152 // Generate a few keyboard events and route them to currently focused frame. | 152 // Generate a few keyboard events and route them to currently focused frame. |
| 153 SimulateKeyPress(web_contents, ui::VKEY_F, false, false, false, false); | 153 SimulateKeyPress(web_contents, ui::DomKey::FromCharacter('f'), |
| 154 SimulateKeyPress(web_contents, ui::VKEY_O, false, false, false, false); | 154 ui::DomCode::US_F, ui::VKEY_F, false, false, false, false); |
| 155 SimulateKeyPress(web_contents, ui::VKEY_O, false, false, false, false); | 155 SimulateKeyPress(web_contents, ui::DomKey::FromCharacter('O'), |
| 156 ui::DomCode::US_O, ui::VKEY_O, false, false, false, false); |
| 157 SimulateKeyPress(web_contents, ui::DomKey::FromCharacter('O'), |
| 158 ui::DomCode::US_O, ui::VKEY_O, false, false, false, false); |
| 156 | 159 |
| 157 // Verify that the input field in the subframe received the keystrokes. | 160 // Verify that the input field in the subframe received the keystrokes. |
| 158 EXPECT_TRUE(ExecuteScriptAndExtractString( | 161 EXPECT_TRUE(ExecuteScriptAndExtractString( |
| 159 child, | 162 child, |
| 160 "window.domAutomationController.send(getInputFieldText());", &result)); | 163 "window.domAutomationController.send(getInputFieldText());", &result)); |
| 161 EXPECT_EQ("FOO", result); | 164 EXPECT_EQ("FOO", result); |
| 162 } | 165 } |
| 163 | 166 |
| 164 // Ensure that sequential focus navigation (advancing focused elements with | 167 // Ensure that sequential focus navigation (advancing focused elements with |
| 165 // <tab> and <shift-tab>) works across cross-process subframes. | 168 // <tab> and <shift-tab>) works across cross-process subframes. |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 213 | 216 |
| 214 // Add two input fields to each of the three frames. | 217 // Add two input fields to each of the three frames. |
| 215 EXPECT_TRUE(ExecuteScript(main_frame, script)); | 218 EXPECT_TRUE(ExecuteScript(main_frame, script)); |
| 216 EXPECT_TRUE(ExecuteScript(child1, script)); | 219 EXPECT_TRUE(ExecuteScript(child1, script)); |
| 217 EXPECT_TRUE(ExecuteScript(child2, script)); | 220 EXPECT_TRUE(ExecuteScript(child2, script)); |
| 218 | 221 |
| 219 // Helper to simulate a tab press and wait for a focus message. | 222 // Helper to simulate a tab press and wait for a focus message. |
| 220 auto press_tab_and_wait_for_message = [web_contents](bool reverse) { | 223 auto press_tab_and_wait_for_message = [web_contents](bool reverse) { |
| 221 content::DOMMessageQueue msg_queue; | 224 content::DOMMessageQueue msg_queue; |
| 222 std::string reply; | 225 std::string reply; |
| 223 SimulateKeyPress(web_contents, ui::VKEY_TAB, false, reverse /* shift */, | 226 SimulateKeyPress(web_contents, ui::DomKey::TAB, ui::DomCode::TAB, |
| 224 false, false); | 227 ui::VKEY_TAB, false, reverse /* shift */, false, false); |
| 225 EXPECT_TRUE(msg_queue.WaitForMessage(&reply)); | 228 EXPECT_TRUE(msg_queue.WaitForMessage(&reply)); |
| 226 return reply; | 229 return reply; |
| 227 }; | 230 }; |
| 228 | 231 |
| 229 // Press <tab> six times to focus each of the <input> elements in turn. | 232 // Press <tab> six times to focus each of the <input> elements in turn. |
| 230 EXPECT_EQ("\"root-focused-input1\"", press_tab_and_wait_for_message(false)); | 233 EXPECT_EQ("\"root-focused-input1\"", press_tab_and_wait_for_message(false)); |
| 231 EXPECT_EQ(main_frame, web_contents->GetFocusedFrame()); | 234 EXPECT_EQ(main_frame, web_contents->GetFocusedFrame()); |
| 232 EXPECT_EQ("\"child1-focused-input1\"", press_tab_and_wait_for_message(false)); | 235 EXPECT_EQ("\"child1-focused-input1\"", press_tab_and_wait_for_message(false)); |
| 233 EXPECT_EQ(child1, web_contents->GetFocusedFrame()); | 236 EXPECT_EQ(child1, web_contents->GetFocusedFrame()); |
| 234 EXPECT_EQ("\"child1-focused-input2\"", press_tab_and_wait_for_message(false)); | 237 EXPECT_EQ("\"child1-focused-input2\"", press_tab_and_wait_for_message(false)); |
| (...skipping 477 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 712 // Verify that all fullscreen styles have been cleared. | 715 // Verify that all fullscreen styles have been cleared. |
| 713 EXPECT_FALSE(ElementHasFullscreenStyle(a_top, "child-0")); | 716 EXPECT_FALSE(ElementHasFullscreenStyle(a_top, "child-0")); |
| 714 EXPECT_FALSE(ElementHasFullscreenStyle(a_bottom, "child-0")); | 717 EXPECT_FALSE(ElementHasFullscreenStyle(a_bottom, "child-0")); |
| 715 EXPECT_FALSE(ElementHasFullscreenStyle(a_bottom, "child-1")); | 718 EXPECT_FALSE(ElementHasFullscreenStyle(a_bottom, "child-1")); |
| 716 EXPECT_FALSE(ElementHasFullscreenStyle(b_second, "child-0")); | 719 EXPECT_FALSE(ElementHasFullscreenStyle(b_second, "child-0")); |
| 717 EXPECT_FALSE(ElementHasFullscreenStyle(c_top, "child-0")); | 720 EXPECT_FALSE(ElementHasFullscreenStyle(c_top, "child-0")); |
| 718 EXPECT_FALSE(ElementHasFullscreenStyle(c_middle, "fullscreen-div")); | 721 EXPECT_FALSE(ElementHasFullscreenStyle(c_middle, "fullscreen-div")); |
| 719 EXPECT_FALSE(ElementHasFullscreenStyle(c_middle, "child-0")); | 722 EXPECT_FALSE(ElementHasFullscreenStyle(c_middle, "child-0")); |
| 720 } | 723 } |
| 721 | 724 |
| OLD | NEW |