OLD | NEW |
---|---|
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/files/file_path.h" | 6 #include "base/files/file_path.h" |
7 #include "base/macros.h" | 7 #include "base/macros.h" |
8 #include "base/path_service.h" | 8 #include "base/path_service.h" |
9 #include "base/strings/stringprintf.h" | 9 #include "base/strings/stringprintf.h" |
10 #include "chrome/browser/chrome_notification_types.h" | 10 #include "chrome/browser/chrome_notification_types.h" |
11 #include "chrome/browser/ui/browser.h" | 11 #include "chrome/browser/ui/browser.h" |
12 #include "chrome/browser/ui/tabs/tab_strip_model.h" | 12 #include "chrome/browser/ui/tabs/tab_strip_model.h" |
13 #include "chrome/test/base/in_process_browser_test.h" | 13 #include "chrome/test/base/in_process_browser_test.h" |
14 #include "chrome/test/base/ui_test_utils.h" | 14 #include "chrome/test/base/ui_test_utils.h" |
15 #include "content/public/browser/interstitial_page.h" | |
15 #include "content/public/browser/notification_observer.h" | 16 #include "content/public/browser/notification_observer.h" |
16 #include "content/public/browser/notification_service.h" | 17 #include "content/public/browser/notification_service.h" |
17 #include "content/public/browser/notification_types.h" | 18 #include "content/public/browser/notification_types.h" |
18 #include "content/public/browser/render_frame_host.h" | 19 #include "content/public/browser/render_frame_host.h" |
19 #include "content/public/browser/web_contents.h" | 20 #include "content/public/browser/web_contents.h" |
20 #include "content/public/browser/web_contents_observer.h" | 21 #include "content/public/browser/web_contents_observer.h" |
21 #include "content/public/test/browser_test_utils.h" | 22 #include "content/public/test/browser_test_utils.h" |
22 #include "content/public/test/content_browser_test_utils.h" | 23 #include "content/public/test/content_browser_test_utils.h" |
23 #include "content/public/test/test_utils.h" | 24 #include "content/public/test/test_utils.h" |
24 #include "net/dns/mock_host_resolver.h" | 25 #include "net/dns/mock_host_resolver.h" |
25 #include "net/test/embedded_test_server/embedded_test_server.h" | 26 #include "net/test/embedded_test_server/embedded_test_server.h" |
27 #include "ui/display/display_switches.h" | |
26 #include "url/gurl.h" | 28 #include "url/gurl.h" |
27 | 29 |
28 class ChromeSitePerProcessTest : public InProcessBrowserTest { | 30 class ChromeSitePerProcessTest : public InProcessBrowserTest { |
29 public: | 31 public: |
30 ChromeSitePerProcessTest() {} | 32 ChromeSitePerProcessTest() {} |
31 ~ChromeSitePerProcessTest() override {} | 33 ~ChromeSitePerProcessTest() override {} |
32 | 34 |
33 void SetUpCommandLine(base::CommandLine* command_line) override { | 35 void SetUpCommandLine(base::CommandLine* command_line) override { |
34 content::IsolateAllSitesForTesting(command_line); | 36 content::IsolateAllSitesForTesting(command_line); |
35 } | 37 } |
36 | 38 |
37 void SetUpOnMainThread() override { | 39 void SetUpOnMainThread() override { |
38 host_resolver()->AddRule("*", "127.0.0.1"); | 40 host_resolver()->AddRule("*", "127.0.0.1"); |
39 ASSERT_TRUE(embedded_test_server()->Start()); | 41 ASSERT_TRUE(embedded_test_server()->Start()); |
40 content::SetupCrossSiteRedirector(embedded_test_server()); | 42 content::SetupCrossSiteRedirector(embedded_test_server()); |
41 } | 43 } |
42 | 44 |
43 private: | 45 private: |
44 DISALLOW_COPY_AND_ASSIGN(ChromeSitePerProcessTest); | 46 DISALLOW_COPY_AND_ASSIGN(ChromeSitePerProcessTest); |
45 }; | 47 }; |
46 | 48 |
49 class SitePerProcessHighDPIExpiredCertBrowserTest | |
50 : public ChromeSitePerProcessTest { | |
51 public: | |
52 const double kDeviceScaleFactor = 2.0; | |
53 | |
54 SitePerProcessHighDPIExpiredCertBrowserTest() | |
55 : https_server_expired_(net::EmbeddedTestServer::TYPE_HTTPS) { | |
56 https_server_expired_.SetSSLConfig(net::EmbeddedTestServer::CERT_EXPIRED); | |
57 } | |
58 | |
59 net::EmbeddedTestServer https_server_expired_; | |
Lei Zhang
2016/08/24 18:33:51
It would be nice if this wasn't public and there w
wjmaclean
2016/08/24 19:17:07
Done.
I've added a function expired_cert_test_ser
| |
60 | |
61 protected: | |
62 void SetUpCommandLine(base::CommandLine* command_line) override { | |
63 ChromeSitePerProcessTest::SetUpCommandLine(command_line); | |
64 command_line->AppendSwitchASCII( | |
65 switches::kForceDeviceScaleFactor, | |
66 base::StringPrintf("%f", kDeviceScaleFactor)); | |
67 } | |
68 | |
69 void SetUpOnMainThread() override { | |
70 ChromeSitePerProcessTest::SetUpOnMainThread(); | |
71 ASSERT_TRUE(https_server_expired_.Start()); | |
72 } | |
73 }; | |
74 | |
75 double GetFrameDeviceScaleFactor(const content::ToRenderFrameHost& adapter) { | |
76 double device_scale_factor; | |
77 const char kGetFrameDeviceScaleFactor[] = | |
78 "window.domAutomationController.send(window.devicePixelRatio);"; | |
79 EXPECT_TRUE(ExecuteScriptAndExtractDouble(adapter, kGetFrameDeviceScaleFactor, | |
80 &device_scale_factor)); | |
81 return device_scale_factor; | |
82 } | |
83 | |
84 IN_PROC_BROWSER_TEST_F(SitePerProcessHighDPIExpiredCertBrowserTest, | |
85 InterstitialLoadsWithCorrectDeviceScaleFactor) { | |
86 GURL main_url(embedded_test_server()->GetURL( | |
87 "a.com", "/cross_site_iframe_factory.html?a(b)")); | |
88 ui_test_utils::NavigateToURL(browser(), main_url); | |
89 | |
90 EXPECT_EQ(SitePerProcessHighDPIExpiredCertBrowserTest::kDeviceScaleFactor, | |
91 GetFrameDeviceScaleFactor( | |
92 browser()->tab_strip_model()->GetActiveWebContents())); | |
93 | |
94 // Navigate to page with expired cert. | |
95 GURL bad_cert_url(https_server_expired_.GetURL("c.com", "/title1.html")); | |
96 ui_test_utils::NavigateToURL(browser(), bad_cert_url); | |
97 WaitForInterstitialAttach( | |
98 browser()->tab_strip_model()->GetActiveWebContents()); | |
Lei Zhang
2016/08/24 18:33:50
You can also save the GetActiveWebContents() retur
wjmaclean
2016/08/24 19:17:07
Done.
| |
99 EXPECT_TRUE(browser() | |
100 ->tab_strip_model() | |
101 ->GetActiveWebContents() | |
102 ->ShowingInterstitialPage()); | |
103 | |
104 // Here we check the device scale factor in use via the interstitial's | |
105 // RenderFrameHost; doing the check directly via the 'active web contents' | |
106 // does not give us the device scale factor for the interstitial. | |
107 content::RenderFrameHost* interstitial_frame_host = | |
108 browser() | |
109 ->tab_strip_model() | |
110 ->GetActiveWebContents() | |
111 ->GetInterstitialPage() | |
112 ->GetMainFrame(); | |
113 | |
114 EXPECT_EQ(SitePerProcessHighDPIExpiredCertBrowserTest::kDeviceScaleFactor, | |
115 GetFrameDeviceScaleFactor(interstitial_frame_host)); | |
116 } | |
117 | |
47 // Verify that browser shutdown path works correctly when there's a | 118 // Verify that browser shutdown path works correctly when there's a |
48 // RenderFrameProxyHost for a child frame. | 119 // RenderFrameProxyHost for a child frame. |
49 IN_PROC_BROWSER_TEST_F(ChromeSitePerProcessTest, RenderFrameProxyHostShutdown) { | 120 IN_PROC_BROWSER_TEST_F(ChromeSitePerProcessTest, RenderFrameProxyHostShutdown) { |
50 GURL main_url(embedded_test_server()->GetURL( | 121 GURL main_url(embedded_test_server()->GetURL( |
51 "a.com", | 122 "a.com", |
52 "/frame_tree/page_with_two_frames_remote_and_local.html")); | 123 "/frame_tree/page_with_two_frames_remote_and_local.html")); |
53 ui_test_utils::NavigateToURL(browser(), main_url); | 124 ui_test_utils::NavigateToURL(browser(), main_url); |
54 } | 125 } |
55 | 126 |
56 // Verify that origin replication allows JS access to localStorage, database, | 127 // Verify that origin replication allows JS access to localStorage, database, |
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
171 main_lost_focus = true; | 242 main_lost_focus = true; |
172 if (status == "\"popup-got-focus\"") | 243 if (status == "\"popup-got-focus\"") |
173 popup_got_focus = true; | 244 popup_got_focus = true; |
174 if (main_lost_focus && popup_got_focus) | 245 if (main_lost_focus && popup_got_focus) |
175 break; | 246 break; |
176 } | 247 } |
177 | 248 |
178 // The popup should be focused now. | 249 // The popup should be focused now. |
179 EXPECT_EQ(popup, browser()->tab_strip_model()->GetActiveWebContents()); | 250 EXPECT_EQ(popup, browser()->tab_strip_model()->GetActiveWebContents()); |
180 } | 251 } |
OLD | NEW |