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 #include <map> | 5 #include <map> |
6 #include <queue> | 6 #include <queue> |
7 | 7 |
8 #include "base/bind.h" | 8 #include "base/bind.h" |
9 #include "base/callback.h" | 9 #include "base/callback.h" |
10 #include "base/file_path.h" | 10 #include "base/file_path.h" |
(...skipping 590 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
601 | 601 |
602 // Part 1. | 602 // Part 1. |
603 // Subscribe to OnBeforeRequest with requestBody requirement. | 603 // Subscribe to OnBeforeRequest with requestBody requirement. |
604 ASSERT_TRUE(GenerateInfoSpec(string_spec_post, &extra_info_spec_body)); | 604 ASSERT_TRUE(GenerateInfoSpec(string_spec_post, &extra_info_spec_body)); |
605 ExtensionWebRequestEventRouter::GetInstance()->AddEventListener( | 605 ExtensionWebRequestEventRouter::GetInstance()->AddEventListener( |
606 &profile_, extension_id, extension_id, kEventName, kEventName + "/1", | 606 &profile_, extension_id, extension_id, kEventName, kEventName + "/1", |
607 filter, extra_info_spec_body, ipc_sender_factory.GetWeakPtr()); | 607 filter, extra_info_spec_body, ipc_sender_factory.GetWeakPtr()); |
608 | 608 |
609 FireURLRequestWithData(kMethodPost, kMultipart, form_1, form_2); | 609 FireURLRequestWithData(kMethodPost, kMultipart, form_1, form_2); |
610 | 610 |
611 MessageLoop::current()->RunAllPending(); | 611 MessageLoop::current()->RunUntilIdle(); |
612 // We inspect the result in the message list of |ipc_sender_| later. | 612 // We inspect the result in the message list of |ipc_sender_| later. |
613 | 613 |
614 ExtensionWebRequestEventRouter::GetInstance()->RemoveEventListener( | 614 ExtensionWebRequestEventRouter::GetInstance()->RemoveEventListener( |
615 &profile_, extension_id, kEventName + "/1"); | 615 &profile_, extension_id, kEventName + "/1"); |
616 } | 616 } |
617 | 617 |
618 { | 618 { |
619 Feature::ScopedCurrentChannel sc( | 619 Feature::ScopedCurrentChannel sc( |
620 pass > 0 ? VersionInfo::CHANNEL_STABLE : VersionInfo::CHANNEL_DEV); | 620 pass > 0 ? VersionInfo::CHANNEL_STABLE : VersionInfo::CHANNEL_DEV); |
621 | 621 |
(...skipping 21 matching lines...) Expand all Loading... |
643 filter, extra_info_spec_body, ipc_sender_factory.GetWeakPtr()); | 643 filter, extra_info_spec_body, ipc_sender_factory.GetWeakPtr()); |
644 | 644 |
645 // Part 3. | 645 // Part 3. |
646 // Now send a POST request with body which is not parseable as a form. | 646 // Now send a POST request with body which is not parseable as a form. |
647 FireURLRequestWithData(kMethodPost, NULL /*no header*/, plain_1, plain_2); | 647 FireURLRequestWithData(kMethodPost, NULL /*no header*/, plain_1, plain_2); |
648 | 648 |
649 // Part 4. | 649 // Part 4. |
650 // Now send a PUT request with the same body as above. | 650 // Now send a PUT request with the same body as above. |
651 FireURLRequestWithData(kMethodPut, NULL /*no header*/, plain_1, plain_2); | 651 FireURLRequestWithData(kMethodPut, NULL /*no header*/, plain_1, plain_2); |
652 | 652 |
653 MessageLoop::current()->RunAllPending(); | 653 MessageLoop::current()->RunUntilIdle(); |
654 | 654 |
655 // Clean-up. | 655 // Clean-up. |
656 ExtensionWebRequestEventRouter::GetInstance()->RemoveEventListener( | 656 ExtensionWebRequestEventRouter::GetInstance()->RemoveEventListener( |
657 &profile_, extension_id, kEventName + "/1"); | 657 &profile_, extension_id, kEventName + "/1"); |
658 } | 658 } |
659 } | 659 } |
660 | 660 |
661 IPC::Message* message = NULL; | 661 IPC::Message* message = NULL; |
662 TestIPCSender::SentMessages::const_iterator i = ipc_sender_.sent_begin(); | 662 TestIPCSender::SentMessages::const_iterator i = ipc_sender_.sent_begin(); |
663 for (size_t test = 0; test < arraysize(kExpected); ++test) { | 663 for (size_t test = 0; test < arraysize(kExpected); ++test) { |
(...skipping 1417 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2081 EXPECT_TRUE(credentials_set); | 2081 EXPECT_TRUE(credentials_set); |
2082 EXPECT_FALSE(auth3.Empty()); | 2082 EXPECT_FALSE(auth3.Empty()); |
2083 EXPECT_EQ(username, auth1.username()); | 2083 EXPECT_EQ(username, auth1.username()); |
2084 EXPECT_EQ(password, auth1.password()); | 2084 EXPECT_EQ(password, auth1.password()); |
2085 EXPECT_EQ(1u, warning_set.size()); | 2085 EXPECT_EQ(1u, warning_set.size()); |
2086 EXPECT_TRUE(HasWarning(warning_set, "extid2")); | 2086 EXPECT_TRUE(HasWarning(warning_set, "extid2")); |
2087 EXPECT_EQ(3u, capturing_net_log.GetSize()); | 2087 EXPECT_EQ(3u, capturing_net_log.GetSize()); |
2088 } | 2088 } |
2089 | 2089 |
2090 } // namespace extensions | 2090 } // namespace extensions |
OLD | NEW |