OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "content/child/web_url_loader_impl.h" | 5 #include "content/child/web_url_loader_impl.h" |
6 | 6 |
7 #include <string.h> | 7 #include <string.h> |
8 | 8 |
9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
10 #include "base/macros.h" | 10 #include "base/macros.h" |
(...skipping 489 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
500 request.setURL(GURL("data:text/html;charset=utf-8,blah!")); | 500 request.setURL(GURL("data:text/html;charset=utf-8,blah!")); |
501 client()->set_delete_on_receive_data(); | 501 client()->set_delete_on_receive_data(); |
502 client()->loader()->loadAsynchronously(request, client()); | 502 client()->loader()->loadAsynchronously(request, client()); |
503 message_loop()->RunUntilIdle(); | 503 message_loop()->RunUntilIdle(); |
504 EXPECT_TRUE(client()->did_receive_response()); | 504 EXPECT_TRUE(client()->did_receive_response()); |
505 EXPECT_EQ("blah!", client()->received_data()); | 505 EXPECT_EQ("blah!", client()->received_data()); |
506 EXPECT_FALSE(client()->did_finish()); | 506 EXPECT_FALSE(client()->did_finish()); |
507 EXPECT_FALSE(bridge()); | 507 EXPECT_FALSE(bridge()); |
508 } | 508 } |
509 | 509 |
510 TEST_F(WebURLLoaderImplTest, DataURLDeleteOnFinisha) { | 510 TEST_F(WebURLLoaderImplTest, DataURLDeleteOnFinish) { |
511 blink::WebURLRequest request; | 511 blink::WebURLRequest request; |
512 request.initialize(); | 512 request.initialize(); |
513 request.setURL(GURL("data:text/html;charset=utf-8,blah!")); | 513 request.setURL(GURL("data:text/html;charset=utf-8,blah!")); |
514 client()->set_delete_on_finish(); | 514 client()->set_delete_on_finish(); |
515 client()->loader()->loadAsynchronously(request, client()); | 515 client()->loader()->loadAsynchronously(request, client()); |
516 message_loop()->RunUntilIdle(); | 516 message_loop()->RunUntilIdle(); |
517 EXPECT_TRUE(client()->did_receive_response()); | 517 EXPECT_TRUE(client()->did_receive_response()); |
518 EXPECT_EQ("blah!", client()->received_data()); | 518 EXPECT_EQ("blah!", client()->received_data()); |
519 EXPECT_TRUE(client()->did_finish()); | 519 EXPECT_TRUE(client()->did_finish()); |
520 EXPECT_FALSE(bridge()); | 520 EXPECT_FALSE(bridge()); |
521 } | 521 } |
522 | 522 |
| 523 TEST_F(WebURLLoaderImplTest, DataURLDefersLoading) { |
| 524 blink::WebURLRequest request; |
| 525 request.initialize(); |
| 526 request.setURL(GURL("data:text/html;charset=utf-8,blah!")); |
| 527 client()->loader()->loadAsynchronously(request, client()); |
| 528 |
| 529 // setDefersLoading() might be called with either false or true in no |
| 530 // specific order. The user of the API will not have sufficient information |
| 531 // about the WebURLLoader's internal state, so the latter gracefully needs to |
| 532 // handle calling setDefersLoading any number of times with any values from |
| 533 // any point in time. |
| 534 |
| 535 client()->loader()->setDefersLoading(false); |
| 536 client()->loader()->setDefersLoading(true); |
| 537 client()->loader()->setDefersLoading(true); |
| 538 message_loop()->RunUntilIdle(); |
| 539 EXPECT_FALSE(client()->did_finish()); |
| 540 |
| 541 client()->loader()->setDefersLoading(false); |
| 542 client()->loader()->setDefersLoading(true); |
| 543 message_loop()->RunUntilIdle(); |
| 544 EXPECT_FALSE(client()->did_finish()); |
| 545 |
| 546 client()->loader()->setDefersLoading(false); |
| 547 message_loop()->RunUntilIdle(); |
| 548 EXPECT_TRUE(client()->did_finish()); |
| 549 |
| 550 client()->loader()->setDefersLoading(true); |
| 551 client()->loader()->setDefersLoading(false); |
| 552 client()->loader()->setDefersLoading(false); |
| 553 message_loop()->RunUntilIdle(); |
| 554 EXPECT_TRUE(client()->did_finish()); |
| 555 |
| 556 EXPECT_EQ("blah!", client()->received_data()); |
| 557 EXPECT_EQ(net::OK, client()->error().reason); |
| 558 EXPECT_EQ("", client()->error().domain.utf8()); |
| 559 } |
| 560 |
523 // FTP integration tests. These are focused more on safe deletion than correct | 561 // FTP integration tests. These are focused more on safe deletion than correct |
524 // parsing of FTP responses. | 562 // parsing of FTP responses. |
525 | 563 |
526 TEST_F(WebURLLoaderImplTest, Ftp) { | 564 TEST_F(WebURLLoaderImplTest, Ftp) { |
527 DoStartAsyncRequest(); | 565 DoStartAsyncRequest(); |
528 DoReceiveResponseFtp(); | 566 DoReceiveResponseFtp(); |
529 DoReceiveDataFtp(); | 567 DoReceiveDataFtp(); |
530 DoCompleteRequest(); | 568 DoCompleteRequest(); |
531 EXPECT_FALSE(bridge()->canceled()); | 569 EXPECT_FALSE(bridge()->canceled()); |
532 } | 570 } |
(...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
700 EXPECT_EQ(kMimeType, client()->response().mimeType().latin1()); | 738 EXPECT_EQ(kMimeType, client()->response().mimeType().latin1()); |
701 | 739 |
702 DoReceiveData(); | 740 DoReceiveData(); |
703 DoCompleteRequest(); | 741 DoCompleteRequest(); |
704 EXPECT_FALSE(bridge()->canceled()); | 742 EXPECT_FALSE(bridge()->canceled()); |
705 EXPECT_EQ(kTestData, client()->received_data()); | 743 EXPECT_EQ(kTestData, client()->received_data()); |
706 } | 744 } |
707 | 745 |
708 } // namespace | 746 } // namespace |
709 } // namespace content | 747 } // namespace content |
OLD | NEW |