| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "content/browser/site_per_process_browsertest.h" | 5 #include "content/browser/site_per_process_browsertest.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include <algorithm> | 10 #include <algorithm> |
| (...skipping 4788 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4799 // The third touch sequence should generate a GestureTapDown, sent to the | 4799 // The third touch sequence should generate a GestureTapDown, sent to the |
| 4800 // main frame. | 4800 // main frame. |
| 4801 SendGestureTapSequenceWithExpectedTarget(rwhv_parent, main_frame_point, | 4801 SendGestureTapSequenceWithExpectedTarget(rwhv_parent, main_frame_point, |
| 4802 router->gesture_target_, rwhv_child, | 4802 router->gesture_target_, rwhv_child, |
| 4803 rwhv_parent); | 4803 rwhv_parent); |
| 4804 EXPECT_EQ(0LU, router->gesture_target_queue_.size()); | 4804 EXPECT_EQ(0LU, router->gesture_target_queue_.size()); |
| 4805 EXPECT_EQ(rwhv_parent, router->gesture_target_); | 4805 EXPECT_EQ(rwhv_parent, router->gesture_target_); |
| 4806 } | 4806 } |
| 4807 #endif // defined(USE_AURA) | 4807 #endif // defined(USE_AURA) |
| 4808 | 4808 |
| 4809 // Ensure that sequential focus navigation (advancing focused elements with | |
| 4810 // <tab> and <shift-tab>) works across cross-process subframes. | |
| 4811 // The test sets up six inputs fields in a page with two cross-process | |
| 4812 // subframes: | |
| 4813 // child1 child2 | |
| 4814 // /------------\ /------------\. | |
| 4815 // | 2. <input> | | 4. <input> | | |
| 4816 // 1. <input> | 3. <input> | | 5. <input> | 6. <input> | |
| 4817 // \------------/ \------------/. | |
| 4818 // | |
| 4819 // The test then presses <tab> six times to cycle through focused elements 1-6. | |
| 4820 // The test then repeats this with <shift-tab> to cycle in reverse order. | |
| 4821 | |
| 4822 // Freqently times out. https://crbug.com/599730. | |
| 4823 IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, | |
| 4824 DISABLED_SequentialFocusNavigation) { | |
| 4825 GURL main_url(embedded_test_server()->GetURL( | |
| 4826 "a.com", "/cross_site_iframe_factory.html?a(b,c)")); | |
| 4827 EXPECT_TRUE(NavigateToURL(shell(), main_url)); | |
| 4828 | |
| 4829 WebContents* contents = shell()->web_contents(); | |
| 4830 FrameTreeNode* root = | |
| 4831 static_cast<WebContentsImpl*>(contents)->GetFrameTree()->root(); | |
| 4832 | |
| 4833 // Assign a name to each frame. This will be sent along in test messages | |
| 4834 // from focus events. | |
| 4835 EXPECT_TRUE(ExecuteScript(root->current_frame_host(), | |
| 4836 "window.name = 'root';")); | |
| 4837 EXPECT_TRUE(ExecuteScript(root->child_at(0)->current_frame_host(), | |
| 4838 "window.name = 'child1';")); | |
| 4839 EXPECT_TRUE(ExecuteScript(root->child_at(1)->current_frame_host(), | |
| 4840 "window.name = 'child2';")); | |
| 4841 | |
| 4842 // This script will insert two <input> fields in the document, one at the | |
| 4843 // beginning and one at the end. For root frame, this means that we will | |
| 4844 // have an <input>, then two <iframe> elements, then another <input>. | |
| 4845 std::string script = | |
| 4846 "function onFocus(e) {" | |
| 4847 " domAutomationController.setAutomationId(0);" | |
| 4848 " domAutomationController.send(window.name + '-focused-' + e.target.id);" | |
| 4849 "}" | |
| 4850 "var input1 = document.createElement('input');" | |
| 4851 "input1.id = 'input1';" | |
| 4852 "var input2 = document.createElement('input');" | |
| 4853 "input2.id = 'input2';" | |
| 4854 "document.body.insertBefore(input1, document.body.firstChild);" | |
| 4855 "document.body.appendChild(input2);" | |
| 4856 "input1.addEventListener('focus', onFocus, false);" | |
| 4857 "input2.addEventListener('focus', onFocus, false);"; | |
| 4858 | |
| 4859 // Add two input fields to each of the three frames. | |
| 4860 EXPECT_TRUE(ExecuteScript(root->current_frame_host(), script)); | |
| 4861 EXPECT_TRUE(ExecuteScript(root->child_at(0)->current_frame_host(), script)); | |
| 4862 EXPECT_TRUE(ExecuteScript(root->child_at(1)->current_frame_host(), script)); | |
| 4863 | |
| 4864 // Helper to simulate a tab press and wait for a focus message. | |
| 4865 auto press_tab_and_wait_for_message = [contents](bool reverse) { | |
| 4866 DOMMessageQueue msg_queue; | |
| 4867 std::string reply; | |
| 4868 SimulateKeyPress(contents, ui::VKEY_TAB, false, reverse /* shift */, false, | |
| 4869 false); | |
| 4870 EXPECT_TRUE(msg_queue.WaitForMessage(&reply)); | |
| 4871 return reply; | |
| 4872 }; | |
| 4873 | |
| 4874 // Press <tab> six times to focus each of the <input> elements in turn. | |
| 4875 EXPECT_EQ("\"root-focused-input1\"", press_tab_and_wait_for_message(false)); | |
| 4876 EXPECT_EQ(root, root->frame_tree()->GetFocusedFrame()); | |
| 4877 EXPECT_EQ("\"child1-focused-input1\"", press_tab_and_wait_for_message(false)); | |
| 4878 EXPECT_EQ(root->child_at(0), root->frame_tree()->GetFocusedFrame()); | |
| 4879 EXPECT_EQ("\"child1-focused-input2\"", press_tab_and_wait_for_message(false)); | |
| 4880 EXPECT_EQ("\"child2-focused-input1\"", press_tab_and_wait_for_message(false)); | |
| 4881 EXPECT_EQ(root->child_at(1), root->frame_tree()->GetFocusedFrame()); | |
| 4882 EXPECT_EQ("\"child2-focused-input2\"", press_tab_and_wait_for_message(false)); | |
| 4883 EXPECT_EQ("\"root-focused-input2\"", press_tab_and_wait_for_message(false)); | |
| 4884 EXPECT_EQ(root, root->frame_tree()->GetFocusedFrame()); | |
| 4885 | |
| 4886 // Now, press <shift-tab> to navigate focus in the reverse direction. | |
| 4887 EXPECT_EQ("\"child2-focused-input2\"", press_tab_and_wait_for_message(true)); | |
| 4888 EXPECT_EQ(root->child_at(1), root->frame_tree()->GetFocusedFrame()); | |
| 4889 EXPECT_EQ("\"child2-focused-input1\"", press_tab_and_wait_for_message(true)); | |
| 4890 EXPECT_EQ("\"child1-focused-input2\"", press_tab_and_wait_for_message(true)); | |
| 4891 EXPECT_EQ(root->child_at(0), root->frame_tree()->GetFocusedFrame()); | |
| 4892 EXPECT_EQ("\"child1-focused-input1\"", press_tab_and_wait_for_message(true)); | |
| 4893 EXPECT_EQ("\"root-focused-input1\"", press_tab_and_wait_for_message(true)); | |
| 4894 EXPECT_EQ(root, root->frame_tree()->GetFocusedFrame()); | |
| 4895 } | |
| 4896 | |
| 4897 // A WebContentsDelegate to capture ContextMenu creation events. | 4809 // A WebContentsDelegate to capture ContextMenu creation events. |
| 4898 class ContextMenuObserverDelegate : public WebContentsDelegate { | 4810 class ContextMenuObserverDelegate : public WebContentsDelegate { |
| 4899 public: | 4811 public: |
| 4900 ContextMenuObserverDelegate() | 4812 ContextMenuObserverDelegate() |
| 4901 : context_menu_created_(false), | 4813 : context_menu_created_(false), |
| 4902 message_loop_runner_(new MessageLoopRunner) {} | 4814 message_loop_runner_(new MessageLoopRunner) {} |
| 4903 | 4815 |
| 4904 ~ContextMenuObserverDelegate() override {} | 4816 ~ContextMenuObserverDelegate() override {} |
| 4905 | 4817 |
| 4906 bool HandleContextMenu(const content::ContextMenuParams& params) override { | 4818 bool HandleContextMenu(const content::ContextMenuParams& params) override { |
| (...skipping 1500 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6407 root->current_frame_host()->GetRenderWidgetHost(); | 6319 root->current_frame_host()->GetRenderWidgetHost(); |
| 6408 press_tab_and_wait_for_state_change(root_rwh); | 6320 press_tab_and_wait_for_state_change(root_rwh); |
| 6409 EXPECT_EQ(ui::TEXT_INPUT_TYPE_TEXT, contents->GetTextInputState()->type); | 6321 EXPECT_EQ(ui::TEXT_INPUT_TYPE_TEXT, contents->GetTextInputState()->type); |
| 6410 | 6322 |
| 6411 // Crash the tab renderer and observer the input state going back to none. | 6323 // Crash the tab renderer and observer the input state going back to none. |
| 6412 RenderProcessHost* host_process = root_rwh->GetProcess(); | 6324 RenderProcessHost* host_process = root_rwh->GetProcess(); |
| 6413 crash_renderer_and_wait_for_input_state_none(host_process); | 6325 crash_renderer_and_wait_for_input_state_none(host_process); |
| 6414 } | 6326 } |
| 6415 | 6327 |
| 6416 } // namespace content | 6328 } // namespace content |
| OLD | NEW |