OLD | NEW |
(Empty) | |
| 1 // Copyright 2016 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. |
| 4 |
| 5 #include "base/command_line.h" |
| 6 #include "chrome/browser/ui/browser.h" |
| 7 #include "chrome/browser/ui/browser_tabstrip.h" |
| 8 #include "chrome/browser/ui/tabs/tab_strip_model.h" |
| 9 #include "chrome/test/base/in_process_browser_test.h" |
| 10 #include "chrome/test/base/ui_test_utils.h" |
| 11 #include "content/public/browser/render_frame_host.h" |
| 12 #include "content/public/browser/render_view_host.h" |
| 13 #include "content/public/browser/render_widget_host_view.h" |
| 14 #include "content/public/browser/web_contents.h" |
| 15 #include "content/public/common/content_switches.h" |
| 16 #include "content/public/test/browser_test_utils.h" |
| 17 #include "content/public/test/test_utils.h" |
| 18 #include "net/dns/mock_host_resolver.h" |
| 19 #include "net/test/embedded_test_server/embedded_test_server.h" |
| 20 #include "url/gurl.h" |
| 21 #include "url/url_constants.h" |
| 22 |
| 23 namespace payments { |
| 24 |
| 25 class SitePerProcessPaymentsBrowserTest : public InProcessBrowserTest { |
| 26 public: |
| 27 SitePerProcessPaymentsBrowserTest() {} |
| 28 ~SitePerProcessPaymentsBrowserTest() override {} |
| 29 |
| 30 private: |
| 31 void SetUpCommandLine(base::CommandLine* command_line) override { |
| 32 InProcessBrowserTest::SetUpCommandLine(command_line); |
| 33 command_line->AppendSwitch(switches::kIgnoreCertificateErrors); |
| 34 command_line->AppendSwitch("enable-experimental-web-platform-features"); |
| 35 // Append --site-per-process flag. |
| 36 content::IsolateAllSitesForTesting(command_line); |
| 37 } |
| 38 |
| 39 DISALLOW_COPY_AND_ASSIGN(SitePerProcessPaymentsBrowserTest); |
| 40 }; |
| 41 |
| 42 IN_PROC_BROWSER_TEST_F(SitePerProcessPaymentsBrowserTest, |
| 43 IframePaymentRequestDoesNotCrash) { |
| 44 net::EmbeddedTestServer https_server(net::EmbeddedTestServer::TYPE_HTTPS); |
| 45 host_resolver()->AddRule("*", "127.0.0.1"); |
| 46 ASSERT_TRUE(https_server.InitializeAndListen()); |
| 47 content::SetupCrossSiteRedirector(&https_server); |
| 48 https_server.ServeFilesFromSourceDirectory("chrome/test/data"); |
| 49 https_server.StartAcceptingConnections(); |
| 50 |
| 51 GURL url = https_server.GetURL("a.com", "/payment_request_main.html"); |
| 52 ui_test_utils::NavigateToURL(browser(), url); |
| 53 |
| 54 content::WebContents* tab = |
| 55 browser()->tab_strip_model()->GetActiveWebContents(); |
| 56 GURL iframe_url = |
| 57 https_server.GetURL("b.com", "/payment_request_iframe.html"); |
| 58 EXPECT_TRUE(content::NavigateIframeToURL(tab, "test", iframe_url)); |
| 59 |
| 60 EXPECT_TRUE(tab->GetRenderWidgetHostView()->IsShowing()); |
| 61 content::RenderFrameHost* frame = ChildFrameAt(tab->GetMainFrame(), 0); |
| 62 EXPECT_TRUE(frame); |
| 63 EXPECT_NE(frame->GetSiteInstance(), tab->GetMainFrame()->GetSiteInstance()); |
| 64 } |
| 65 |
| 66 } // namespace payments |
OLD | NEW |