Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 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 | 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 <vector> | |
| 6 | |
| 5 #include "base/command_line.h" | 7 #include "base/command_line.h" |
| 6 #include "chrome/browser/ui/browser.h" | 8 #include "chrome/browser/ui/browser.h" |
| 7 #include "chrome/browser/ui/browser_tabstrip.h" | 9 #include "chrome/browser/ui/browser_tabstrip.h" |
| 8 #include "chrome/browser/ui/tabs/tab_strip_model.h" | 10 #include "chrome/browser/ui/tabs/tab_strip_model.h" |
| 9 #include "chrome/test/base/in_process_browser_test.h" | 11 #include "chrome/test/base/in_process_browser_test.h" |
| 10 #include "chrome/test/base/ui_test_utils.h" | 12 #include "chrome/test/base/ui_test_utils.h" |
| 13 #include "components/payments/payment_request_impl.h" | |
| 14 #include "components/payments/payment_request_web_contents_manager.h" | |
| 11 #include "content/public/browser/render_frame_host.h" | 15 #include "content/public/browser/render_frame_host.h" |
| 12 #include "content/public/browser/render_view_host.h" | 16 #include "content/public/browser/render_view_host.h" |
| 13 #include "content/public/browser/render_widget_host_view.h" | 17 #include "content/public/browser/render_widget_host_view.h" |
| 14 #include "content/public/browser/web_contents.h" | 18 #include "content/public/browser/web_contents.h" |
| 15 #include "content/public/common/content_switches.h" | 19 #include "content/public/common/content_switches.h" |
| 16 #include "content/public/test/browser_test_utils.h" | 20 #include "content/public/test/browser_test_utils.h" |
| 17 #include "content/public/test/test_utils.h" | 21 #include "content/public/test/test_utils.h" |
| 18 #include "net/dns/mock_host_resolver.h" | 22 #include "net/dns/mock_host_resolver.h" |
| 19 #include "net/test/embedded_test_server/embedded_test_server.h" | 23 #include "net/test/embedded_test_server/embedded_test_server.h" |
| 20 #include "url/gurl.h" | 24 #include "url/gurl.h" |
| (...skipping 19 matching lines...) Expand all Loading... | |
| 40 void SetUpOnMainThread() override { | 44 void SetUpOnMainThread() override { |
| 41 https_server_.reset( | 45 https_server_.reset( |
| 42 new net::EmbeddedTestServer(net::EmbeddedTestServer::TYPE_HTTPS)); | 46 new net::EmbeddedTestServer(net::EmbeddedTestServer::TYPE_HTTPS)); |
| 43 host_resolver()->AddRule("*", "127.0.0.1"); | 47 host_resolver()->AddRule("*", "127.0.0.1"); |
| 44 ASSERT_TRUE(https_server_->InitializeAndListen()); | 48 ASSERT_TRUE(https_server_->InitializeAndListen()); |
| 45 content::SetupCrossSiteRedirector(https_server_.get()); | 49 content::SetupCrossSiteRedirector(https_server_.get()); |
| 46 https_server_->ServeFilesFromSourceDirectory("chrome/test/data"); | 50 https_server_->ServeFilesFromSourceDirectory("chrome/test/data"); |
| 47 https_server_->StartAcceptingConnections(); | 51 https_server_->StartAcceptingConnections(); |
| 48 } | 52 } |
| 49 | 53 |
| 54 // Convenience method to get a list of PaymentRequestImpl associated with | |
| 55 // |web_contents|. | |
| 56 const std::vector<PaymentRequestImpl*> GetPaymentRequestImpls( | |
| 57 content::WebContents* web_contents) { | |
| 58 PaymentRequestWebContentsManager* manager = | |
| 59 PaymentRequestWebContentsManager::GetOrCreateForWebContents( | |
| 60 web_contents); | |
| 61 if (!manager) | |
| 62 return std::vector<PaymentRequestImpl*>(); | |
| 63 | |
| 64 std::vector<PaymentRequestImpl*> payment_requests_ptrs; | |
| 65 for (const auto& p : manager->payment_requests_) { | |
| 66 payment_requests_ptrs.push_back(p.first); | |
| 67 } | |
| 68 return payment_requests_ptrs; | |
| 69 } | |
| 70 | |
| 50 std::unique_ptr<net::EmbeddedTestServer> https_server_; | 71 std::unique_ptr<net::EmbeddedTestServer> https_server_; |
| 51 | 72 |
| 52 private: | 73 private: |
| 53 DISALLOW_COPY_AND_ASSIGN(SitePerProcessPaymentsBrowserTest); | 74 DISALLOW_COPY_AND_ASSIGN(SitePerProcessPaymentsBrowserTest); |
| 54 }; | 75 }; |
| 55 | 76 |
| 56 IN_PROC_BROWSER_TEST_F(SitePerProcessPaymentsBrowserTest, | 77 IN_PROC_BROWSER_TEST_F(SitePerProcessPaymentsBrowserTest, |
| 57 IframePaymentRequestDoesNotCrash) { | 78 IframePaymentRequestDoesNotCrash) { |
| 58 GURL url = https_server_->GetURL("a.com", "/payment_request_main.html"); | 79 GURL url = https_server_->GetURL("a.com", "/payment_request_main.html"); |
| 59 ui_test_utils::NavigateToURL(browser(), url); | 80 ui_test_utils::NavigateToURL(browser(), url); |
| 60 | 81 |
| 61 content::WebContents* tab = | 82 content::WebContents* tab = |
| 62 browser()->tab_strip_model()->GetActiveWebContents(); | 83 browser()->tab_strip_model()->GetActiveWebContents(); |
| 63 GURL iframe_url = | 84 GURL iframe_url = |
| 64 https_server_->GetURL("b.com", "/payment_request_iframe.html"); | 85 https_server_->GetURL("b.com", "/payment_request_iframe.html"); |
| 65 EXPECT_TRUE(content::NavigateIframeToURL(tab, "test", iframe_url)); | 86 EXPECT_TRUE(content::NavigateIframeToURL(tab, "test", iframe_url)); |
| 66 | 87 |
| 67 EXPECT_TRUE(tab->GetRenderWidgetHostView()->IsShowing()); | 88 EXPECT_TRUE(tab->GetRenderWidgetHostView()->IsShowing()); |
| 68 content::RenderFrameHost* frame = ChildFrameAt(tab->GetMainFrame(), 0); | 89 content::RenderFrameHost* frame = ChildFrameAt(tab->GetMainFrame(), 0); |
| 69 EXPECT_TRUE(frame); | 90 EXPECT_TRUE(frame); |
| 70 EXPECT_NE(frame->GetSiteInstance(), tab->GetMainFrame()->GetSiteInstance()); | 91 EXPECT_NE(frame->GetSiteInstance(), tab->GetMainFrame()->GetSiteInstance()); |
| 71 } | 92 } |
| 72 | 93 |
| 94 IN_PROC_BROWSER_TEST_F(SitePerProcessPaymentsBrowserTest, | |
| 95 MultiplePaymentRequests) { | |
| 96 GURL url = | |
| 97 https_server_->GetURL("a.com", "/payment_request_multiple_requests.html"); | |
| 98 ui_test_utils::NavigateToURL(browser(), url); | |
| 99 | |
| 100 const std::vector<PaymentRequestImpl*> payment_requests = | |
| 101 GetPaymentRequestImpls( | |
| 102 browser()->tab_strip_model()->GetActiveWebContents()); | |
| 103 EXPECT_EQ(5U, payment_requests.size()); | |
|
please use gerrit instead
2017/01/06 21:49:09
Would you mind adding a different browser test fil
Mathieu
2017/01/07 05:03:07
Done.
| |
| 104 } | |
| 105 | |
| 73 } // namespace payments | 106 } // namespace payments |
| OLD | NEW |