| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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/frame_host/render_frame_host_impl.h" | 5 #include "content/browser/frame_host/render_frame_host_impl.h" |
| 6 #include "content/browser/web_contents/web_contents_impl.h" | 6 #include "content/browser/web_contents/web_contents_impl.h" |
| 7 #include "content/public/browser/render_frame_host.h" | 7 #include "content/public/browser/render_frame_host.h" |
| 8 #include "content/public/browser/web_contents.h" | 8 #include "content/public/browser/web_contents.h" |
| 9 #include "content/public/common/content_client.h" | 9 #include "content/public/common/content_client.h" |
| 10 #include "content/public/test/content_browser_test.h" | 10 #include "content/public/test/content_browser_test.h" |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 49 blink::WebPageVisibilityState visibility_override_; | 49 blink::WebPageVisibilityState visibility_override_; |
| 50 | 50 |
| 51 DISALLOW_COPY_AND_ASSIGN(PrerenderTestContentBrowserClient); | 51 DISALLOW_COPY_AND_ASSIGN(PrerenderTestContentBrowserClient); |
| 52 }; | 52 }; |
| 53 | 53 |
| 54 } // anonymous namespace | 54 } // anonymous namespace |
| 55 | 55 |
| 56 using RenderFrameHostImplBrowserTest = ContentBrowserTest; | 56 using RenderFrameHostImplBrowserTest = ContentBrowserTest; |
| 57 | 57 |
| 58 // Test that when creating a new window, the main frame is correctly focused. | 58 // Test that when creating a new window, the main frame is correctly focused. |
| 59 IN_PROC_BROWSER_TEST_F(RenderFrameHostImplBrowserTest, IsFocused_AtLoad) { | 59 // flaky http://crbug.com/452631 |
| 60 IN_PROC_BROWSER_TEST_F(RenderFrameHostImplBrowserTest, |
| 61 DISABLED_IsFocused_AtLoad) { |
| 60 EXPECT_TRUE( | 62 EXPECT_TRUE( |
| 61 NavigateToURL(shell(), GetTestUrl("render_frame_host", "focus.html"))); | 63 NavigateToURL(shell(), GetTestUrl("render_frame_host", "focus.html"))); |
| 62 | 64 |
| 63 // The main frame should be focused. | 65 // The main frame should be focused. |
| 64 WebContents* web_contents = shell()->web_contents(); | 66 WebContents* web_contents = shell()->web_contents(); |
| 65 EXPECT_TRUE(ToRFHI(web_contents->GetMainFrame())->IsFocused()); | 67 EXPECT_TRUE(ToRFHI(web_contents->GetMainFrame())->IsFocused()); |
| 66 } | 68 } |
| 67 | 69 |
| 68 // Test that if the content changes the focused frame, it is correctly exposed. | 70 // Test that if the content changes the focused frame, it is correctly exposed. |
| 69 // Disabled to to flaky failures: crbug.com/452631 | 71 // Disabled to to flaky failures: crbug.com/452631 |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 115 EXPECT_NE(web_contents->GetMainFrame(), web_contents->GetFocusedFrame()); | 117 EXPECT_NE(web_contents->GetMainFrame(), web_contents->GetFocusedFrame()); |
| 116 EXPECT_NE(-1, web_contents->GetFrameTree()->focused_frame_tree_node_id_); | 118 EXPECT_NE(-1, web_contents->GetFrameTree()->focused_frame_tree_node_id_); |
| 117 | 119 |
| 118 ExecuteScriptAndGetValue(web_contents->GetMainFrame(), "detachframe(2)"); | 120 ExecuteScriptAndGetValue(web_contents->GetMainFrame(), "detachframe(2)"); |
| 119 EXPECT_EQ(nullptr, web_contents->GetFocusedFrame()); | 121 EXPECT_EQ(nullptr, web_contents->GetFocusedFrame()); |
| 120 EXPECT_EQ(-1, web_contents->GetFrameTree()->focused_frame_tree_node_id_); | 122 EXPECT_EQ(-1, web_contents->GetFrameTree()->focused_frame_tree_node_id_); |
| 121 } | 123 } |
| 122 | 124 |
| 123 // Test that even if the frame is focused in the frame tree but its | 125 // Test that even if the frame is focused in the frame tree but its |
| 124 // RenderWidgetHost is not focused, it is not considered as focused. | 126 // RenderWidgetHost is not focused, it is not considered as focused. |
| 125 IN_PROC_BROWSER_TEST_F(RenderFrameHostImplBrowserTest, IsFocused_Widget) { | 127 // flaky http://crbug.com/452631 |
| 128 IN_PROC_BROWSER_TEST_F(RenderFrameHostImplBrowserTest, |
| 129 DISABLED_IsFocused_Widget) { |
| 126 EXPECT_TRUE( | 130 EXPECT_TRUE( |
| 127 NavigateToURL(shell(), GetTestUrl("render_frame_host", "focus.html"))); | 131 NavigateToURL(shell(), GetTestUrl("render_frame_host", "focus.html"))); |
| 128 WebContents* web_contents = shell()->web_contents(); | 132 WebContents* web_contents = shell()->web_contents(); |
| 129 | 133 |
| 130 // A second window is created and navigated. It takes the focus. | 134 // A second window is created and navigated. It takes the focus. |
| 131 Shell* new_shell = CreateBrowser(); | 135 Shell* new_shell = CreateBrowser(); |
| 132 EXPECT_TRUE( | 136 EXPECT_TRUE( |
| 133 NavigateToURL(new_shell, GetTestUrl("render_frame_host", "focus.html"))); | 137 NavigateToURL(new_shell, GetTestUrl("render_frame_host", "focus.html"))); |
| 134 EXPECT_TRUE(ToRFHI(new_shell->web_contents()->GetMainFrame())->IsFocused()); | 138 EXPECT_TRUE(ToRFHI(new_shell->web_contents()->GetMainFrame())->IsFocused()); |
| 135 | 139 |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 179 web_contents->GetMainFrame()->GetVisibilityState()); | 183 web_contents->GetMainFrame()->GetVisibilityState()); |
| 180 | 184 |
| 181 new_client.EnableVisibilityOverride(blink::WebPageVisibilityStatePrerender); | 185 new_client.EnableVisibilityOverride(blink::WebPageVisibilityStatePrerender); |
| 182 EXPECT_EQ(blink::WebPageVisibilityStatePrerender, | 186 EXPECT_EQ(blink::WebPageVisibilityStatePrerender, |
| 183 web_contents->GetMainFrame()->GetVisibilityState()); | 187 web_contents->GetMainFrame()->GetVisibilityState()); |
| 184 | 188 |
| 185 SetBrowserClientForTesting(old_client); | 189 SetBrowserClientForTesting(old_client); |
| 186 } | 190 } |
| 187 | 191 |
| 188 } // namespace content | 192 } // namespace content |
| OLD | NEW |