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

Side by Side Diff: content/browser/frame_host/render_widget_host_view_child_frame_browsertest.cc

Issue 2928643003: Propagate auto-resize viewport values to OOPIF processes (Closed)
Patch Set: Created 3 years, 6 months 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 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 "base/macros.h" 5 #include "base/macros.h"
6 #include "content/browser/frame_host/frame_tree_node.h"
6 #include "content/browser/web_contents/web_contents_impl.h" 7 #include "content/browser/web_contents/web_contents_impl.h"
8 #include "content/common/view_messages.h"
7 #include "content/public/browser/render_frame_host.h" 9 #include "content/public/browser/render_frame_host.h"
8 #include "content/public/browser/web_contents.h" 10 #include "content/public/browser/web_contents.h"
9 #include "content/public/test/browser_test_utils.h" 11 #include "content/public/test/browser_test_utils.h"
10 #include "content/public/test/content_browser_test.h" 12 #include "content/public/test/content_browser_test.h"
11 #include "content/public/test/content_browser_test_utils.h" 13 #include "content/public/test/content_browser_test_utils.h"
12 #include "content/public/test/test_utils.h" 14 #include "content/public/test/test_utils.h"
13 #include "content/shell/browser/shell.h" 15 #include "content/shell/browser/shell.h"
14 #include "content/test/content_browser_test_utils_internal.h" 16 #include "content/test/content_browser_test_utils_internal.h"
15 #include "content/test/test_content_browser_client.h" 17 #include "content/test/test_content_browser_client.h"
16 #include "net/dns/mock_host_resolver.h" 18 #include "net/dns/mock_host_resolver.h"
17 #include "net/test/embedded_test_server/embedded_test_server.h" 19 #include "net/test/embedded_test_server/embedded_test_server.h"
20 #include "ui/gfx/geometry/size.h"
18 21
19 namespace content { 22 namespace content {
20 23
21 class RenderWidgetHostViewChildFrameTest : public ContentBrowserTest { 24 class RenderWidgetHostViewChildFrameTest : public ContentBrowserTest {
22 public: 25 public:
23 RenderWidgetHostViewChildFrameTest() {} 26 RenderWidgetHostViewChildFrameTest() {}
24 27
25 void SetUpCommandLine(base::CommandLine* command_line) override { 28 void SetUpCommandLine(base::CommandLine* command_line) override {
26 IsolateAllSitesForTesting(command_line); 29 IsolateAllSitesForTesting(command_line);
27 } 30 }
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
66 ExecuteScriptAndGetValue(shell()->web_contents()->GetMainFrame(), 69 ExecuteScriptAndGetValue(shell()->web_contents()->GetMainFrame(),
67 "window.screen.width")->GetAsInteger(&main_frame_screen_width); 70 "window.screen.width")->GetAsInteger(&main_frame_screen_width);
68 set_expected_screen_width(main_frame_screen_width); 71 set_expected_screen_width(main_frame_screen_width);
69 EXPECT_FALSE(main_frame_screen_width == 0); 72 EXPECT_FALSE(main_frame_screen_width == 0);
70 73
71 shell()->web_contents()->ForEachFrame( 74 shell()->web_contents()->ForEachFrame(
72 base::Bind(&RenderWidgetHostViewChildFrameTest::CheckScreenWidth, 75 base::Bind(&RenderWidgetHostViewChildFrameTest::CheckScreenWidth,
73 base::Unretained(this))); 76 base::Unretained(this)));
74 } 77 }
75 78
79 // Test that auto-resize sizes in the top frame are propagated to OOPIF
80 // RenderWidgetHostViews. See https://crbug.com/726743.
81 IN_PROC_BROWSER_TEST_F(RenderWidgetHostViewChildFrameTest,
82 ChildFrameAutoResizeUpdate) {
83 EXPECT_TRUE(NavigateToURL(
84 shell(), embedded_test_server()->GetURL(
85 "a.com", "/cross_site_iframe_factory.html?a(b)")));
86
87 FrameTreeNode* root = static_cast<WebContentsImpl*>(shell()->web_contents())
88 ->GetFrameTree()
89 ->root();
90 root->current_frame_host()->render_view_host()->EnableAutoResize(
91 gfx::Size(0, 0), gfx::Size(100, 100));
92
93 RenderWidgetHostView* rwhv =
94 root->child_at(0)->current_frame_host()->GetRenderWidgetHost()->GetView();
95
96 // Fake an auto-resize update from the parent renderer.
97 int routing_id =
98 root->current_frame_host()->GetRenderWidgetHost()->GetRoutingID();
99 ViewHostMsg_UpdateRect_Params params;
100 params.view_size = gfx::Size(75, 75);
101 params.flags = 0;
102 root->current_frame_host()->GetRenderWidgetHost()->OnMessageReceived(
103 ViewHostMsg_UpdateRect(routing_id, params));
104
105 // RenderWidgetHostImpl has delayed auto-resize processing. Yield here to
106 // let it complete.
107 base::RunLoop run_loop;
108 base::ThreadTaskRunnerHandle::Get()->PostTask(FROM_HERE,
109 run_loop.QuitClosure());
110 run_loop.Run();
111
112 // The child frame's RenderWidgetHostView should now use the auto-resize value
113 // for its visible viewport.
114 EXPECT_EQ(gfx::Size(75, 75), rwhv->GetVisibleViewportSize());
115 }
116
76 } // namespace content 117 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698