| 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* expired_cert_test_server() { |
| 60 return &https_server_expired_; |
| 61 } |
| 62 |
| 63 protected: |
| 64 void SetUpCommandLine(base::CommandLine* command_line) override { |
| 65 ChromeSitePerProcessTest::SetUpCommandLine(command_line); |
| 66 command_line->AppendSwitchASCII( |
| 67 switches::kForceDeviceScaleFactor, |
| 68 base::StringPrintf("%f", kDeviceScaleFactor)); |
| 69 } |
| 70 |
| 71 void SetUpOnMainThread() override { |
| 72 ChromeSitePerProcessTest::SetUpOnMainThread(); |
| 73 ASSERT_TRUE(https_server_expired_.Start()); |
| 74 } |
| 75 |
| 76 private: |
| 77 net::EmbeddedTestServer https_server_expired_; |
| 78 }; |
| 79 |
| 80 double GetFrameDeviceScaleFactor(const content::ToRenderFrameHost& adapter) { |
| 81 double device_scale_factor; |
| 82 const char kGetFrameDeviceScaleFactor[] = |
| 83 "window.domAutomationController.send(window.devicePixelRatio);"; |
| 84 EXPECT_TRUE(ExecuteScriptAndExtractDouble(adapter, kGetFrameDeviceScaleFactor, |
| 85 &device_scale_factor)); |
| 86 return device_scale_factor; |
| 87 } |
| 88 |
| 89 IN_PROC_BROWSER_TEST_F(SitePerProcessHighDPIExpiredCertBrowserTest, |
| 90 InterstitialLoadsWithCorrectDeviceScaleFactor) { |
| 91 GURL main_url(embedded_test_server()->GetURL( |
| 92 "a.com", "/cross_site_iframe_factory.html?a(b)")); |
| 93 ui_test_utils::NavigateToURL(browser(), main_url); |
| 94 |
| 95 EXPECT_EQ(SitePerProcessHighDPIExpiredCertBrowserTest::kDeviceScaleFactor, |
| 96 GetFrameDeviceScaleFactor( |
| 97 browser()->tab_strip_model()->GetActiveWebContents())); |
| 98 |
| 99 // Navigate to page with expired cert. |
| 100 GURL bad_cert_url( |
| 101 expired_cert_test_server()->GetURL("c.com", "/title1.html")); |
| 102 ui_test_utils::NavigateToURL(browser(), bad_cert_url); |
| 103 content::WebContents* active_web_contents = |
| 104 browser()->tab_strip_model()->GetActiveWebContents(); |
| 105 WaitForInterstitialAttach(active_web_contents); |
| 106 EXPECT_TRUE(active_web_contents->ShowingInterstitialPage()); |
| 107 |
| 108 // Here we check the device scale factor in use via the interstitial's |
| 109 // RenderFrameHost; doing the check directly via the 'active web contents' |
| 110 // does not give us the device scale factor for the interstitial. |
| 111 content::RenderFrameHost* interstitial_frame_host = |
| 112 active_web_contents->GetInterstitialPage()->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 |