OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "ppapi/tests/test_url_loader.h" | 5 #include "ppapi/tests/test_url_loader.h" |
6 | 6 |
7 #include <stdio.h> | 7 #include <stdio.h> |
8 #include <string.h> | 8 #include <string.h> |
9 #include <string> | 9 #include <string> |
10 | 10 |
(...skipping 25 matching lines...) Expand all Loading... |
36 bool TestURLLoader::Init() { | 36 bool TestURLLoader::Init() { |
37 file_io_trusted_interface_ = static_cast<const PPB_FileIOTrusted_Dev*>( | 37 file_io_trusted_interface_ = static_cast<const PPB_FileIOTrusted_Dev*>( |
38 pp::Module::Get()->GetBrowserInterface(PPB_FILEIOTRUSTED_DEV_INTERFACE)); | 38 pp::Module::Get()->GetBrowserInterface(PPB_FILEIOTRUSTED_DEV_INTERFACE)); |
39 if (!file_io_trusted_interface_) { | 39 if (!file_io_trusted_interface_) { |
40 instance_->AppendError("FileIOTrusted interface not available"); | 40 instance_->AppendError("FileIOTrusted interface not available"); |
41 } | 41 } |
42 return InitTestingInterface() && EnsureRunningOverHTTP(); | 42 return InitTestingInterface() && EnsureRunningOverHTTP(); |
43 } | 43 } |
44 | 44 |
45 void TestURLLoader::RunTest() { | 45 void TestURLLoader::RunTest() { |
46 RUN_TEST(BasicGET); | 46 RUN_ASYNC_TEST(BasicGET); |
47 RUN_TEST(BasicPOST); | 47 RUN_ASYNC_TEST(BasicPOST); |
48 RUN_TEST(CompoundBodyPOST); | 48 RUN_ASYNC_TEST(CompoundBodyPOST); |
49 RUN_TEST(EmptyDataPOST); | 49 RUN_ASYNC_TEST(EmptyDataPOST); |
50 RUN_TEST(BinaryDataPOST); | 50 RUN_ASYNC_TEST(BinaryDataPOST); |
51 RUN_TEST(CustomRequestHeader); | 51 RUN_ASYNC_TEST(CustomRequestHeader); |
52 RUN_TEST(IgnoresBogusContentLength); | 52 RUN_ASYNC_TEST(IgnoresBogusContentLength); |
53 RUN_TEST(SameOriginRestriction); | 53 RUN_ASYNC_TEST(SameOriginRestriction); |
54 RUN_TEST(CrossOriginRequest); | 54 RUN_ASYNC_TEST(CrossOriginRequest); |
55 RUN_TEST(StreamToFile); | 55 RUN_ASYNC_TEST(StreamToFile); |
56 RUN_TEST(AuditURLRedirect); | 56 RUN_ASYNC_TEST(AuditURLRedirect); |
57 RUN_TEST(AbortCalls); | 57 RUN_ASYNC_TEST(AbortCalls); |
58 } | 58 } |
59 | 59 |
60 std::string TestURLLoader::ReadEntireFile(pp::FileIO_Dev* file_io, | 60 std::string TestURLLoader::ReadEntireFile(pp::FileIO_Dev* file_io, |
61 std::string* data) { | 61 std::string* data) { |
62 TestCompletionCallback callback(instance_->pp_instance()); | 62 TestCompletionCallback callback(instance_->pp_instance(), force_async_); |
63 char buf[256]; | 63 char buf[256]; |
64 int64_t offset = 0; | 64 int64_t offset = 0; |
65 | 65 |
66 for (;;) { | 66 for (;;) { |
67 int32_t rv = file_io->Read(offset, buf, sizeof(buf), callback); | 67 int32_t rv = file_io->Read(offset, buf, sizeof(buf), callback); |
| 68 if (force_async_ && rv != PP_OK_COMPLETIONPENDING) |
| 69 return ReportError("FileIO::Read force_async failed", rv); |
68 if (rv == PP_OK_COMPLETIONPENDING) | 70 if (rv == PP_OK_COMPLETIONPENDING) |
69 rv = callback.WaitForResult(); | 71 rv = callback.WaitForResult(); |
70 if (rv < 0) | 72 if (rv < 0) |
71 return ReportError("FileIO::Read", rv); | 73 return ReportError("FileIO::Read", rv); |
72 if (rv == 0) | 74 if (rv == 0) |
73 break; | 75 break; |
74 offset += rv; | 76 offset += rv; |
75 data->append(buf, rv); | 77 data->append(buf, rv); |
76 } | 78 } |
77 | 79 |
78 PASS(); | 80 PASS(); |
79 } | 81 } |
80 | 82 |
81 std::string TestURLLoader::ReadEntireResponseBody(pp::URLLoader* loader, | 83 std::string TestURLLoader::ReadEntireResponseBody(pp::URLLoader* loader, |
82 std::string* body) { | 84 std::string* body) { |
83 TestCompletionCallback callback(instance_->pp_instance()); | 85 TestCompletionCallback callback(instance_->pp_instance(), force_async_); |
84 char buf[2]; // Small so that multiple reads are needed. | 86 char buf[2]; // Small so that multiple reads are needed. |
85 | 87 |
86 for (;;) { | 88 for (;;) { |
87 int32_t rv = loader->ReadResponseBody(buf, sizeof(buf), callback); | 89 int32_t rv = loader->ReadResponseBody(buf, sizeof(buf), callback); |
| 90 if (force_async_ && rv != PP_OK_COMPLETIONPENDING) |
| 91 return ReportError("URLLoader::ReadResponseBody force_async failed", rv); |
88 if (rv == PP_OK_COMPLETIONPENDING) | 92 if (rv == PP_OK_COMPLETIONPENDING) |
89 rv = callback.WaitForResult(); | 93 rv = callback.WaitForResult(); |
90 if (rv < 0) | 94 if (rv < 0) |
91 return ReportError("URLLoader::ReadResponseBody", rv); | 95 return ReportError("URLLoader::ReadResponseBody", rv); |
92 if (rv == 0) | 96 if (rv == 0) |
93 break; | 97 break; |
94 body->append(buf, rv); | 98 body->append(buf, rv); |
95 } | 99 } |
96 | 100 |
97 PASS(); | 101 PASS(); |
98 } | 102 } |
99 | 103 |
100 std::string TestURLLoader::LoadAndCompareBody( | 104 std::string TestURLLoader::LoadAndCompareBody( |
101 const pp::URLRequestInfo& request, | 105 const pp::URLRequestInfo& request, |
102 const std::string& expected_body) { | 106 const std::string& expected_body) { |
103 TestCompletionCallback callback(instance_->pp_instance()); | 107 TestCompletionCallback callback(instance_->pp_instance(), force_async_); |
104 | 108 |
105 pp::URLLoader loader(*instance_); | 109 pp::URLLoader loader(*instance_); |
106 int32_t rv = loader.Open(request, callback); | 110 int32_t rv = loader.Open(request, callback); |
| 111 if (force_async_ && rv != PP_OK_COMPLETIONPENDING) |
| 112 return ReportError("URLLoader::Open force_async failed", rv); |
107 if (rv == PP_OK_COMPLETIONPENDING) | 113 if (rv == PP_OK_COMPLETIONPENDING) |
108 rv = callback.WaitForResult(); | 114 rv = callback.WaitForResult(); |
109 if (rv != PP_OK) | 115 if (rv != PP_OK) |
110 return ReportError("URLLoader::Open", rv); | 116 return ReportError("URLLoader::Open", rv); |
111 | 117 |
112 pp::URLResponseInfo response_info(loader.GetResponseInfo()); | 118 pp::URLResponseInfo response_info(loader.GetResponseInfo()); |
113 if (response_info.is_null()) | 119 if (response_info.is_null()) |
114 return "URLLoader::GetResponseInfo returned null"; | 120 return "URLLoader::GetResponseInfo returned null"; |
115 int32_t status_code = response_info.GetStatusCode(); | 121 int32_t status_code = response_info.GetStatusCode(); |
116 if (status_code != 200) | 122 if (status_code != 200) |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
190 std::string postdata("postdata"); | 196 std::string postdata("postdata"); |
191 request.AppendDataToBody(postdata.data(), postdata.length()); | 197 request.AppendDataToBody(postdata.data(), postdata.length()); |
192 return LoadAndCompareBody(request, postdata); | 198 return LoadAndCompareBody(request, postdata); |
193 } | 199 } |
194 | 200 |
195 std::string TestURLLoader::TestStreamToFile() { | 201 std::string TestURLLoader::TestStreamToFile() { |
196 pp::URLRequestInfo request(instance_); | 202 pp::URLRequestInfo request(instance_); |
197 request.SetURL("test_url_loader_data/hello.txt"); | 203 request.SetURL("test_url_loader_data/hello.txt"); |
198 request.SetStreamToFile(true); | 204 request.SetStreamToFile(true); |
199 | 205 |
200 TestCompletionCallback callback(instance_->pp_instance()); | 206 TestCompletionCallback callback(instance_->pp_instance(), force_async_); |
201 | 207 |
202 pp::URLLoader loader(*instance_); | 208 pp::URLLoader loader(*instance_); |
203 int32_t rv = loader.Open(request, callback); | 209 int32_t rv = loader.Open(request, callback); |
| 210 if (force_async_ && rv != PP_OK_COMPLETIONPENDING) |
| 211 return ReportError("URLLoader::Open force_async failed", rv); |
204 if (rv == PP_OK_COMPLETIONPENDING) | 212 if (rv == PP_OK_COMPLETIONPENDING) |
205 rv = callback.WaitForResult(); | 213 rv = callback.WaitForResult(); |
206 if (rv != PP_OK) | 214 if (rv != PP_OK) |
207 return ReportError("URLLoader::Open", rv); | 215 return ReportError("URLLoader::Open", rv); |
208 | 216 |
209 pp::URLResponseInfo response_info(loader.GetResponseInfo()); | 217 pp::URLResponseInfo response_info(loader.GetResponseInfo()); |
210 if (response_info.is_null()) | 218 if (response_info.is_null()) |
211 return "URLLoader::GetResponseInfo returned null"; | 219 return "URLLoader::GetResponseInfo returned null"; |
212 int32_t status_code = response_info.GetStatusCode(); | 220 int32_t status_code = response_info.GetStatusCode(); |
213 if (status_code != 200) | 221 if (status_code != 200) |
214 return "Unexpected HTTP status code"; | 222 return "Unexpected HTTP status code"; |
215 | 223 |
216 pp::FileRef_Dev body(response_info.GetBodyAsFileRef()); | 224 pp::FileRef_Dev body(response_info.GetBodyAsFileRef()); |
217 if (body.is_null()) | 225 if (body.is_null()) |
218 return "URLResponseInfo::GetBody returned null"; | 226 return "URLResponseInfo::GetBody returned null"; |
219 | 227 |
220 rv = loader.FinishStreamingToFile(callback); | 228 rv = loader.FinishStreamingToFile(callback); |
| 229 if (force_async_ && rv != PP_OK_COMPLETIONPENDING) |
| 230 return ReportError("URLLoader::FinishStreamingToFile force_async failed", |
| 231 rv); |
221 if (rv == PP_OK_COMPLETIONPENDING) | 232 if (rv == PP_OK_COMPLETIONPENDING) |
222 rv = callback.WaitForResult(); | 233 rv = callback.WaitForResult(); |
223 if (rv != PP_OK) | 234 if (rv != PP_OK) |
224 return ReportError("URLLoader::FinishStreamingToFile", rv); | 235 return ReportError("URLLoader::FinishStreamingToFile", rv); |
225 | 236 |
226 pp::FileIO_Dev reader(instance_); | 237 pp::FileIO_Dev reader(instance_); |
227 rv = reader.Open(body, PP_FILEOPENFLAG_READ, callback); | 238 rv = reader.Open(body, PP_FILEOPENFLAG_READ, callback); |
| 239 if (force_async_ && rv != PP_OK_COMPLETIONPENDING) |
| 240 return ReportError("FileIO::Open force_async failed", rv); |
228 if (rv == PP_OK_COMPLETIONPENDING) | 241 if (rv == PP_OK_COMPLETIONPENDING) |
229 rv = callback.WaitForResult(); | 242 rv = callback.WaitForResult(); |
230 if (rv != PP_OK) | 243 if (rv != PP_OK) |
231 return ReportError("FileIO::Open", rv); | 244 return ReportError("FileIO::Open", rv); |
232 | 245 |
233 std::string data; | 246 std::string data; |
234 std::string error = ReadEntireFile(&reader, &data); | 247 std::string error = ReadEntireFile(&reader, &data); |
235 if (!error.empty()) | 248 if (!error.empty()) |
236 return error; | 249 return error; |
237 | 250 |
238 std::string expected_body = "hello\n"; | 251 std::string expected_body = "hello\n"; |
239 if (data.size() != expected_body.size()) | 252 if (data.size() != expected_body.size()) |
240 return "ReadEntireFile returned unexpected content length"; | 253 return "ReadEntireFile returned unexpected content length"; |
241 if (data != expected_body) | 254 if (data != expected_body) |
242 return "ReadEntireFile returned unexpected content"; | 255 return "ReadEntireFile returned unexpected content"; |
243 | 256 |
244 int32_t file_descriptor = file_io_trusted_interface_->GetOSFileDescriptor( | 257 int32_t file_descriptor = file_io_trusted_interface_->GetOSFileDescriptor( |
245 reader.pp_resource()); | 258 reader.pp_resource()); |
246 if (file_descriptor < 0) | 259 if (file_descriptor < 0) |
247 return "FileIO::GetOSFileDescriptor() returned a bad file descriptor."; | 260 return "FileIO::GetOSFileDescriptor() returned a bad file descriptor."; |
248 | 261 |
249 PASS(); | 262 PASS(); |
250 } | 263 } |
251 | 264 |
252 std::string TestURLLoader::TestSameOriginRestriction() { | 265 std::string TestURLLoader::TestSameOriginRestriction() { |
253 pp::URLRequestInfo request(instance_); | 266 pp::URLRequestInfo request(instance_); |
254 request.SetURL("http://www.google.com/"); | 267 request.SetURL("http://www.google.com/"); |
255 | 268 |
256 TestCompletionCallback callback(instance_->pp_instance()); | 269 TestCompletionCallback callback(instance_->pp_instance(), force_async_); |
257 | 270 |
258 pp::URLLoader loader(*instance_); | 271 pp::URLLoader loader(*instance_); |
259 int32_t rv = loader.Open(request, callback); | 272 int32_t rv = loader.Open(request, callback); |
| 273 if (force_async_ && rv != PP_OK_COMPLETIONPENDING) |
| 274 return ReportError("URLLoader::Open force_async failed", rv); |
260 if (rv == PP_OK_COMPLETIONPENDING) | 275 if (rv == PP_OK_COMPLETIONPENDING) |
261 rv = callback.WaitForResult(); | 276 rv = callback.WaitForResult(); |
262 | 277 |
263 // We expect a failure. | 278 // We expect a failure. |
264 if (rv != PP_ERROR_NOACCESS) { | 279 if (rv != PP_ERROR_NOACCESS) { |
265 if (rv == PP_OK) { | 280 if (rv == PP_OK) { |
266 return "URLLoader::Open() failed to block a cross-origin request."; | 281 return "URLLoader::Open() failed to block a cross-origin request."; |
267 } else { | 282 } else { |
268 return ReportError("URLLoader::Open()", rv); | 283 return ReportError("URLLoader::Open()", rv); |
269 } | 284 } |
(...skipping 13 matching lines...) Expand all Loading... |
283 // Replace "127.0.0.1" with "localhost". | 298 // Replace "127.0.0.1" with "localhost". |
284 if (document_url.find("127.0.0.1") == std::string::npos) | 299 if (document_url.find("127.0.0.1") == std::string::npos) |
285 return "Can't construct a cross-origin URL"; | 300 return "Can't construct a cross-origin URL"; |
286 std::string cross_origin_url = document_url.replace( | 301 std::string cross_origin_url = document_url.replace( |
287 components.host.begin, components.host.len, "localhost"); | 302 components.host.begin, components.host.len, "localhost"); |
288 | 303 |
289 pp::URLRequestInfo request(instance_); | 304 pp::URLRequestInfo request(instance_); |
290 request.SetURL(cross_origin_url); | 305 request.SetURL(cross_origin_url); |
291 request.SetAllowCrossOriginRequests(true); | 306 request.SetAllowCrossOriginRequests(true); |
292 | 307 |
293 TestCompletionCallback callback(instance_->pp_instance()); | 308 TestCompletionCallback callback(instance_->pp_instance(), force_async_); |
294 | 309 |
295 pp::URLLoader loader(*instance_); | 310 pp::URLLoader loader(*instance_); |
296 int32_t rv = loader.Open(request, callback); | 311 int32_t rv = loader.Open(request, callback); |
297 if (rv == PP_ERROR_WOULDBLOCK) | 312 if (force_async_ && rv != PP_OK_COMPLETIONPENDING) |
| 313 return ReportError("URLLoader::Open force_async failed", rv); |
| 314 if (rv == PP_OK_COMPLETIONPENDING) |
298 rv = callback.WaitForResult(); | 315 rv = callback.WaitForResult(); |
299 | 316 |
300 // We expect success since we allowed a cross-origin request. | 317 // We expect success since we allowed a cross-origin request. |
301 if (rv != PP_OK) | 318 if (rv != PP_OK) |
302 return ReportError("URLLoader::Open()", rv); | 319 return ReportError("URLLoader::Open()", rv); |
303 | 320 |
304 PASS(); | 321 PASS(); |
305 } | 322 } |
306 | 323 |
307 // This test should cause a redirect and ensure that the loader runs | 324 // This test should cause a redirect and ensure that the loader runs |
308 // the callback, rather than following the redirect. | 325 // the callback, rather than following the redirect. |
309 std::string TestURLLoader::TestAuditURLRedirect() { | 326 std::string TestURLLoader::TestAuditURLRedirect() { |
310 pp::URLRequestInfo request(instance_); | 327 pp::URLRequestInfo request(instance_); |
311 // This path will cause the server to return a 301 redirect. | 328 // This path will cause the server to return a 301 redirect. |
312 request.SetURL("/server-redirect?www.google.com"); | 329 request.SetURL("/server-redirect?www.google.com"); |
313 request.SetFollowRedirects(false); | 330 request.SetFollowRedirects(false); |
314 | 331 |
315 TestCompletionCallback callback(instance_->pp_instance()); | 332 TestCompletionCallback callback(instance_->pp_instance(), force_async_); |
316 | 333 |
317 pp::URLLoader loader(*instance_); | 334 pp::URLLoader loader(*instance_); |
318 int32_t rv = loader.Open(request, callback); | 335 int32_t rv = loader.Open(request, callback); |
| 336 if (force_async_ && rv != PP_OK_COMPLETIONPENDING) |
| 337 return ReportError("URLLoader::Open force_async failed", rv); |
319 if (rv == PP_OK_COMPLETIONPENDING) | 338 if (rv == PP_OK_COMPLETIONPENDING) |
320 rv = callback.WaitForResult(); | 339 rv = callback.WaitForResult(); |
321 if (rv != PP_OK) | 340 if (rv != PP_OK) |
322 return ReportError("URLLoader::Open", rv); | 341 return ReportError("URLLoader::Open", rv); |
323 | 342 |
324 // Checks that the response indicates a redirect, and that the URL | 343 // Checks that the response indicates a redirect, and that the URL |
325 // is correct. | 344 // is correct. |
326 pp::URLResponseInfo response_info(loader.GetResponseInfo()); | 345 pp::URLResponseInfo response_info(loader.GetResponseInfo()); |
327 if (response_info.is_null()) | 346 if (response_info.is_null()) |
328 return "URLLoader::GetResponseInfo returned null"; | 347 return "URLLoader::GetResponseInfo returned null"; |
329 int32_t status_code = response_info.GetStatusCode(); | 348 int32_t status_code = response_info.GetStatusCode(); |
330 if (status_code != 301) | 349 if (status_code != 301) |
331 return "Response status should be 301"; | 350 return "Response status should be 301"; |
332 if (response_info.GetRedirectURL().AsString() != "www.google.com") | 351 if (response_info.GetRedirectURL().AsString() != "www.google.com") |
333 return "Redirect URL should be www.google.com"; | 352 return "Redirect URL should be www.google.com"; |
334 | 353 |
335 PASS(); | 354 PASS(); |
336 } | 355 } |
337 | 356 |
338 std::string TestURLLoader::TestAbortCalls() { | 357 std::string TestURLLoader::TestAbortCalls() { |
339 pp::URLRequestInfo request(instance_); | 358 pp::URLRequestInfo request(instance_); |
340 request.SetURL("test_url_loader_data/hello.txt"); | 359 request.SetURL("test_url_loader_data/hello.txt"); |
341 | 360 |
342 TestCompletionCallback callback(instance_->pp_instance()); | 361 TestCompletionCallback callback(instance_->pp_instance(), force_async_); |
343 int32_t rv; | 362 int32_t rv; |
344 | 363 |
345 // Abort |Open()|. | 364 // Abort |Open()|. |
346 { | 365 { |
347 callback.reset_run_count(); | 366 callback.reset_run_count(); |
348 rv = pp::URLLoader(*instance_).Open(request, callback); | 367 rv = pp::URLLoader(*instance_).Open(request, callback); |
| 368 if (force_async_ && rv != PP_OK_COMPLETIONPENDING) |
| 369 return ReportError("URLLoader::Open force_async failed", rv); |
349 if (callback.run_count() > 0) | 370 if (callback.run_count() > 0) |
350 return "URLLoader::Open ran callback synchronously."; | 371 return "URLLoader::Open ran callback synchronously."; |
351 if (rv == PP_OK_COMPLETIONPENDING) { | 372 if (rv == PP_OK_COMPLETIONPENDING) { |
352 rv = callback.WaitForResult(); | 373 rv = callback.WaitForResult(); |
353 if (rv != PP_ERROR_ABORTED) | 374 if (rv != PP_ERROR_ABORTED) |
354 return "URLLoader::Open not aborted."; | 375 return "URLLoader::Open not aborted."; |
355 } else if (rv != PP_OK) { | 376 } else if (rv != PP_OK) { |
356 return ReportError("URLLoader::Open", rv); | 377 return ReportError("URLLoader::Open", rv); |
357 } | 378 } |
358 } | 379 } |
359 | 380 |
360 // Abort |ReadResponseBody()|. | 381 // Abort |ReadResponseBody()|. |
361 { | 382 { |
362 char buf[2] = { 0 }; | 383 char buf[2] = { 0 }; |
363 { | 384 { |
364 pp::URLLoader loader(*instance_); | 385 pp::URLLoader loader(*instance_); |
365 rv = loader.Open(request, callback); | 386 rv = loader.Open(request, callback); |
| 387 if (force_async_ && rv != PP_OK_COMPLETIONPENDING) |
| 388 return ReportError("URLLoader::Open force_async failed", rv); |
366 if (rv == PP_OK_COMPLETIONPENDING) | 389 if (rv == PP_OK_COMPLETIONPENDING) |
367 rv = callback.WaitForResult(); | 390 rv = callback.WaitForResult(); |
368 if (rv != PP_OK) | 391 if (rv != PP_OK) |
369 return ReportError("URLLoader::Open", rv); | 392 return ReportError("URLLoader::Open", rv); |
370 | 393 |
371 callback.reset_run_count(); | 394 callback.reset_run_count(); |
372 rv = loader.ReadResponseBody(buf, sizeof(buf), callback); | 395 rv = loader.ReadResponseBody(buf, sizeof(buf), callback); |
| 396 if (force_async_ && rv != PP_OK_COMPLETIONPENDING) |
| 397 return ReportError("URLLoader::ReadResponseBody force_async failed", |
| 398 rv); |
373 } // Destroy |loader|. | 399 } // Destroy |loader|. |
374 if (rv == PP_OK_COMPLETIONPENDING) { | 400 if (rv == PP_OK_COMPLETIONPENDING) { |
375 // Save a copy and make sure |buf| doesn't get written to. | 401 // Save a copy and make sure |buf| doesn't get written to. |
376 char buf_copy[2]; | 402 char buf_copy[2]; |
377 memcpy(&buf_copy, &buf, sizeof(buf)); | 403 memcpy(&buf_copy, &buf, sizeof(buf)); |
378 rv = callback.WaitForResult(); | 404 rv = callback.WaitForResult(); |
379 if (rv != PP_ERROR_ABORTED) | 405 if (rv != PP_ERROR_ABORTED) |
380 return "URLLoader::ReadResponseBody not aborted."; | 406 return "URLLoader::ReadResponseBody not aborted."; |
381 if (memcmp(&buf_copy, &buf, sizeof(buf)) != 0) | 407 if (memcmp(&buf_copy, &buf, sizeof(buf)) != 0) |
382 return "URLLoader::ReadResponseBody wrote data after resource " | 408 return "URLLoader::ReadResponseBody wrote data after resource " |
383 "destruction."; | 409 "destruction."; |
384 } else if (rv != PP_OK) { | 410 } else if (rv != PP_OK) { |
385 return ReportError("URLLoader::ReadResponseBody", rv); | 411 return ReportError("URLLoader::ReadResponseBody", rv); |
386 } | 412 } |
387 } | 413 } |
388 | 414 |
389 // TODO(viettrungluu): More abort tests (but add basic tests first). | 415 // TODO(viettrungluu): More abort tests (but add basic tests first). |
390 // Also test that Close() aborts properly. crbug.com/69457 | 416 // Also test that Close() aborts properly. crbug.com/69457 |
391 | 417 |
392 PASS(); | 418 PASS(); |
393 } | 419 } |
394 | 420 |
395 // TODO(viettrungluu): Add tests for FollowRedirect, | 421 // TODO(viettrungluu): Add tests for FollowRedirect, |
396 // Get{Upload,Download}Progress, Close (including abort tests if applicable). | 422 // Get{Upload,Download}Progress, Close (including abort tests if applicable). |
397 // TODO(darin): Add a test for GrantUniversalAccess. | 423 // TODO(darin): Add a test for GrantUniversalAccess. |
OLD | NEW |