OLD | NEW |
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 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
76 #include "content/public/browser/render_view_host.h" | 76 #include "content/public/browser/render_view_host.h" |
77 #include "content/public/browser/site_instance.h" | 77 #include "content/public/browser/site_instance.h" |
78 #include "content/public/browser/web_contents.h" | 78 #include "content/public/browser/web_contents.h" |
79 #include "content/public/browser/web_contents_observer.h" | 79 #include "content/public/browser/web_contents_observer.h" |
80 #include "content/public/common/url_constants.h" | 80 #include "content/public/common/url_constants.h" |
81 #include "content/public/test/browser_test_utils.h" | 81 #include "content/public/test/browser_test_utils.h" |
82 #include "content/public/test/test_navigation_observer.h" | 82 #include "content/public/test/test_navigation_observer.h" |
83 #include "content/public/test/test_utils.h" | 83 #include "content/public/test/test_utils.h" |
84 #include "content/test/net/url_request_mock_http_job.h" | 84 #include "content/test/net/url_request_mock_http_job.h" |
85 #include "extensions/common/switches.h" | 85 #include "extensions/common/switches.h" |
| 86 #include "extensions/test/result_catcher.h" |
86 #include "net/base/escape.h" | 87 #include "net/base/escape.h" |
87 #include "net/cert/x509_certificate.h" | 88 #include "net/cert/x509_certificate.h" |
88 #include "net/dns/mock_host_resolver.h" | 89 #include "net/dns/mock_host_resolver.h" |
89 #include "net/ssl/client_cert_store.h" | 90 #include "net/ssl/client_cert_store.h" |
90 #include "net/ssl/ssl_cert_request_info.h" | 91 #include "net/ssl/ssl_cert_request_info.h" |
91 #include "net/url_request/url_request_context.h" | 92 #include "net/url_request/url_request_context.h" |
92 #include "net/url_request/url_request_context_getter.h" | 93 #include "net/url_request/url_request_context_getter.h" |
93 #include "net/url_request/url_request_filter.h" | 94 #include "net/url_request/url_request_filter.h" |
94 #include "net/url_request/url_request_interceptor.h" | 95 #include "net/url_request/url_request_interceptor.h" |
95 #include "net/url_request/url_request_job.h" | 96 #include "net/url_request/url_request_job.h" |
(...skipping 3435 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3531 } | 3532 } |
3532 }; | 3533 }; |
3533 | 3534 |
3534 IN_PROC_BROWSER_TEST_F(PrerenderBrowserTestWithExtensions, WebNavigation) { | 3535 IN_PROC_BROWSER_TEST_F(PrerenderBrowserTestWithExtensions, WebNavigation) { |
3535 ASSERT_TRUE(StartSpawnedTestServer()); | 3536 ASSERT_TRUE(StartSpawnedTestServer()); |
3536 extensions::FrameNavigationState::set_allow_extension_scheme(true); | 3537 extensions::FrameNavigationState::set_allow_extension_scheme(true); |
3537 | 3538 |
3538 // Wait for the extension to set itself up and return control to us. | 3539 // Wait for the extension to set itself up and return control to us. |
3539 ASSERT_TRUE(RunExtensionTest("webnavigation/prerender")) << message_; | 3540 ASSERT_TRUE(RunExtensionTest("webnavigation/prerender")) << message_; |
3540 | 3541 |
3541 ResultCatcher catcher; | 3542 extensions::ResultCatcher catcher; |
3542 | 3543 |
3543 PrerenderTestURL("files/prerender/prerender_page.html", FINAL_STATUS_USED, 1); | 3544 PrerenderTestURL("files/prerender/prerender_page.html", FINAL_STATUS_USED, 1); |
3544 | 3545 |
3545 ChannelDestructionWatcher channel_close_watcher; | 3546 ChannelDestructionWatcher channel_close_watcher; |
3546 channel_close_watcher.WatchChannel(browser()->tab_strip_model()-> | 3547 channel_close_watcher.WatchChannel(browser()->tab_strip_model()-> |
3547 GetActiveWebContents()->GetRenderProcessHost()); | 3548 GetActiveWebContents()->GetRenderProcessHost()); |
3548 NavigateToDestURL(); | 3549 NavigateToDestURL(); |
3549 channel_close_watcher.WaitForChannelClose(); | 3550 channel_close_watcher.WaitForChannelClose(); |
3550 | 3551 |
3551 ASSERT_TRUE(IsEmptyPrerenderLinkManager()); | 3552 ASSERT_TRUE(IsEmptyPrerenderLinkManager()); |
3552 ASSERT_TRUE(catcher.GetNextResult()) << catcher.message(); | 3553 ASSERT_TRUE(catcher.GetNextResult()) << catcher.message(); |
3553 } | 3554 } |
3554 | 3555 |
3555 IN_PROC_BROWSER_TEST_F(PrerenderBrowserTestWithExtensions, TabsApi) { | 3556 IN_PROC_BROWSER_TEST_F(PrerenderBrowserTestWithExtensions, TabsApi) { |
3556 ASSERT_TRUE(StartSpawnedTestServer()); | 3557 ASSERT_TRUE(StartSpawnedTestServer()); |
3557 extensions::FrameNavigationState::set_allow_extension_scheme(true); | 3558 extensions::FrameNavigationState::set_allow_extension_scheme(true); |
3558 | 3559 |
3559 // Wait for the extension to set itself up and return control to us. | 3560 // Wait for the extension to set itself up and return control to us. |
3560 ASSERT_TRUE(RunExtensionTest("tabs/on_replaced")) << message_; | 3561 ASSERT_TRUE(RunExtensionTest("tabs/on_replaced")) << message_; |
3561 | 3562 |
3562 ResultCatcher catcher; | 3563 extensions::ResultCatcher catcher; |
3563 | 3564 |
3564 PrerenderTestURL("files/prerender/prerender_page.html", FINAL_STATUS_USED, 1); | 3565 PrerenderTestURL("files/prerender/prerender_page.html", FINAL_STATUS_USED, 1); |
3565 | 3566 |
3566 ChannelDestructionWatcher channel_close_watcher; | 3567 ChannelDestructionWatcher channel_close_watcher; |
3567 channel_close_watcher.WatchChannel(browser()->tab_strip_model()-> | 3568 channel_close_watcher.WatchChannel(browser()->tab_strip_model()-> |
3568 GetActiveWebContents()->GetRenderProcessHost()); | 3569 GetActiveWebContents()->GetRenderProcessHost()); |
3569 NavigateToDestURL(); | 3570 NavigateToDestURL(); |
3570 channel_close_watcher.WaitForChannelClose(); | 3571 channel_close_watcher.WaitForChannelClose(); |
3571 | 3572 |
3572 ASSERT_TRUE(IsEmptyPrerenderLinkManager()); | 3573 ASSERT_TRUE(IsEmptyPrerenderLinkManager()); |
(...skipping 13 matching lines...) Expand all Loading... |
3586 MimeTypesHandler* handler = MimeTypesHandler::GetHandler(extension); | 3587 MimeTypesHandler* handler = MimeTypesHandler::GetHandler(extension); |
3587 ASSERT_TRUE(handler); | 3588 ASSERT_TRUE(handler); |
3588 EXPECT_TRUE(handler->CanHandleMIMEType("application/msword")); | 3589 EXPECT_TRUE(handler->CanHandleMIMEType("application/msword")); |
3589 | 3590 |
3590 PrerenderTestURL("files/prerender/document.doc", FINAL_STATUS_DOWNLOAD, 0); | 3591 PrerenderTestURL("files/prerender/document.doc", FINAL_STATUS_DOWNLOAD, 0); |
3591 | 3592 |
3592 // Sanity-check that the extension would have picked up the stream in a normal | 3593 // Sanity-check that the extension would have picked up the stream in a normal |
3593 // navigation had prerender not intercepted it. | 3594 // navigation had prerender not intercepted it. |
3594 // streams_private/handle_mime_type reports success if it has handled the | 3595 // streams_private/handle_mime_type reports success if it has handled the |
3595 // application/msword type. | 3596 // application/msword type. |
3596 ResultCatcher catcher; | 3597 extensions::ResultCatcher catcher; |
3597 NavigateToDestURL(); | 3598 NavigateToDestURL(); |
3598 EXPECT_TRUE(catcher.GetNextResult()); | 3599 EXPECT_TRUE(catcher.GetNextResult()); |
3599 } | 3600 } |
3600 | 3601 |
3601 // Checks that non-http/https/chrome-extension subresource cancels the | 3602 // Checks that non-http/https/chrome-extension subresource cancels the |
3602 // prerender. | 3603 // prerender. |
3603 IN_PROC_BROWSER_TEST_F(PrerenderBrowserTest, | 3604 IN_PROC_BROWSER_TEST_F(PrerenderBrowserTest, |
3604 PrerenderCancelSubresourceUnsupportedScheme) { | 3605 PrerenderCancelSubresourceUnsupportedScheme) { |
3605 GURL image_url = GURL("invalidscheme://www.google.com/test.jpg"); | 3606 GURL image_url = GURL("invalidscheme://www.google.com/test.jpg"); |
3606 std::vector<net::SpawnedTestServer::StringPair> replacement_text; | 3607 std::vector<net::SpawnedTestServer::StringPair> replacement_text; |
(...skipping 810 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4417 | 4418 |
4418 // Navigate to the URL entered. | 4419 // Navigate to the URL entered. |
4419 omnibox_view->model()->AcceptInput(CURRENT_TAB, false); | 4420 omnibox_view->model()->AcceptInput(CURRENT_TAB, false); |
4420 | 4421 |
4421 // Prerender should be running, but abandoned. | 4422 // Prerender should be running, but abandoned. |
4422 EXPECT_TRUE( | 4423 EXPECT_TRUE( |
4423 GetAutocompleteActionPredictor()->IsPrerenderAbandonedForTesting()); | 4424 GetAutocompleteActionPredictor()->IsPrerenderAbandonedForTesting()); |
4424 } | 4425 } |
4425 | 4426 |
4426 } // namespace prerender | 4427 } // namespace prerender |
OLD | NEW |