Chromium Code Reviews| 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 // This file contains download browser tests that are known to be runnable | 5 // This file contains download browser tests that are known to be runnable |
| 6 // in a pure content context. Over time tests should be migrated here. | 6 // in a pure content context. Over time tests should be migrated here. |
| 7 | 7 |
| 8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
| 9 #include "base/files/file_path.h" | 9 #include "base/files/file_path.h" |
| 10 #include "base/files/file_util.h" | 10 #include "base/files/file_util.h" |
| (...skipping 19 matching lines...) Expand all Loading... | |
| 30 #include "content/public/test/download_test_observer.h" | 30 #include "content/public/test/download_test_observer.h" |
| 31 #include "content/public/test/test_file_error_injector.h" | 31 #include "content/public/test/test_file_error_injector.h" |
| 32 #include "content/public/test/test_utils.h" | 32 #include "content/public/test/test_utils.h" |
| 33 #include "content/shell/browser/shell.h" | 33 #include "content/shell/browser/shell.h" |
| 34 #include "content/shell/browser/shell_browser_context.h" | 34 #include "content/shell/browser/shell_browser_context.h" |
| 35 #include "content/shell/browser/shell_download_manager_delegate.h" | 35 #include "content/shell/browser/shell_download_manager_delegate.h" |
| 36 #include "content/shell/browser/shell_network_delegate.h" | 36 #include "content/shell/browser/shell_network_delegate.h" |
| 37 #include "net/test/embedded_test_server/embedded_test_server.h" | 37 #include "net/test/embedded_test_server/embedded_test_server.h" |
| 38 #include "net/test/embedded_test_server/http_request.h" | 38 #include "net/test/embedded_test_server/http_request.h" |
| 39 #include "net/test/embedded_test_server/http_response.h" | 39 #include "net/test/embedded_test_server/http_response.h" |
| 40 #include "net/test/spawned_test_server/spawned_test_server.h" | |
| 41 #include "net/test/url_request/url_request_mock_http_job.h" | 40 #include "net/test/url_request/url_request_mock_http_job.h" |
|
mmenke
2015/11/03 19:12:57
Why did you remove the spawned_test_server header?
svaldez
2015/11/03 19:33:16
Done.
| |
| 42 #include "net/test/url_request/url_request_slow_download_job.h" | 41 #include "net/test/url_request/url_request_slow_download_job.h" |
| 43 #include "testing/gmock/include/gmock/gmock.h" | 42 #include "testing/gmock/include/gmock/gmock.h" |
| 44 #include "testing/gtest/include/gtest/gtest.h" | 43 #include "testing/gtest/include/gtest/gtest.h" |
| 45 #include "url/gurl.h" | 44 #include "url/gurl.h" |
| 46 | 45 |
| 47 #if defined(ENABLE_PLUGINS) | 46 #if defined(ENABLE_PLUGINS) |
| 48 #include "content/browser/plugin_service_impl.h" | 47 #include "content/browser/plugin_service_impl.h" |
| 49 #endif | 48 #endif |
| 50 | 49 |
| 51 using ::net::test_server::EmbeddedTestServer; | |
| 52 using ::testing::AllOf; | 50 using ::testing::AllOf; |
| 53 using ::testing::Field; | 51 using ::testing::Field; |
| 54 using ::testing::InSequence; | 52 using ::testing::InSequence; |
| 55 using ::testing::Property; | 53 using ::testing::Property; |
| 56 using ::testing::Return; | 54 using ::testing::Return; |
| 57 using ::testing::StrictMock; | 55 using ::testing::StrictMock; |
| 58 using ::testing::_; | 56 using ::testing::_; |
| 59 | 57 |
| 60 namespace content { | 58 namespace content { |
| 61 | 59 |
| (...skipping 452 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 514 if (request.relative_url == relative_url) { | 512 if (request.relative_url == relative_url) { |
| 515 response.reset(new net::test_server::BasicHttpResponse); | 513 response.reset(new net::test_server::BasicHttpResponse); |
| 516 response->set_code(net::HTTP_FOUND); | 514 response->set_code(net::HTTP_FOUND); |
| 517 response->AddCustomHeader("Location", target_url.spec()); | 515 response->AddCustomHeader("Location", target_url.spec()); |
| 518 } | 516 } |
| 519 return response.Pass(); | 517 return response.Pass(); |
| 520 } | 518 } |
| 521 | 519 |
| 522 // Creates a request handler for EmbeddedTestServer that responds with a HTTP | 520 // Creates a request handler for EmbeddedTestServer that responds with a HTTP |
| 523 // 302 redirect if the request URL matches |relative_url|. | 521 // 302 redirect if the request URL matches |relative_url|. |
| 524 EmbeddedTestServer::HandleRequestCallback CreateRedirectHandler( | 522 net::EmbeddedTestServer::HandleRequestCallback CreateRedirectHandler( |
| 525 const std::string& relative_url, | 523 const std::string& relative_url, |
| 526 const GURL& target_url) { | 524 const GURL& target_url) { |
| 527 return base::Bind( | 525 return base::Bind( |
| 528 &HandleRequestAndSendRedirectResponse, relative_url, target_url); | 526 &HandleRequestAndSendRedirectResponse, relative_url, target_url); |
| 529 } | 527 } |
| 530 | 528 |
| 531 // Request handler to be used with CreateBasicResponseHandler(). | 529 // Request handler to be used with CreateBasicResponseHandler(). |
| 532 scoped_ptr<net::test_server::HttpResponse> HandleRequestAndSendBasicResponse( | 530 scoped_ptr<net::test_server::HttpResponse> HandleRequestAndSendBasicResponse( |
| 533 const std::string& relative_url, | 531 const std::string& relative_url, |
| 534 const std::string& content_type, | 532 const std::string& content_type, |
| 535 const std::string& body, | 533 const std::string& body, |
| 536 const net::test_server::HttpRequest& request) { | 534 const net::test_server::HttpRequest& request) { |
| 537 scoped_ptr<net::test_server::BasicHttpResponse> response; | 535 scoped_ptr<net::test_server::BasicHttpResponse> response; |
| 538 if (request.relative_url == relative_url) { | 536 if (request.relative_url == relative_url) { |
| 539 response.reset(new net::test_server::BasicHttpResponse); | 537 response.reset(new net::test_server::BasicHttpResponse); |
| 540 response->set_content_type(content_type); | 538 response->set_content_type(content_type); |
| 541 response->set_content(body); | 539 response->set_content(body); |
| 542 } | 540 } |
| 543 return response.Pass(); | 541 return response.Pass(); |
| 544 } | 542 } |
| 545 | 543 |
| 546 // Creates a request handler for an EmbeddedTestServer that response with an | 544 // Creates a request handler for an EmbeddedTestServer that response with an |
| 547 // HTTP 200 status code, a Content-Type header and a body. | 545 // HTTP 200 status code, a Content-Type header and a body. |
| 548 EmbeddedTestServer::HandleRequestCallback CreateBasicResponseHandler( | 546 net::EmbeddedTestServer::HandleRequestCallback CreateBasicResponseHandler( |
| 549 const std::string& relative_url, | 547 const std::string& relative_url, |
| 550 const std::string& content_type, | 548 const std::string& content_type, |
| 551 const std::string& body) { | 549 const std::string& body) { |
| 552 return base::Bind( | 550 return base::Bind( |
| 553 &HandleRequestAndSendBasicResponse, relative_url, content_type, body); | 551 &HandleRequestAndSendBasicResponse, relative_url, content_type, body); |
| 554 } | 552 } |
| 555 | 553 |
| 556 } // namespace | 554 } // namespace |
| 557 | 555 |
| 558 class DownloadContentTest : public ContentBrowserTest { | 556 class DownloadContentTest : public ContentBrowserTest { |
| (...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 695 ASSERT_EQ(size, download->GetReceivedBytes()); | 693 ASSERT_EQ(size, download->GetReceivedBytes()); |
| 696 ASSERT_EQ(DownloadItem::IN_PROGRESS, download->GetState()); | 694 ASSERT_EQ(DownloadItem::IN_PROGRESS, download->GetState()); |
| 697 } | 695 } |
| 698 | 696 |
| 699 // Tell the test server to release a pending RST and confirm | 697 // Tell the test server to release a pending RST and confirm |
| 700 // that the interrupt is received properly (for download resumption | 698 // that the interrupt is received properly (for download resumption |
| 701 // testing). | 699 // testing). |
| 702 void ReleaseRSTAndConfirmInterruptForResume(DownloadItem* download) { | 700 void ReleaseRSTAndConfirmInterruptForResume(DownloadItem* download) { |
| 703 scoped_ptr<DownloadTestObserver> rst_observer( | 701 scoped_ptr<DownloadTestObserver> rst_observer( |
| 704 CreateInterruptedWaiter(shell(), 1)); | 702 CreateInterruptedWaiter(shell(), 1)); |
| 705 NavigateToURL(shell(), test_server()->GetURL("download-finish")); | 703 NavigateToURL(shell(), spawned_test_server()->GetURL("download-finish")); |
| 706 rst_observer->WaitForFinished(); | 704 rst_observer->WaitForFinished(); |
| 707 EXPECT_EQ(DownloadItem::INTERRUPTED, download->GetState()); | 705 EXPECT_EQ(DownloadItem::INTERRUPTED, download->GetState()); |
| 708 } | 706 } |
| 709 | 707 |
| 710 // Confirm file status expected for the given location in a stream | 708 // Confirm file status expected for the given location in a stream |
| 711 // provided by the resume test server. | 709 // provided by the resume test server. |
| 712 void ConfirmFileStatusForResume( | 710 void ConfirmFileStatusForResume( |
| 713 DownloadItem* download, bool file_exists, | 711 DownloadItem* download, bool file_exists, |
| 714 int received_bytes, int total_bytes, | 712 int received_bytes, int total_bytes, |
| 715 const base::FilePath& expected_filename) { | 713 const base::FilePath& expected_filename) { |
| (...skipping 349 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1065 EXPECT_CALL(observer, OnDownloadDestroyed(items[0])); | 1063 EXPECT_CALL(observer, OnDownloadDestroyed(items[0])); |
| 1066 | 1064 |
| 1067 // Shutdown the download manager. Mostly this is confirming a lack of | 1065 // Shutdown the download manager. Mostly this is confirming a lack of |
| 1068 // crashes. | 1066 // crashes. |
| 1069 DownloadManagerForShell(shell())->Shutdown(); | 1067 DownloadManagerForShell(shell())->Shutdown(); |
| 1070 } | 1068 } |
| 1071 | 1069 |
| 1072 IN_PROC_BROWSER_TEST_F(DownloadContentTest, ResumeInterruptedDownload) { | 1070 IN_PROC_BROWSER_TEST_F(DownloadContentTest, ResumeInterruptedDownload) { |
| 1073 base::CommandLine::ForCurrentProcess()->AppendSwitch( | 1071 base::CommandLine::ForCurrentProcess()->AppendSwitch( |
| 1074 switches::kEnableDownloadResumption); | 1072 switches::kEnableDownloadResumption); |
| 1075 ASSERT_TRUE(test_server()->Start()); | 1073 ASSERT_TRUE(spawned_test_server()->Start()); |
| 1076 | 1074 |
| 1077 GURL url = test_server()->GetURL( | 1075 GURL url = spawned_test_server()->GetURL( |
| 1078 base::StringPrintf("rangereset?size=%d&rst_boundary=%d", | 1076 base::StringPrintf("rangereset?size=%d&rst_boundary=%d", |
| 1079 GetSafeBufferChunk() * 3, GetSafeBufferChunk())); | 1077 GetSafeBufferChunk() * 3, GetSafeBufferChunk())); |
| 1080 | 1078 |
| 1081 MockDownloadManagerObserver dm_observer(DownloadManagerForShell(shell())); | 1079 MockDownloadManagerObserver dm_observer(DownloadManagerForShell(shell())); |
| 1082 EXPECT_CALL(dm_observer, OnDownloadCreated(_,_)).Times(1); | 1080 EXPECT_CALL(dm_observer, OnDownloadCreated(_,_)).Times(1); |
| 1083 | 1081 |
| 1084 DownloadItem* download(StartDownloadAndReturnItem(url)); | 1082 DownloadItem* download(StartDownloadAndReturnItem(url)); |
| 1085 WaitForData(download, GetSafeBufferChunk()); | 1083 WaitForData(download, GetSafeBufferChunk()); |
| 1086 ::testing::Mock::VerifyAndClearExpectations(&dm_observer); | 1084 ::testing::Mock::VerifyAndClearExpectations(&dm_observer); |
| 1087 | 1085 |
| 1088 // Confirm resumption while in progress doesn't do anything. | 1086 // Confirm resumption while in progress doesn't do anything. |
| 1089 download->Resume(); | 1087 download->Resume(); |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1132 ASSERT_EQ(DownloadItem::COMPLETE, download->GetState()); | 1130 ASSERT_EQ(DownloadItem::COMPLETE, download->GetState()); |
| 1133 RunAllPendingInMessageLoop(); | 1131 RunAllPendingInMessageLoop(); |
| 1134 ASSERT_EQ(GetSafeBufferChunk() * 3, download->GetReceivedBytes()); | 1132 ASSERT_EQ(GetSafeBufferChunk() * 3, download->GetReceivedBytes()); |
| 1135 ASSERT_EQ(DownloadItem::COMPLETE, download->GetState()); | 1133 ASSERT_EQ(DownloadItem::COMPLETE, download->GetState()); |
| 1136 } | 1134 } |
| 1137 | 1135 |
| 1138 // Confirm restart fallback happens if a range request is bounced. | 1136 // Confirm restart fallback happens if a range request is bounced. |
| 1139 IN_PROC_BROWSER_TEST_F(DownloadContentTest, ResumeInterruptedDownloadNoRange) { | 1137 IN_PROC_BROWSER_TEST_F(DownloadContentTest, ResumeInterruptedDownloadNoRange) { |
| 1140 base::CommandLine::ForCurrentProcess()->AppendSwitch( | 1138 base::CommandLine::ForCurrentProcess()->AppendSwitch( |
| 1141 switches::kEnableDownloadResumption); | 1139 switches::kEnableDownloadResumption); |
| 1142 ASSERT_TRUE(test_server()->Start()); | 1140 ASSERT_TRUE(spawned_test_server()->Start()); |
| 1143 | 1141 |
| 1144 // Auto-restart if server doesn't handle ranges. | 1142 // Auto-restart if server doesn't handle ranges. |
| 1145 GURL url = test_server()->GetURL( | 1143 GURL url = spawned_test_server()->GetURL(base::StringPrintf( |
| 1146 base::StringPrintf( | 1144 // First download hits an RST, rest don't, no ranges. |
| 1147 // First download hits an RST, rest don't, no ranges. | 1145 "rangereset?size=%d&rst_boundary=%d&" |
| 1148 "rangereset?size=%d&rst_boundary=%d&" | 1146 "token=NoRange&rst_limit=1&bounce_range", |
| 1149 "token=NoRange&rst_limit=1&bounce_range", | 1147 GetSafeBufferChunk() * 3, GetSafeBufferChunk())); |
| 1150 GetSafeBufferChunk() * 3, GetSafeBufferChunk())); | |
| 1151 | 1148 |
| 1152 // Start the download and wait for first data chunk. | 1149 // Start the download and wait for first data chunk. |
| 1153 DownloadItem* download(StartDownloadAndReturnItem(url)); | 1150 DownloadItem* download(StartDownloadAndReturnItem(url)); |
| 1154 WaitForData(download, GetSafeBufferChunk()); | 1151 WaitForData(download, GetSafeBufferChunk()); |
| 1155 | 1152 |
| 1156 RecordingDownloadObserver recorder(download); | 1153 RecordingDownloadObserver recorder(download); |
| 1157 | 1154 |
| 1158 ReleaseRSTAndConfirmInterruptForResume(download); | 1155 ReleaseRSTAndConfirmInterruptForResume(download); |
| 1159 ConfirmFileStatusForResume( | 1156 ConfirmFileStatusForResume( |
| 1160 download, true, GetSafeBufferChunk(), GetSafeBufferChunk() * 3, | 1157 download, true, GetSafeBufferChunk(), GetSafeBufferChunk() * 3, |
| (...skipping 20 matching lines...) Expand all Loading... | |
| 1181 }; | 1178 }; |
| 1182 | 1179 |
| 1183 recorder.CompareToExpectedRecord(expected_record, arraysize(expected_record)); | 1180 recorder.CompareToExpectedRecord(expected_record, arraysize(expected_record)); |
| 1184 } | 1181 } |
| 1185 | 1182 |
| 1186 // Confirm restart fallback happens if a precondition is failed. | 1183 // Confirm restart fallback happens if a precondition is failed. |
| 1187 IN_PROC_BROWSER_TEST_F(DownloadContentTest, | 1184 IN_PROC_BROWSER_TEST_F(DownloadContentTest, |
| 1188 ResumeInterruptedDownloadBadPrecondition) { | 1185 ResumeInterruptedDownloadBadPrecondition) { |
| 1189 base::CommandLine::ForCurrentProcess()->AppendSwitch( | 1186 base::CommandLine::ForCurrentProcess()->AppendSwitch( |
| 1190 switches::kEnableDownloadResumption); | 1187 switches::kEnableDownloadResumption); |
| 1191 ASSERT_TRUE(test_server()->Start()); | 1188 ASSERT_TRUE(spawned_test_server()->Start()); |
| 1192 | 1189 |
| 1193 GURL url = test_server()->GetURL(base::StringPrintf( | 1190 GURL url = spawned_test_server()->GetURL(base::StringPrintf( |
| 1194 // First download hits an RST, rest don't, precondition fail. | 1191 // First download hits an RST, rest don't, precondition fail. |
| 1195 "rangereset?size=%d&rst_boundary=%d&" | 1192 "rangereset?size=%d&rst_boundary=%d&" |
| 1196 "token=BadPrecondition&rst_limit=1&fail_precondition=2", | 1193 "token=BadPrecondition&rst_limit=1&fail_precondition=2", |
| 1197 GetSafeBufferChunk() * 3, | 1194 GetSafeBufferChunk() * 3, GetSafeBufferChunk())); |
| 1198 GetSafeBufferChunk())); | |
| 1199 | 1195 |
| 1200 // Start the download and wait for first data chunk. | 1196 // Start the download and wait for first data chunk. |
| 1201 DownloadItem* download(StartDownloadAndReturnItem(url)); | 1197 DownloadItem* download(StartDownloadAndReturnItem(url)); |
| 1202 WaitForData(download, GetSafeBufferChunk()); | 1198 WaitForData(download, GetSafeBufferChunk()); |
| 1203 | 1199 |
| 1204 RecordingDownloadObserver recorder(download); | 1200 RecordingDownloadObserver recorder(download); |
| 1205 | 1201 |
| 1206 ReleaseRSTAndConfirmInterruptForResume(download); | 1202 ReleaseRSTAndConfirmInterruptForResume(download); |
| 1207 ConfirmFileStatusForResume( | 1203 ConfirmFileStatusForResume( |
| 1208 download, true, GetSafeBufferChunk(), GetSafeBufferChunk() * 3, | 1204 download, true, GetSafeBufferChunk(), GetSafeBufferChunk() * 3, |
| (...skipping 24 matching lines...) Expand all Loading... | |
| 1233 }; | 1229 }; |
| 1234 | 1230 |
| 1235 recorder.CompareToExpectedRecord(expected_record, arraysize(expected_record)); | 1231 recorder.CompareToExpectedRecord(expected_record, arraysize(expected_record)); |
| 1236 } | 1232 } |
| 1237 | 1233 |
| 1238 // Confirm we don't try to resume if we don't have a verifier. | 1234 // Confirm we don't try to resume if we don't have a verifier. |
| 1239 IN_PROC_BROWSER_TEST_F(DownloadContentTest, | 1235 IN_PROC_BROWSER_TEST_F(DownloadContentTest, |
| 1240 ResumeInterruptedDownloadNoVerifiers) { | 1236 ResumeInterruptedDownloadNoVerifiers) { |
| 1241 base::CommandLine::ForCurrentProcess()->AppendSwitch( | 1237 base::CommandLine::ForCurrentProcess()->AppendSwitch( |
| 1242 switches::kEnableDownloadResumption); | 1238 switches::kEnableDownloadResumption); |
| 1243 ASSERT_TRUE(test_server()->Start()); | 1239 ASSERT_TRUE(spawned_test_server()->Start()); |
| 1244 | 1240 |
| 1245 GURL url = test_server()->GetURL( | 1241 GURL url = spawned_test_server()->GetURL(base::StringPrintf( |
| 1246 base::StringPrintf( | 1242 // First download hits an RST, rest don't, no verifiers. |
| 1247 // First download hits an RST, rest don't, no verifiers. | 1243 "rangereset?size=%d&rst_boundary=%d&" |
| 1248 "rangereset?size=%d&rst_boundary=%d&" | 1244 "token=NoRange&rst_limit=1&no_verifiers", |
| 1249 "token=NoRange&rst_limit=1&no_verifiers", | 1245 GetSafeBufferChunk() * 3, GetSafeBufferChunk())); |
| 1250 GetSafeBufferChunk() * 3, GetSafeBufferChunk())); | |
| 1251 | 1246 |
| 1252 // Start the download and wait for first data chunk. | 1247 // Start the download and wait for first data chunk. |
| 1253 DownloadItem* download(StartDownloadAndReturnItem(url)); | 1248 DownloadItem* download(StartDownloadAndReturnItem(url)); |
| 1254 WaitForData(download, GetSafeBufferChunk()); | 1249 WaitForData(download, GetSafeBufferChunk()); |
| 1255 | 1250 |
| 1256 RecordingDownloadObserver recorder(download); | 1251 RecordingDownloadObserver recorder(download); |
| 1257 | 1252 |
| 1258 ReleaseRSTAndConfirmInterruptForResume(download); | 1253 ReleaseRSTAndConfirmInterruptForResume(download); |
| 1259 ConfirmFileStatusForResume( | 1254 ConfirmFileStatusForResume( |
| 1260 download, false, GetSafeBufferChunk(), GetSafeBufferChunk() * 3, | 1255 download, false, GetSafeBufferChunk(), GetSafeBufferChunk() * 3, |
| (...skipping 16 matching lines...) Expand all Loading... | |
| 1277 // Completion. | 1272 // Completion. |
| 1278 {DownloadItem::COMPLETE, GetSafeBufferChunk() * 3}, | 1273 {DownloadItem::COMPLETE, GetSafeBufferChunk() * 3}, |
| 1279 }; | 1274 }; |
| 1280 | 1275 |
| 1281 recorder.CompareToExpectedRecord(expected_record, arraysize(expected_record)); | 1276 recorder.CompareToExpectedRecord(expected_record, arraysize(expected_record)); |
| 1282 } | 1277 } |
| 1283 | 1278 |
| 1284 IN_PROC_BROWSER_TEST_F(DownloadContentTest, ResumeWithDeletedFile) { | 1279 IN_PROC_BROWSER_TEST_F(DownloadContentTest, ResumeWithDeletedFile) { |
| 1285 base::CommandLine::ForCurrentProcess()->AppendSwitch( | 1280 base::CommandLine::ForCurrentProcess()->AppendSwitch( |
| 1286 switches::kEnableDownloadResumption); | 1281 switches::kEnableDownloadResumption); |
| 1287 ASSERT_TRUE(test_server()->Start()); | 1282 ASSERT_TRUE(spawned_test_server()->Start()); |
| 1288 | 1283 |
| 1289 GURL url = test_server()->GetURL( | 1284 GURL url = spawned_test_server()->GetURL(base::StringPrintf( |
| 1290 base::StringPrintf( | 1285 // First download hits an RST, rest don't |
| 1291 // First download hits an RST, rest don't | 1286 "rangereset?size=%d&rst_boundary=%d&" |
| 1292 "rangereset?size=%d&rst_boundary=%d&" | 1287 "token=NoRange&rst_limit=1", |
| 1293 "token=NoRange&rst_limit=1", | 1288 GetSafeBufferChunk() * 3, GetSafeBufferChunk())); |
| 1294 GetSafeBufferChunk() * 3, GetSafeBufferChunk())); | |
| 1295 | 1289 |
| 1296 // Start the download and wait for first data chunk. | 1290 // Start the download and wait for first data chunk. |
| 1297 DownloadItem* download(StartDownloadAndReturnItem(url)); | 1291 DownloadItem* download(StartDownloadAndReturnItem(url)); |
| 1298 WaitForData(download, GetSafeBufferChunk()); | 1292 WaitForData(download, GetSafeBufferChunk()); |
| 1299 | 1293 |
| 1300 RecordingDownloadObserver recorder(download); | 1294 RecordingDownloadObserver recorder(download); |
| 1301 | 1295 |
| 1302 ReleaseRSTAndConfirmInterruptForResume(download); | 1296 ReleaseRSTAndConfirmInterruptForResume(download); |
| 1303 ConfirmFileStatusForResume( | 1297 ConfirmFileStatusForResume( |
| 1304 download, true, GetSafeBufferChunk(), GetSafeBufferChunk() * 3, | 1298 download, true, GetSafeBufferChunk(), GetSafeBufferChunk() * 3, |
| (...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1481 download->Resume(); | 1475 download->Resume(); |
| 1482 completion_observer.WaitForEvent(); | 1476 completion_observer.WaitForEvent(); |
| 1483 EXPECT_EQ(download->GetState(), DownloadItem::COMPLETE); | 1477 EXPECT_EQ(download->GetState(), DownloadItem::COMPLETE); |
| 1484 } | 1478 } |
| 1485 | 1479 |
| 1486 // An interrupted download should remove the intermediate file when it is | 1480 // An interrupted download should remove the intermediate file when it is |
| 1487 // cancelled. | 1481 // cancelled. |
| 1488 IN_PROC_BROWSER_TEST_F(DownloadContentTest, CancelInterruptedDownload) { | 1482 IN_PROC_BROWSER_TEST_F(DownloadContentTest, CancelInterruptedDownload) { |
| 1489 base::CommandLine::ForCurrentProcess()->AppendSwitch( | 1483 base::CommandLine::ForCurrentProcess()->AppendSwitch( |
| 1490 switches::kEnableDownloadResumption); | 1484 switches::kEnableDownloadResumption); |
| 1491 ASSERT_TRUE(test_server()->Start()); | 1485 ASSERT_TRUE(spawned_test_server()->Start()); |
| 1492 | 1486 |
| 1493 GURL url1 = test_server()->GetURL( | 1487 GURL url1 = spawned_test_server()->GetURL( |
| 1494 base::StringPrintf("rangereset?size=%d&rst_boundary=%d", | 1488 base::StringPrintf("rangereset?size=%d&rst_boundary=%d", |
| 1495 GetSafeBufferChunk() * 3, GetSafeBufferChunk())); | 1489 GetSafeBufferChunk() * 3, GetSafeBufferChunk())); |
| 1496 | 1490 |
| 1497 DownloadItem* download(StartDownloadAndReturnItem(url1)); | 1491 DownloadItem* download(StartDownloadAndReturnItem(url1)); |
| 1498 WaitForData(download, GetSafeBufferChunk()); | 1492 WaitForData(download, GetSafeBufferChunk()); |
| 1499 | 1493 |
| 1500 ReleaseRSTAndConfirmInterruptForResume(download); | 1494 ReleaseRSTAndConfirmInterruptForResume(download); |
| 1501 ConfirmFileStatusForResume( | 1495 ConfirmFileStatusForResume( |
| 1502 download, true, GetSafeBufferChunk(), GetSafeBufferChunk() * 3, | 1496 download, true, GetSafeBufferChunk(), GetSafeBufferChunk() * 3, |
| 1503 base::FilePath(FILE_PATH_LITERAL("rangereset.crdownload"))); | 1497 base::FilePath(FILE_PATH_LITERAL("rangereset.crdownload"))); |
| 1504 | 1498 |
| 1505 base::FilePath intermediate_path(download->GetFullPath()); | 1499 base::FilePath intermediate_path(download->GetFullPath()); |
| 1506 ASSERT_FALSE(intermediate_path.empty()); | 1500 ASSERT_FALSE(intermediate_path.empty()); |
| 1507 EXPECT_TRUE(base::PathExists(intermediate_path)); | 1501 EXPECT_TRUE(base::PathExists(intermediate_path)); |
| 1508 | 1502 |
| 1509 download->Cancel(true /* user_cancel */); | 1503 download->Cancel(true /* user_cancel */); |
| 1510 RunAllPendingInMessageLoop(BrowserThread::FILE); | 1504 RunAllPendingInMessageLoop(BrowserThread::FILE); |
| 1511 RunAllPendingInMessageLoop(); | 1505 RunAllPendingInMessageLoop(); |
| 1512 | 1506 |
| 1513 // The intermediate file should now be gone. | 1507 // The intermediate file should now be gone. |
| 1514 EXPECT_FALSE(base::PathExists(intermediate_path)); | 1508 EXPECT_FALSE(base::PathExists(intermediate_path)); |
| 1515 EXPECT_TRUE(download->GetFullPath().empty()); | 1509 EXPECT_TRUE(download->GetFullPath().empty()); |
| 1516 } | 1510 } |
| 1517 | 1511 |
| 1518 IN_PROC_BROWSER_TEST_F(DownloadContentTest, RemoveDownload) { | 1512 IN_PROC_BROWSER_TEST_F(DownloadContentTest, RemoveDownload) { |
| 1519 base::CommandLine::ForCurrentProcess()->AppendSwitch( | 1513 base::CommandLine::ForCurrentProcess()->AppendSwitch( |
| 1520 switches::kEnableDownloadResumption); | 1514 switches::kEnableDownloadResumption); |
| 1521 ASSERT_TRUE(test_server()->Start()); | 1515 ASSERT_TRUE(spawned_test_server()->Start()); |
| 1522 | 1516 |
| 1523 // An interrupted download should remove the intermediate file when it is | 1517 // An interrupted download should remove the intermediate file when it is |
| 1524 // removed. | 1518 // removed. |
| 1525 { | 1519 { |
| 1526 GURL url1 = test_server()->GetURL( | 1520 GURL url1 = spawned_test_server()->GetURL( |
| 1527 base::StringPrintf("rangereset?size=%d&rst_boundary=%d", | 1521 base::StringPrintf("rangereset?size=%d&rst_boundary=%d", |
| 1528 GetSafeBufferChunk() * 3, GetSafeBufferChunk())); | 1522 GetSafeBufferChunk() * 3, GetSafeBufferChunk())); |
| 1529 | 1523 |
| 1530 DownloadItem* download(StartDownloadAndReturnItem(url1)); | 1524 DownloadItem* download(StartDownloadAndReturnItem(url1)); |
| 1531 WaitForData(download, GetSafeBufferChunk()); | 1525 WaitForData(download, GetSafeBufferChunk()); |
| 1532 ReleaseRSTAndConfirmInterruptForResume(download); | 1526 ReleaseRSTAndConfirmInterruptForResume(download); |
| 1533 ConfirmFileStatusForResume( | 1527 ConfirmFileStatusForResume( |
| 1534 download, true, GetSafeBufferChunk(), GetSafeBufferChunk() * 3, | 1528 download, true, GetSafeBufferChunk(), GetSafeBufferChunk() * 3, |
| 1535 base::FilePath(FILE_PATH_LITERAL("rangereset.crdownload"))); | 1529 base::FilePath(FILE_PATH_LITERAL("rangereset.crdownload"))); |
| 1536 | 1530 |
| (...skipping 28 matching lines...) Expand all Loading... | |
| 1565 | 1559 |
| 1566 // The file should still exist. | 1560 // The file should still exist. |
| 1567 EXPECT_TRUE(base::PathExists(target_path)); | 1561 EXPECT_TRUE(base::PathExists(target_path)); |
| 1568 } | 1562 } |
| 1569 } | 1563 } |
| 1570 | 1564 |
| 1571 IN_PROC_BROWSER_TEST_F(DownloadContentTest, RemoveResumingDownload) { | 1565 IN_PROC_BROWSER_TEST_F(DownloadContentTest, RemoveResumingDownload) { |
| 1572 SetupEnsureNoPendingDownloads(); | 1566 SetupEnsureNoPendingDownloads(); |
| 1573 base::CommandLine::ForCurrentProcess()->AppendSwitch( | 1567 base::CommandLine::ForCurrentProcess()->AppendSwitch( |
| 1574 switches::kEnableDownloadResumption); | 1568 switches::kEnableDownloadResumption); |
| 1575 ASSERT_TRUE(test_server()->Start()); | 1569 ASSERT_TRUE(spawned_test_server()->Start()); |
| 1576 | 1570 |
| 1577 GURL url = test_server()->GetURL( | 1571 GURL url = spawned_test_server()->GetURL( |
| 1578 base::StringPrintf("rangereset?size=%d&rst_boundary=%d", | 1572 base::StringPrintf("rangereset?size=%d&rst_boundary=%d", |
| 1579 GetSafeBufferChunk() * 3, GetSafeBufferChunk())); | 1573 GetSafeBufferChunk() * 3, GetSafeBufferChunk())); |
| 1580 | 1574 |
| 1581 MockDownloadManagerObserver dm_observer(DownloadManagerForShell(shell())); | 1575 MockDownloadManagerObserver dm_observer(DownloadManagerForShell(shell())); |
| 1582 EXPECT_CALL(dm_observer, OnDownloadCreated(_,_)).Times(1); | 1576 EXPECT_CALL(dm_observer, OnDownloadCreated(_,_)).Times(1); |
| 1583 | 1577 |
| 1584 DownloadItem* download(StartDownloadAndReturnItem(url)); | 1578 DownloadItem* download(StartDownloadAndReturnItem(url)); |
| 1585 WaitForData(download, GetSafeBufferChunk()); | 1579 WaitForData(download, GetSafeBufferChunk()); |
| 1586 ::testing::Mock::VerifyAndClearExpectations(&dm_observer); | 1580 ::testing::Mock::VerifyAndClearExpectations(&dm_observer); |
| 1587 | 1581 |
| (...skipping 14 matching lines...) Expand all Loading... | |
| 1602 download->Remove(); | 1596 download->Remove(); |
| 1603 | 1597 |
| 1604 // The intermediate file should now be gone. | 1598 // The intermediate file should now be gone. |
| 1605 RunAllPendingInMessageLoop(BrowserThread::FILE); | 1599 RunAllPendingInMessageLoop(BrowserThread::FILE); |
| 1606 RunAllPendingInMessageLoop(); | 1600 RunAllPendingInMessageLoop(); |
| 1607 EXPECT_FALSE(base::PathExists(intermediate_path)); | 1601 EXPECT_FALSE(base::PathExists(intermediate_path)); |
| 1608 | 1602 |
| 1609 // Start the second download and wait until it's done. The test server is | 1603 // Start the second download and wait until it's done. The test server is |
| 1610 // single threaded. The response to this download request should follow the | 1604 // single threaded. The response to this download request should follow the |
| 1611 // response to the previous resumption request. | 1605 // response to the previous resumption request. |
| 1612 GURL url2(test_server()->GetURL("rangereset?size=100&rst_limit=0&token=x")); | 1606 GURL url2( |
| 1607 spawned_test_server()->GetURL("rangereset?size=100&rst_limit=0&token=x")); | |
| 1613 NavigateToURLAndWaitForDownload(shell(), url2, DownloadItem::COMPLETE); | 1608 NavigateToURLAndWaitForDownload(shell(), url2, DownloadItem::COMPLETE); |
| 1614 | 1609 |
| 1615 EXPECT_TRUE(EnsureNoPendingDownloads()); | 1610 EXPECT_TRUE(EnsureNoPendingDownloads()); |
| 1616 } | 1611 } |
| 1617 | 1612 |
| 1618 IN_PROC_BROWSER_TEST_F(DownloadContentTest, CancelResumingDownload) { | 1613 IN_PROC_BROWSER_TEST_F(DownloadContentTest, CancelResumingDownload) { |
| 1619 SetupEnsureNoPendingDownloads(); | 1614 SetupEnsureNoPendingDownloads(); |
| 1620 base::CommandLine::ForCurrentProcess()->AppendSwitch( | 1615 base::CommandLine::ForCurrentProcess()->AppendSwitch( |
| 1621 switches::kEnableDownloadResumption); | 1616 switches::kEnableDownloadResumption); |
| 1622 ASSERT_TRUE(test_server()->Start()); | 1617 ASSERT_TRUE(spawned_test_server()->Start()); |
| 1623 | 1618 |
| 1624 GURL url = test_server()->GetURL( | 1619 GURL url = spawned_test_server()->GetURL( |
| 1625 base::StringPrintf("rangereset?size=%d&rst_boundary=%d", | 1620 base::StringPrintf("rangereset?size=%d&rst_boundary=%d", |
| 1626 GetSafeBufferChunk() * 3, GetSafeBufferChunk())); | 1621 GetSafeBufferChunk() * 3, GetSafeBufferChunk())); |
| 1627 | 1622 |
| 1628 MockDownloadManagerObserver dm_observer(DownloadManagerForShell(shell())); | 1623 MockDownloadManagerObserver dm_observer(DownloadManagerForShell(shell())); |
| 1629 EXPECT_CALL(dm_observer, OnDownloadCreated(_,_)).Times(1); | 1624 EXPECT_CALL(dm_observer, OnDownloadCreated(_,_)).Times(1); |
| 1630 | 1625 |
| 1631 DownloadItem* download(StartDownloadAndReturnItem(url)); | 1626 DownloadItem* download(StartDownloadAndReturnItem(url)); |
| 1632 WaitForData(download, GetSafeBufferChunk()); | 1627 WaitForData(download, GetSafeBufferChunk()); |
| 1633 ::testing::Mock::VerifyAndClearExpectations(&dm_observer); | 1628 ::testing::Mock::VerifyAndClearExpectations(&dm_observer); |
| 1634 | 1629 |
| (...skipping 15 matching lines...) Expand all Loading... | |
| 1650 | 1645 |
| 1651 // The intermediate file should now be gone. | 1646 // The intermediate file should now be gone. |
| 1652 RunAllPendingInMessageLoop(BrowserThread::FILE); | 1647 RunAllPendingInMessageLoop(BrowserThread::FILE); |
| 1653 RunAllPendingInMessageLoop(); | 1648 RunAllPendingInMessageLoop(); |
| 1654 EXPECT_FALSE(base::PathExists(intermediate_path)); | 1649 EXPECT_FALSE(base::PathExists(intermediate_path)); |
| 1655 EXPECT_TRUE(download->GetFullPath().empty()); | 1650 EXPECT_TRUE(download->GetFullPath().empty()); |
| 1656 | 1651 |
| 1657 // Start the second download and wait until it's done. The test server is | 1652 // Start the second download and wait until it's done. The test server is |
| 1658 // single threaded. The response to this download request should follow the | 1653 // single threaded. The response to this download request should follow the |
| 1659 // response to the previous resumption request. | 1654 // response to the previous resumption request. |
| 1660 GURL url2(test_server()->GetURL("rangereset?size=100&rst_limit=0&token=x")); | 1655 GURL url2( |
| 1656 spawned_test_server()->GetURL("rangereset?size=100&rst_limit=0&token=x")); | |
| 1661 NavigateToURLAndWaitForDownload(shell(), url2, DownloadItem::COMPLETE); | 1657 NavigateToURLAndWaitForDownload(shell(), url2, DownloadItem::COMPLETE); |
| 1662 | 1658 |
| 1663 EXPECT_TRUE(EnsureNoPendingDownloads()); | 1659 EXPECT_TRUE(EnsureNoPendingDownloads()); |
| 1664 } | 1660 } |
| 1665 | 1661 |
| 1666 // Check that the cookie policy is correctly updated when downloading a file | 1662 // Check that the cookie policy is correctly updated when downloading a file |
| 1667 // that redirects cross origin. | 1663 // that redirects cross origin. |
| 1668 IN_PROC_BROWSER_TEST_F(DownloadContentTest, CookiePolicy) { | 1664 IN_PROC_BROWSER_TEST_F(DownloadContentTest, CookiePolicy) { |
| 1669 ASSERT_TRUE(test_server()->Start()); | 1665 ASSERT_TRUE(spawned_test_server()->Start()); |
| 1670 net::HostPortPair host_port = test_server()->host_port_pair(); | 1666 net::HostPortPair host_port = spawned_test_server()->host_port_pair(); |
| 1671 DCHECK_EQ(host_port.host(), std::string("127.0.0.1")); | 1667 DCHECK_EQ(host_port.host(), std::string("127.0.0.1")); |
| 1672 | 1668 |
| 1673 // Block third-party cookies. | 1669 // Block third-party cookies. |
| 1674 ShellNetworkDelegate::SetAcceptAllCookies(false); | 1670 ShellNetworkDelegate::SetAcceptAllCookies(false); |
| 1675 | 1671 |
| 1676 // |url| redirects to a different origin |download| which tries to set a | 1672 // |url| redirects to a different origin |download| which tries to set a |
| 1677 // cookie. | 1673 // cookie. |
| 1678 std::string download(base::StringPrintf( | 1674 std::string download(base::StringPrintf( |
| 1679 "http://localhost:%d/set-cookie?A=B", host_port.port())); | 1675 "http://localhost:%d/set-cookie?A=B", host_port.port())); |
| 1680 GURL url(test_server()->GetURL("server-redirect?" + download)); | 1676 GURL url(spawned_test_server()->GetURL("server-redirect?" + download)); |
| 1681 | 1677 |
| 1682 // Download the file. | 1678 // Download the file. |
| 1683 SetupEnsureNoPendingDownloads(); | 1679 SetupEnsureNoPendingDownloads(); |
| 1684 scoped_ptr<DownloadUrlParameters> dl_params( | 1680 scoped_ptr<DownloadUrlParameters> dl_params( |
| 1685 DownloadUrlParameters::FromWebContents(shell()->web_contents(), url)); | 1681 DownloadUrlParameters::FromWebContents(shell()->web_contents(), url)); |
| 1686 scoped_ptr<DownloadTestObserver> observer(CreateWaiter(shell(), 1)); | 1682 scoped_ptr<DownloadTestObserver> observer(CreateWaiter(shell(), 1)); |
| 1687 DownloadManagerForShell(shell())->DownloadUrl(dl_params.Pass()); | 1683 DownloadManagerForShell(shell())->DownloadUrl(dl_params.Pass()); |
| 1688 observer->WaitForFinished(); | 1684 observer->WaitForFinished(); |
| 1689 | 1685 |
| 1690 // Get the important info from other threads and check it. | 1686 // Get the important info from other threads and check it. |
| 1691 EXPECT_TRUE(EnsureNoPendingDownloads()); | 1687 EXPECT_TRUE(EnsureNoPendingDownloads()); |
| 1692 | 1688 |
| 1693 std::vector<DownloadItem*> downloads; | 1689 std::vector<DownloadItem*> downloads; |
| 1694 DownloadManagerForShell(shell())->GetAllDownloads(&downloads); | 1690 DownloadManagerForShell(shell())->GetAllDownloads(&downloads); |
| 1695 ASSERT_EQ(1u, downloads.size()); | 1691 ASSERT_EQ(1u, downloads.size()); |
| 1696 ASSERT_EQ(DownloadItem::COMPLETE, downloads[0]->GetState()); | 1692 ASSERT_EQ(DownloadItem::COMPLETE, downloads[0]->GetState()); |
| 1697 | 1693 |
| 1698 // Check that the cookies were correctly set. | 1694 // Check that the cookies were correctly set. |
| 1699 EXPECT_EQ("A=B", | 1695 EXPECT_EQ("A=B", |
| 1700 content::GetCookies(shell()->web_contents()->GetBrowserContext(), | 1696 content::GetCookies(shell()->web_contents()->GetBrowserContext(), |
| 1701 GURL(download))); | 1697 GURL(download))); |
| 1702 } | 1698 } |
| 1703 | 1699 |
| 1704 // A filename suggestion specified via a @download attribute should not be | 1700 // A filename suggestion specified via a @download attribute should not be |
| 1705 // effective if the final download URL is in another origin from the original | 1701 // effective if the final download URL is in another origin from the original |
| 1706 // download URL. | 1702 // download URL. |
| 1707 IN_PROC_BROWSER_TEST_F(DownloadContentTest, | 1703 IN_PROC_BROWSER_TEST_F(DownloadContentTest, |
| 1708 DownloadAttributeCrossOriginRedirect) { | 1704 DownloadAttributeCrossOriginRedirect) { |
| 1709 EmbeddedTestServer origin_one; | 1705 net::EmbeddedTestServer origin_one; |
| 1710 EmbeddedTestServer origin_two; | 1706 net::EmbeddedTestServer origin_two; |
| 1711 ASSERT_TRUE(origin_one.InitializeAndWaitUntilReady()); | 1707 ASSERT_TRUE(origin_one.Start()); |
| 1712 ASSERT_TRUE(origin_two.InitializeAndWaitUntilReady()); | 1708 ASSERT_TRUE(origin_two.Start()); |
| 1713 | 1709 |
| 1714 // The download-attribute.html page contains an anchor element whose href is | 1710 // The download-attribute.html page contains an anchor element whose href is |
| 1715 // set to the value of the query parameter (specified as |target| in the URL | 1711 // set to the value of the query parameter (specified as |target| in the URL |
| 1716 // below). The suggested filename for the anchor is 'suggested-filename'. When | 1712 // below). The suggested filename for the anchor is 'suggested-filename'. When |
| 1717 // the page is loaded, a script simulates a click on the anchor, triggering a | 1713 // the page is loaded, a script simulates a click on the anchor, triggering a |
| 1718 // download of the target URL. | 1714 // download of the target URL. |
| 1719 // | 1715 // |
| 1720 // We construct two test servers; origin_one and origin_two. Once started, the | 1716 // We construct two test servers; origin_one and origin_two. Once started, the |
| 1721 // server URLs will differ by the port number. Therefore they will be in | 1717 // server URLs will differ by the port number. Therefore they will be in |
| 1722 // different origins. | 1718 // different origins. |
| (...skipping 21 matching lines...) Expand all Loading... | |
| 1744 ASSERT_TRUE(origin_one.ShutdownAndWaitUntilComplete()); | 1740 ASSERT_TRUE(origin_one.ShutdownAndWaitUntilComplete()); |
| 1745 ASSERT_TRUE(origin_two.ShutdownAndWaitUntilComplete()); | 1741 ASSERT_TRUE(origin_two.ShutdownAndWaitUntilComplete()); |
| 1746 } | 1742 } |
| 1747 | 1743 |
| 1748 // A filename suggestion specified via a @download attribute should be effective | 1744 // A filename suggestion specified via a @download attribute should be effective |
| 1749 // if the final download URL is in the same origin as the initial download URL. | 1745 // if the final download URL is in the same origin as the initial download URL. |
| 1750 // Test that this holds even if there are cross origin redirects in the middle | 1746 // Test that this holds even if there are cross origin redirects in the middle |
| 1751 // of the redirect chain. | 1747 // of the redirect chain. |
| 1752 IN_PROC_BROWSER_TEST_F(DownloadContentTest, | 1748 IN_PROC_BROWSER_TEST_F(DownloadContentTest, |
| 1753 DownloadAttributeSameOriginRedirect) { | 1749 DownloadAttributeSameOriginRedirect) { |
| 1754 EmbeddedTestServer origin_one; | 1750 net::EmbeddedTestServer origin_one; |
| 1755 EmbeddedTestServer origin_two; | 1751 net::EmbeddedTestServer origin_two; |
| 1756 ASSERT_TRUE(origin_one.InitializeAndWaitUntilReady()); | 1752 ASSERT_TRUE(origin_one.Start()); |
| 1757 ASSERT_TRUE(origin_two.InitializeAndWaitUntilReady()); | 1753 ASSERT_TRUE(origin_two.Start()); |
| 1758 | 1754 |
| 1759 // The download-attribute.html page contains an anchor element whose href is | 1755 // The download-attribute.html page contains an anchor element whose href is |
| 1760 // set to the value of the query parameter (specified as |target| in the URL | 1756 // set to the value of the query parameter (specified as |target| in the URL |
| 1761 // below). The suggested filename for the anchor is 'suggested-filename'. When | 1757 // below). The suggested filename for the anchor is 'suggested-filename'. When |
| 1762 // the page is loaded, a script simulates a click on the anchor, triggering a | 1758 // the page is loaded, a script simulates a click on the anchor, triggering a |
| 1763 // download of the target URL. | 1759 // download of the target URL. |
| 1764 // | 1760 // |
| 1765 // We construct two test servers; origin_one and origin_two. Once started, the | 1761 // We construct two test servers; origin_one and origin_two. Once started, the |
| 1766 // server URLs will differ by the port number. Therefore they will be in | 1762 // server URLs will differ by the port number. Therefore they will be in |
| 1767 // different origins. | 1763 // different origins. |
| (...skipping 22 matching lines...) Expand all Loading... | |
| 1790 EXPECT_EQ(FILE_PATH_LITERAL("suggested-filename"), | 1786 EXPECT_EQ(FILE_PATH_LITERAL("suggested-filename"), |
| 1791 downloads[0]->GetTargetFilePath().BaseName().value()); | 1787 downloads[0]->GetTargetFilePath().BaseName().value()); |
| 1792 ASSERT_TRUE(origin_one.ShutdownAndWaitUntilComplete()); | 1788 ASSERT_TRUE(origin_one.ShutdownAndWaitUntilComplete()); |
| 1793 ASSERT_TRUE(origin_two.ShutdownAndWaitUntilComplete()); | 1789 ASSERT_TRUE(origin_two.ShutdownAndWaitUntilComplete()); |
| 1794 } | 1790 } |
| 1795 | 1791 |
| 1796 // The file empty.bin is served with a MIME type of application/octet-stream. | 1792 // The file empty.bin is served with a MIME type of application/octet-stream. |
| 1797 // The content body is empty. Make sure this case is handled properly and we | 1793 // The content body is empty. Make sure this case is handled properly and we |
| 1798 // don't regress on http://crbug.com/320394. | 1794 // don't regress on http://crbug.com/320394. |
| 1799 IN_PROC_BROWSER_TEST_F(DownloadContentTest, DownloadGZipWithNoContent) { | 1795 IN_PROC_BROWSER_TEST_F(DownloadContentTest, DownloadGZipWithNoContent) { |
| 1800 EmbeddedTestServer test_server; | 1796 net::EmbeddedTestServer test_server; |
| 1801 ASSERT_TRUE(test_server.InitializeAndWaitUntilReady()); | 1797 ASSERT_TRUE(test_server.Start()); |
| 1802 | 1798 |
| 1803 GURL url = test_server.GetURL("/empty.bin"); | 1799 GURL url = test_server.GetURL("/empty.bin"); |
| 1804 test_server.ServeFilesFromDirectory(GetTestFilePath("download", "")); | 1800 test_server.ServeFilesFromDirectory(GetTestFilePath("download", "")); |
| 1805 | 1801 |
| 1806 NavigateToURLAndWaitForDownload(shell(), url, DownloadItem::COMPLETE); | 1802 NavigateToURLAndWaitForDownload(shell(), url, DownloadItem::COMPLETE); |
| 1807 // That's it. This should work without crashing. | 1803 // That's it. This should work without crashing. |
| 1808 } | 1804 } |
| 1809 | 1805 |
| 1810 IN_PROC_BROWSER_TEST_F(DownloadContentTest, Spam) { | 1806 IN_PROC_BROWSER_TEST_F(DownloadContentTest, Spam) { |
| 1811 ASSERT_TRUE(embedded_test_server()->InitializeAndWaitUntilReady()); | 1807 ASSERT_TRUE(embedded_test_server()->Start()); |
| 1812 | 1808 |
| 1813 NavigateToURLAndWaitForDownload( | 1809 NavigateToURLAndWaitForDownload( |
| 1814 shell(), | 1810 shell(), |
| 1815 embedded_test_server()->GetURL( | 1811 embedded_test_server()->GetURL( |
| 1816 "/download/double-content-disposition.txt"), | 1812 "/download/double-content-disposition.txt"), |
| 1817 DownloadItem::COMPLETE); | 1813 DownloadItem::COMPLETE); |
| 1818 | 1814 |
| 1819 std::vector<DownloadItem*> downloads; | 1815 std::vector<DownloadItem*> downloads; |
| 1820 DownloadManagerForShell(shell())->GetAllDownloads(&downloads); | 1816 DownloadManagerForShell(shell())->GetAllDownloads(&downloads); |
| 1821 ASSERT_EQ(1u, downloads.size()); | 1817 ASSERT_EQ(1u, downloads.size()); |
| 1822 | 1818 |
| 1823 EXPECT_EQ(FILE_PATH_LITERAL("Jumboshrimp.txt"), | 1819 EXPECT_EQ(FILE_PATH_LITERAL("Jumboshrimp.txt"), |
| 1824 downloads[0]->GetTargetFilePath().BaseName().value()); | 1820 downloads[0]->GetTargetFilePath().BaseName().value()); |
| 1825 } | 1821 } |
| 1826 | 1822 |
| 1827 } // namespace content | 1823 } // namespace content |
| OLD | NEW |