| 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 <stddef.h> | 8 #include <stddef.h> |
| 9 #include <stdint.h> | 9 #include <stdint.h> |
| 10 #include <utility> | 10 #include <utility> |
| (...skipping 1053 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1064 EXPECT_EQ(parameters.etag, value); | 1064 EXPECT_EQ(parameters.etag, value); |
| 1065 | 1065 |
| 1066 ASSERT_TRUE(requests[1].request_headers.GetHeader( | 1066 ASSERT_TRUE(requests[1].request_headers.GetHeader( |
| 1067 net::HttpRequestHeaders::kRange, &value)); | 1067 net::HttpRequestHeaders::kRange, &value)); |
| 1068 EXPECT_EQ(base::StringPrintf("bytes=%" PRId64 "-", interruption.offset), | 1068 EXPECT_EQ(base::StringPrintf("bytes=%" PRId64 "-", interruption.offset), |
| 1069 value); | 1069 value); |
| 1070 } | 1070 } |
| 1071 | 1071 |
| 1072 // Resumption should only attempt to contact the final URL if the download has a | 1072 // Resumption should only attempt to contact the final URL if the download has a |
| 1073 // URL chain. | 1073 // URL chain. |
| 1074 // Fails on Win x64 GN (dbg). https://crbug.com/598360 | 1074 IN_PROC_BROWSER_TEST_F(DownloadContentTest, RedirectBeforeResume) { |
| 1075 #if defined(OS_WIN) | |
| 1076 #define MAYBE_RedirectBeforeResume DISABLED_RedirectBeforeResume | |
| 1077 #else | |
| 1078 #define MAYBE_RedirectBeforeResume RedirectBeforeResume | |
| 1079 #endif | |
| 1080 IN_PROC_BROWSER_TEST_F(DownloadContentTest, MAYBE_RedirectBeforeResume) { | |
| 1081 TestDownloadRequestHandler request_handler_1( | 1075 TestDownloadRequestHandler request_handler_1( |
| 1082 GURL("http://example.com/first-url")); | 1076 GURL("http://example.com/first-url")); |
| 1083 request_handler_1.StartServingStaticResponse( | 1077 request_handler_1.StartServingStaticResponse( |
| 1084 "HTTP/1.1 302 Redirect\r\n" | 1078 "HTTP/1.1 302 Redirect\r\n" |
| 1085 "Location: http://example.com/second-url\r\n" | 1079 "Location: http://example.com/second-url\r\n" |
| 1086 "\r\n"); | 1080 "\r\n"); |
| 1087 | 1081 |
| 1088 TestDownloadRequestHandler request_handler_2( | 1082 TestDownloadRequestHandler request_handler_2( |
| 1089 GURL("http://example.com/second-url")); | 1083 GURL("http://example.com/second-url")); |
| 1090 request_handler_2.StartServingStaticResponse( | 1084 request_handler_2.StartServingStaticResponse( |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1124 download->Resume(); | 1118 download->Resume(); |
| 1125 WaitForCompletion(download); | 1119 WaitForCompletion(download); |
| 1126 | 1120 |
| 1127 ASSERT_NO_FATAL_FAILURE(ReadAndVerifyFileContents( | 1121 ASSERT_NO_FATAL_FAILURE(ReadAndVerifyFileContents( |
| 1128 parameters.pattern_generator_seed, parameters.size, | 1122 parameters.pattern_generator_seed, parameters.size, |
| 1129 download->GetTargetFilePath())); | 1123 download->GetTargetFilePath())); |
| 1130 } | 1124 } |
| 1131 | 1125 |
| 1132 // If a resumption request results in a redirect, the response should be ignored | 1126 // If a resumption request results in a redirect, the response should be ignored |
| 1133 // and the download should be marked as interrupted again. | 1127 // and the download should be marked as interrupted again. |
| 1134 // Fails on Win x64 GN (dbg). https://crbug.com/598360 | 1128 IN_PROC_BROWSER_TEST_F(DownloadContentTest, RedirectWhileResume) { |
| 1135 #if defined(OS_WIN) | |
| 1136 #define MAYBE_RedirectWhileResume DISABLED_RedirectWhileResume | |
| 1137 #else | |
| 1138 #define MAYBE_RedirectWhileResume RedirectWhileResume | |
| 1139 #endif | |
| 1140 IN_PROC_BROWSER_TEST_F(DownloadContentTest, MAYBE_RedirectWhileResume) { | |
| 1141 TestDownloadRequestHandler request_handler( | 1129 TestDownloadRequestHandler request_handler( |
| 1142 GURL("http://example.com/first-url")); | 1130 GURL("http://example.com/first-url")); |
| 1143 TestDownloadRequestHandler::Parameters parameters = | 1131 TestDownloadRequestHandler::Parameters parameters = |
| 1144 TestDownloadRequestHandler::Parameters::WithSingleInterruption(); | 1132 TestDownloadRequestHandler::Parameters::WithSingleInterruption(); |
| 1145 ++parameters.pattern_generator_seed; | 1133 ++parameters.pattern_generator_seed; |
| 1146 request_handler.StartServing(parameters); | 1134 request_handler.StartServing(parameters); |
| 1147 | 1135 |
| 1148 // We should never send a request to the decoy. If we do, the request will | 1136 // We should never send a request to the decoy. If we do, the request will |
| 1149 // always succeed, which results in behavior that diverges from what we want, | 1137 // always succeed, which results in behavior that diverges from what we want, |
| 1150 // which is for the download to return to being interrupted. | 1138 // which is for the download to return to being interrupted. |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1192 // redirect response shows up as a response with 0 bytes transferred. | 1180 // redirect response shows up as a response with 0 bytes transferred. |
| 1193 EXPECT_GT(parameters.size, requests[0].transferred_byte_count); | 1181 EXPECT_GT(parameters.size, requests[0].transferred_byte_count); |
| 1194 EXPECT_EQ(0, requests[1].transferred_byte_count); | 1182 EXPECT_EQ(0, requests[1].transferred_byte_count); |
| 1195 EXPECT_GT(parameters.size, requests[2].transferred_byte_count); | 1183 EXPECT_GT(parameters.size, requests[2].transferred_byte_count); |
| 1196 } | 1184 } |
| 1197 | 1185 |
| 1198 // If the server response for the resumption request specifies a bad range (i.e. | 1186 // If the server response for the resumption request specifies a bad range (i.e. |
| 1199 // not the range that was requested or an invalid or missing Content-Range | 1187 // not the range that was requested or an invalid or missing Content-Range |
| 1200 // header), then the download should be marked as interrupted again without | 1188 // header), then the download should be marked as interrupted again without |
| 1201 // discarding the partial state. | 1189 // discarding the partial state. |
| 1202 // Fails on Win x64 GN (dbg). https://crbug.com/598360 | 1190 IN_PROC_BROWSER_TEST_F(DownloadContentTest, BadRangeHeader) { |
| 1203 #if defined(OS_WIN) | |
| 1204 #define MAYBE_BadRangeHeader DISABLED_BadRangeHeader | |
| 1205 #else | |
| 1206 #define MAYBE_BadRangeHeader BadRangeHeader | |
| 1207 #endif | |
| 1208 IN_PROC_BROWSER_TEST_F(DownloadContentTest, MAYBE_BadRangeHeader) { | |
| 1209 TestDownloadRequestHandler request_handler; | 1191 TestDownloadRequestHandler request_handler; |
| 1210 TestDownloadRequestHandler::Parameters parameters = | 1192 TestDownloadRequestHandler::Parameters parameters = |
| 1211 TestDownloadRequestHandler::Parameters::WithSingleInterruption(); | 1193 TestDownloadRequestHandler::Parameters::WithSingleInterruption(); |
| 1212 request_handler.StartServing(parameters); | 1194 request_handler.StartServing(parameters); |
| 1213 | 1195 |
| 1214 DownloadItem* download = | 1196 DownloadItem* download = |
| 1215 StartDownloadAndReturnItem(shell(), request_handler.url()); | 1197 StartDownloadAndReturnItem(shell(), request_handler.url()); |
| 1216 WaitForInterrupt(download); | 1198 WaitForInterrupt(download); |
| 1217 | 1199 |
| 1218 // Upon resumption, the server starts responding with a bad range header. | 1200 // Upon resumption, the server starts responding with a bad range header. |
| (...skipping 1253 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2472 | 2454 |
| 2473 std::vector<DownloadItem*> downloads; | 2455 std::vector<DownloadItem*> downloads; |
| 2474 DownloadManagerForShell(shell())->GetAllDownloads(&downloads); | 2456 DownloadManagerForShell(shell())->GetAllDownloads(&downloads); |
| 2475 ASSERT_EQ(1u, downloads.size()); | 2457 ASSERT_EQ(1u, downloads.size()); |
| 2476 | 2458 |
| 2477 EXPECT_EQ(FILE_PATH_LITERAL("Jumboshrimp.txt"), | 2459 EXPECT_EQ(FILE_PATH_LITERAL("Jumboshrimp.txt"), |
| 2478 downloads[0]->GetTargetFilePath().BaseName().value()); | 2460 downloads[0]->GetTargetFilePath().BaseName().value()); |
| 2479 } | 2461 } |
| 2480 | 2462 |
| 2481 } // namespace content | 2463 } // namespace content |
| OLD | NEW |