Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(191)

Side by Side Diff: chrome/browser/prerender/prerender_browsertest.cc

Issue 124113003: Remove calls of PrerenderTracker::TryCancel and TryCancelOnIOThread in ChromeResourceDispatcherHost… (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: simplify Created 6 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 <deque> 5 #include <deque>
6 #include <vector> 6 #include <vector>
7 7
8 #include "base/bind.h" 8 #include "base/bind.h"
9 #include "base/command_line.h" 9 #include "base/command_line.h"
10 #include "base/files/file_path.h" 10 #include "base/files/file_path.h"
(...skipping 14 matching lines...) Expand all
25 #include "chrome/browser/extensions/api/web_navigation/web_navigation_api.h" 25 #include "chrome/browser/extensions/api/web_navigation/web_navigation_api.h"
26 #include "chrome/browser/extensions/extension_apitest.h" 26 #include "chrome/browser/extensions/extension_apitest.h"
27 #include "chrome/browser/favicon/favicon_tab_helper.h" 27 #include "chrome/browser/favicon/favicon_tab_helper.h"
28 #include "chrome/browser/prerender/prerender_contents.h" 28 #include "chrome/browser/prerender/prerender_contents.h"
29 #include "chrome/browser/prerender/prerender_handle.h" 29 #include "chrome/browser/prerender/prerender_handle.h"
30 #include "chrome/browser/prerender/prerender_link_manager.h" 30 #include "chrome/browser/prerender/prerender_link_manager.h"
31 #include "chrome/browser/prerender/prerender_link_manager_factory.h" 31 #include "chrome/browser/prerender/prerender_link_manager_factory.h"
32 #include "chrome/browser/prerender/prerender_manager.h" 32 #include "chrome/browser/prerender/prerender_manager.h"
33 #include "chrome/browser/prerender/prerender_manager_factory.h" 33 #include "chrome/browser/prerender/prerender_manager_factory.h"
34 #include "chrome/browser/profiles/profile.h" 34 #include "chrome/browser/profiles/profile.h"
35 #include "chrome/browser/profiles/profile_io_data.h"
35 #include "chrome/browser/safe_browsing/database_manager.h" 36 #include "chrome/browser/safe_browsing/database_manager.h"
36 #include "chrome/browser/safe_browsing/safe_browsing_service.h" 37 #include "chrome/browser/safe_browsing/safe_browsing_service.h"
37 #include "chrome/browser/safe_browsing/safe_browsing_util.h" 38 #include "chrome/browser/safe_browsing/safe_browsing_util.h"
38 #include "chrome/browser/task_manager/task_manager.h" 39 #include "chrome/browser/task_manager/task_manager.h"
39 #include "chrome/browser/task_manager/task_manager_browsertest_util.h" 40 #include "chrome/browser/task_manager/task_manager_browsertest_util.h"
40 #include "chrome/browser/ui/browser.h" 41 #include "chrome/browser/ui/browser.h"
41 #include "chrome/browser/ui/browser_commands.h" 42 #include "chrome/browser/ui/browser_commands.h"
42 #include "chrome/browser/ui/browser_finder.h" 43 #include "chrome/browser/ui/browser_finder.h"
43 #include "chrome/browser/ui/browser_navigator.h" 44 #include "chrome/browser/ui/browser_navigator.h"
44 #include "chrome/browser/ui/browser_window.h" 45 #include "chrome/browser/ui/browser_window.h"
(...skipping 17 matching lines...) Expand all
62 #include "content/public/browser/site_instance.h" 63 #include "content/public/browser/site_instance.h"
63 #include "content/public/browser/web_contents.h" 64 #include "content/public/browser/web_contents.h"
64 #include "content/public/common/url_constants.h" 65 #include "content/public/common/url_constants.h"
65 #include "content/public/test/browser_test_utils.h" 66 #include "content/public/test/browser_test_utils.h"
66 #include "content/public/test/test_navigation_observer.h" 67 #include "content/public/test/test_navigation_observer.h"
67 #include "content/public/test/test_utils.h" 68 #include "content/public/test/test_utils.h"
68 #include "content/test/net/url_request_mock_http_job.h" 69 #include "content/test/net/url_request_mock_http_job.h"
69 #include "extensions/common/switches.h" 70 #include "extensions/common/switches.h"
70 #include "grit/generated_resources.h" 71 #include "grit/generated_resources.h"
71 #include "net/base/escape.h" 72 #include "net/base/escape.h"
73 #include "net/cert/x509_certificate.h"
72 #include "net/dns/mock_host_resolver.h" 74 #include "net/dns/mock_host_resolver.h"
75 #include "net/ssl/client_cert_store.h"
76 #include "net/ssl/ssl_cert_request_info.h"
73 #include "net/url_request/url_request_context.h" 77 #include "net/url_request/url_request_context.h"
74 #include "net/url_request/url_request_context_getter.h" 78 #include "net/url_request/url_request_context_getter.h"
75 #include "net/url_request/url_request_filter.h" 79 #include "net/url_request/url_request_filter.h"
76 #include "net/url_request/url_request_job.h" 80 #include "net/url_request/url_request_job.h"
77 #include "ui/base/l10n/l10n_util.h" 81 #include "ui/base/l10n/l10n_util.h"
78 #include "url/gurl.h" 82 #include "url/gurl.h"
79 83
80 using content::BrowserThread; 84 using content::BrowserThread;
81 using content::DevToolsAgentHost; 85 using content::DevToolsAgentHost;
82 using content::DevToolsClientHost; 86 using content::DevToolsClientHost;
(...skipping 2425 matching lines...) Expand 10 before | Expand all | Expand 10 after
2508 OpenDestURLViaClickTarget(); 2512 OpenDestURLViaClickTarget();
2509 } 2513 }
2510 2514
2511 #if defined(OS_LINUX) && !defined(OS_CHROMEOS) && defined(USE_AURA) 2515 #if defined(OS_LINUX) && !defined(OS_CHROMEOS) && defined(USE_AURA)
2512 // TODO(erg): linux_aura bringup: http://crbug.com/163931 2516 // TODO(erg): linux_aura bringup: http://crbug.com/163931
2513 #define MAYBE_PrerenderSSLClientCertTopLevel DISABLED_PrerenderSSLClientCertTopL evel 2517 #define MAYBE_PrerenderSSLClientCertTopLevel DISABLED_PrerenderSSLClientCertTopL evel
2514 #else 2518 #else
2515 #define MAYBE_PrerenderSSLClientCertTopLevel PrerenderSSLClientCertTopLevel 2519 #define MAYBE_PrerenderSSLClientCertTopLevel PrerenderSSLClientCertTopLevel
2516 #endif 2520 #endif
2517 2521
2522 class TestClientCertStore : public net::ClientCertStore {
2523 public:
2524 TestClientCertStore() {}
2525 virtual ~TestClientCertStore() {}
2526
2527 // net::ClientCertStore:
2528 virtual void GetClientCerts(const net::SSLCertRequestInfo& cert_request_info,
2529 net::CertificateList* selected_certs,
2530 const base::Closure& callback) OVERRIDE {
2531 *selected_certs = net::CertificateList(
2532 1, scoped_refptr<net::X509Certificate>(
2533 new net::X509Certificate("test", "test", base::Time(), base::Time())));
2534 callback.Run();
2535 }
2536
2537 private:
2538 const net::CertificateList response_;
davidben 2014/01/06 22:14:47 Remnant from a previous version?
jam 2014/01/06 22:21:00 oops, copy and paste. removed
2539 };
2540
2541 scoped_ptr<net::ClientCertStore> CreateCertStore() {
2542 return scoped_ptr<net::ClientCertStore>(new TestClientCertStore);
2543 }
2544
2518 // Checks that a top-level page which would normally request an SSL client 2545 // Checks that a top-level page which would normally request an SSL client
2519 // certificate will never be seen since it's an https top-level resource. 2546 // certificate will never be seen since it's an https top-level resource.
2520 IN_PROC_BROWSER_TEST_F(PrerenderBrowserTest, 2547 IN_PROC_BROWSER_TEST_F(PrerenderBrowserTest,
2521 MAYBE_PrerenderSSLClientCertTopLevel) { 2548 MAYBE_PrerenderSSLClientCertTopLevel) {
2549 ProfileIOData::FromResourceContext(
2550 current_browser()->profile()->GetResourceContext())->
2551 set_client_cert_store_factory_for_testing(
2552 base::Bind(&CreateCertStore));
2522 net::SpawnedTestServer::SSLOptions ssl_options; 2553 net::SpawnedTestServer::SSLOptions ssl_options;
2523 ssl_options.request_client_certificate = true; 2554 ssl_options.request_client_certificate = true;
2524 net::SpawnedTestServer https_server( 2555 net::SpawnedTestServer https_server(
2525 net::SpawnedTestServer::TYPE_HTTPS, ssl_options, 2556 net::SpawnedTestServer::TYPE_HTTPS, ssl_options,
2526 base::FilePath(FILE_PATH_LITERAL("chrome/test/data"))); 2557 base::FilePath(FILE_PATH_LITERAL("chrome/test/data")));
2527 ASSERT_TRUE(https_server.Start()); 2558 ASSERT_TRUE(https_server.Start());
2528 GURL https_url = https_server.GetURL("files/prerender/prerender_page.html"); 2559 GURL https_url = https_server.GetURL("files/prerender/prerender_page.html");
2529 PrerenderTestURL(https_url, FINAL_STATUS_SSL_CLIENT_CERTIFICATE_REQUESTED, 0); 2560 PrerenderTestURL(https_url, FINAL_STATUS_SSL_CLIENT_CERTIFICATE_REQUESTED, 0);
2530 } 2561 }
2531 2562
2532 // Checks that an SSL Client Certificate request that originates from a 2563 // Checks that an SSL Client Certificate request that originates from a
2533 // subresource will cancel the prerendered page. 2564 // subresource will cancel the prerendered page.
2534 IN_PROC_BROWSER_TEST_F(PrerenderBrowserTest, 2565 IN_PROC_BROWSER_TEST_F(PrerenderBrowserTest,
2535 PrerenderSSLClientCertSubresource) { 2566 PrerenderSSLClientCertSubresource) {
2567 ProfileIOData::FromResourceContext(
2568 current_browser()->profile()->GetResourceContext())->
2569 set_client_cert_store_factory_for_testing(
2570 base::Bind(&CreateCertStore));
2536 net::SpawnedTestServer::SSLOptions ssl_options; 2571 net::SpawnedTestServer::SSLOptions ssl_options;
2537 ssl_options.request_client_certificate = true; 2572 ssl_options.request_client_certificate = true;
2538 net::SpawnedTestServer https_server( 2573 net::SpawnedTestServer https_server(
2539 net::SpawnedTestServer::TYPE_HTTPS, ssl_options, 2574 net::SpawnedTestServer::TYPE_HTTPS, ssl_options,
2540 base::FilePath(FILE_PATH_LITERAL("chrome/test/data"))); 2575 base::FilePath(FILE_PATH_LITERAL("chrome/test/data")));
2541 ASSERT_TRUE(https_server.Start()); 2576 ASSERT_TRUE(https_server.Start());
2542 GURL https_url = https_server.GetURL("files/prerender/image.jpeg"); 2577 GURL https_url = https_server.GetURL("files/prerender/image.jpeg");
2543 std::vector<net::SpawnedTestServer::StringPair> replacement_text; 2578 std::vector<net::SpawnedTestServer::StringPair> replacement_text;
2544 replacement_text.push_back( 2579 replacement_text.push_back(
2545 std::make_pair("REPLACE_WITH_IMAGE_URL", https_url.spec())); 2580 std::make_pair("REPLACE_WITH_IMAGE_URL", https_url.spec()));
2546 std::string replacement_path; 2581 std::string replacement_path;
2547 ASSERT_TRUE(net::SpawnedTestServer::GetFilePathWithReplacements( 2582 ASSERT_TRUE(net::SpawnedTestServer::GetFilePathWithReplacements(
2548 "files/prerender/prerender_with_image.html", 2583 "files/prerender/prerender_with_image.html",
2549 replacement_text, 2584 replacement_text,
2550 &replacement_path)); 2585 &replacement_path));
2551 PrerenderTestURL(replacement_path, 2586 PrerenderTestURL(replacement_path,
2552 FINAL_STATUS_SSL_CLIENT_CERTIFICATE_REQUESTED, 2587 FINAL_STATUS_SSL_CLIENT_CERTIFICATE_REQUESTED,
2553 0); 2588 0);
2554 } 2589 }
2555 2590
2556 // Checks that an SSL Client Certificate request that originates from an 2591 // Checks that an SSL Client Certificate request that originates from an
2557 // iframe will cancel the prerendered page. 2592 // iframe will cancel the prerendered page.
2558 IN_PROC_BROWSER_TEST_F(PrerenderBrowserTest, PrerenderSSLClientCertIframe) { 2593 IN_PROC_BROWSER_TEST_F(PrerenderBrowserTest, PrerenderSSLClientCertIframe) {
2594 ProfileIOData::FromResourceContext(
2595 current_browser()->profile()->GetResourceContext())->
2596 set_client_cert_store_factory_for_testing(
2597 base::Bind(&CreateCertStore));
2559 net::SpawnedTestServer::SSLOptions ssl_options; 2598 net::SpawnedTestServer::SSLOptions ssl_options;
2560 ssl_options.request_client_certificate = true; 2599 ssl_options.request_client_certificate = true;
2561 net::SpawnedTestServer https_server( 2600 net::SpawnedTestServer https_server(
2562 net::SpawnedTestServer::TYPE_HTTPS, ssl_options, 2601 net::SpawnedTestServer::TYPE_HTTPS, ssl_options,
2563 base::FilePath(FILE_PATH_LITERAL("chrome/test/data"))); 2602 base::FilePath(FILE_PATH_LITERAL("chrome/test/data")));
2564 ASSERT_TRUE(https_server.Start()); 2603 ASSERT_TRUE(https_server.Start());
2565 GURL https_url = https_server.GetURL( 2604 GURL https_url = https_server.GetURL(
2566 "files/prerender/prerender_embedded_content.html"); 2605 "files/prerender/prerender_embedded_content.html");
2567 std::vector<net::SpawnedTestServer::StringPair> replacement_text; 2606 std::vector<net::SpawnedTestServer::StringPair> replacement_text;
2568 replacement_text.push_back( 2607 replacement_text.push_back(
(...skipping 791 matching lines...) Expand 10 before | Expand all | Expand 10 after
3360 const NavigationController& controller = web_contents->GetController(); 3399 const NavigationController& controller = web_contents->GetController();
3361 // First entry is about:blank, second is prerender_page.html. 3400 // First entry is about:blank, second is prerender_page.html.
3362 EXPECT_TRUE(controller.GetPendingEntry() == NULL); 3401 EXPECT_TRUE(controller.GetPendingEntry() == NULL);
3363 EXPECT_EQ(2, controller.GetEntryCount()); 3402 EXPECT_EQ(2, controller.GetEntryCount());
3364 EXPECT_EQ(GURL(content::kAboutBlankURL), 3403 EXPECT_EQ(GURL(content::kAboutBlankURL),
3365 controller.GetEntryAtIndex(0)->GetURL()); 3404 controller.GetEntryAtIndex(0)->GetURL());
3366 EXPECT_EQ(dest_url(), controller.GetEntryAtIndex(1)->GetURL()); 3405 EXPECT_EQ(dest_url(), controller.GetEntryAtIndex(1)->GetURL());
3367 } 3406 }
3368 3407
3369 } // namespace prerender 3408 } // namespace prerender
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698