Pin Chrome's shortcut to the Win10 Start menu on install and OS upgrade.
[chromium-blink-merge.git] / content / browser / frame_host / render_widget_host_view_child_frame_browsertest.cc
blob3e369087141c5ad526a3a1e283e85c67e6baacee
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
3 // found in the LICENSE file.
5 #include "base/command_line.h"
6 #include "content/browser/web_contents/web_contents_impl.h"
7 #include "content/public/browser/render_frame_host.h"
8 #include "content/public/browser/web_contents.h"
9 #include "content/public/common/content_switches.h"
10 #include "content/public/test/browser_test_utils.h"
11 #include "content/public/test/content_browser_test.h"
12 #include "content/public/test/content_browser_test_utils.h"
13 #include "content/public/test/test_utils.h"
14 #include "content/shell/browser/shell.h"
15 #include "content/test/content_browser_test_utils_internal.h"
16 #include "content/test/test_content_browser_client.h"
17 #include "net/dns/mock_host_resolver.h"
18 #include "net/test/embedded_test_server/embedded_test_server.h"
20 namespace content {
22 class RenderWidgetHostViewChildFrameTest : public ContentBrowserTest {
23 public:
24 RenderWidgetHostViewChildFrameTest() {}
26 void SetUpCommandLine(base::CommandLine* command_line) override {
27 command_line->AppendSwitch(switches::kSitePerProcess);
30 void SetUpOnMainThread() override {
31 host_resolver()->AddRule("*", "127.0.0.1");
32 ASSERT_TRUE(embedded_test_server()->InitializeAndWaitUntilReady());
33 SetupCrossSiteRedirector(embedded_test_server());
36 void CheckScreenWidth(RenderFrameHost* render_frame_host) {
37 int width;
38 ExecuteScriptAndGetValue(render_frame_host, "window.screen.width")
39 ->GetAsInteger(&width);
40 EXPECT_EQ(expected_screen_width_, width);
43 void set_expected_screen_width(int width) {
44 expected_screen_width_ = width;
47 private:
48 int expected_screen_width_;
50 DISALLOW_COPY_AND_ASSIGN(RenderWidgetHostViewChildFrameTest);
53 // Tests that the screen is properly reflected for RWHVChildFrame.
54 IN_PROC_BROWSER_TEST_F(RenderWidgetHostViewChildFrameTest, Screen) {
55 GURL main_url(embedded_test_server()->GetURL("/site_per_process_main.html"));
56 NavigateToURL(shell(), main_url);
58 FrameTreeNode* root = static_cast<WebContentsImpl*>(shell()->web_contents())
59 ->GetFrameTree()->root();
61 // Load cross-site page into iframe.
62 GURL cross_site_url(
63 embedded_test_server()->GetURL("foo.com", "/title2.html"));
64 NavigateFrameToURL(root->child_at(0), cross_site_url);
66 int main_frame_screen_width = 0;
67 ExecuteScriptAndGetValue(shell()->web_contents()->GetMainFrame(),
68 "window.screen.width")->GetAsInteger(&main_frame_screen_width);
69 set_expected_screen_width(main_frame_screen_width);
70 EXPECT_FALSE(main_frame_screen_width == 0);
72 shell()->web_contents()->ForEachFrame(
73 base::Bind(&RenderWidgetHostViewChildFrameTest::CheckScreenWidth, this));
76 } // namespace content