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 client()->loader()->setDefersLoading(true); | |
530 message_loop()->RunUntilIdle(); | |
531 EXPECT_FALSE(client()->did_finish()); | |
532 message_loop()->RunUntilIdle(); | |
533 EXPECT_FALSE(client()->did_finish()); | |
davidben
2014/11/21 18:34:00
Why do this twice? I would have thought that a Run
| |
534 | |
535 client()->loader()->setDefersLoading(false); | |
536 message_loop()->RunUntilIdle(); | |
537 EXPECT_TRUE(client()->did_finish()); | |
538 | |
539 EXPECT_EQ("blah!", client()->received_data()); | |
540 EXPECT_EQ(net::OK, client()->error().reason); | |
541 EXPECT_EQ("", client()->error().domain.utf8()); | |
542 } | |
543 | |
523 // FTP integration tests. These are focused more on safe deletion than correct | 544 // FTP integration tests. These are focused more on safe deletion than correct |
524 // parsing of FTP responses. | 545 // parsing of FTP responses. |
525 | 546 |
526 TEST_F(WebURLLoaderImplTest, Ftp) { | 547 TEST_F(WebURLLoaderImplTest, Ftp) { |
527 DoStartAsyncRequest(); | 548 DoStartAsyncRequest(); |
528 DoReceiveResponseFtp(); | 549 DoReceiveResponseFtp(); |
529 DoReceiveDataFtp(); | 550 DoReceiveDataFtp(); |
530 DoCompleteRequest(); | 551 DoCompleteRequest(); |
531 EXPECT_FALSE(bridge()->canceled()); | 552 EXPECT_FALSE(bridge()->canceled()); |
532 } | 553 } |
(...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
700 EXPECT_EQ(kMimeType, client()->response().mimeType().latin1()); | 721 EXPECT_EQ(kMimeType, client()->response().mimeType().latin1()); |
701 | 722 |
702 DoReceiveData(); | 723 DoReceiveData(); |
703 DoCompleteRequest(); | 724 DoCompleteRequest(); |
704 EXPECT_FALSE(bridge()->canceled()); | 725 EXPECT_FALSE(bridge()->canceled()); |
705 EXPECT_EQ(kTestData, client()->received_data()); | 726 EXPECT_EQ(kTestData, client()->received_data()); |
706 } | 727 } |
707 | 728 |
708 } // namespace | 729 } // namespace |
709 } // namespace content | 730 } // namespace content |
OLD | NEW |