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 <stddef.h> | 5 #include <stddef.h> |
6 #include <stdint.h> | 6 #include <stdint.h> |
7 | 7 |
8 #include <map> | 8 #include <map> |
9 #include <memory> | 9 #include <memory> |
10 #include <queue> | 10 #include <queue> |
(...skipping 815 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
826 const base::DictionaryValue* details = NULL; | 826 const base::DictionaryValue* details = NULL; |
827 ExtensionMsg_MessageInvoke::Param param; | 827 ExtensionMsg_MessageInvoke::Param param; |
828 GetPartOfMessageArguments(message, &details, ¶m); | 828 GetPartOfMessageArguments(message, &details, ¶m); |
829 ASSERT_TRUE(details != NULL); | 829 ASSERT_TRUE(details != NULL); |
830 EXPECT_FALSE(details->HasKey(keys::kRequestBodyKey)); | 830 EXPECT_FALSE(details->HasKey(keys::kRequestBodyKey)); |
831 } | 831 } |
832 | 832 |
833 EXPECT_EQ(i, ipc_sender_.sent_end()); | 833 EXPECT_EQ(i, ipc_sender_.sent_end()); |
834 } | 834 } |
835 | 835 |
| 836 // Tests the sanity of operator< (crbug.com/589735). |
| 837 TEST_F(ExtensionWebRequestTest, AddAndRemoveListeners) { |
| 838 std::string ext_id("abcdefghijklmnopabcdefghijklmnop"); |
| 839 ExtensionWebRequestEventRouter::RequestFilter filter; |
| 840 const std::string kEventName(web_request::OnBeforeRequest::kEventName); |
| 841 const std::string kSubEventName = kEventName + "/1"; |
| 842 base::WeakPtrFactory<TestIPCSender> ipc_sender_factory(&ipc_sender_); |
| 843 |
| 844 // Add two non-webview listeners. |
| 845 ExtensionWebRequestEventRouter::GetInstance()->AddEventListener( |
| 846 &profile_, ext_id, ext_id, events::FOR_TEST, kEventName, kSubEventName, |
| 847 filter, 0, 1 /* embedder_process_id */, 0, |
| 848 ipc_sender_factory.GetWeakPtr()); |
| 849 ExtensionWebRequestEventRouter::GetInstance()->AddEventListener( |
| 850 &profile_, ext_id, ext_id, events::FOR_TEST, kEventName, kSubEventName, |
| 851 filter, 0, 2 /* embedder_process_id */, 0, |
| 852 ipc_sender_factory.GetWeakPtr()); |
| 853 |
| 854 // Now remove the events without passing an explicit process ID. |
| 855 ExtensionWebRequestEventRouter::GetInstance()->RemoveEventListener( |
| 856 &profile_, ext_id, kSubEventName, 0 /* embedder_process_id */, 0); |
| 857 EXPECT_EQ(1, |
| 858 ExtensionWebRequestEventRouter::GetInstance()->GetListenerCountForTesting( |
| 859 &profile_, kEventName)); |
| 860 |
| 861 ExtensionWebRequestEventRouter::GetInstance()->RemoveEventListener( |
| 862 &profile_, ext_id, kSubEventName, 0 /* embedder_process_id */, 0); |
| 863 EXPECT_EQ(0, |
| 864 ExtensionWebRequestEventRouter::GetInstance()->GetListenerCountForTesting( |
| 865 &profile_, kEventName)); |
| 866 } |
| 867 |
836 struct HeaderModificationTest_Header { | 868 struct HeaderModificationTest_Header { |
837 const char* name; | 869 const char* name; |
838 const char* value; | 870 const char* value; |
839 }; | 871 }; |
840 | 872 |
841 struct HeaderModificationTest_Modification { | 873 struct HeaderModificationTest_Modification { |
842 enum Type { | 874 enum Type { |
843 SET, | 875 SET, |
844 REMOVE | 876 REMOVE |
845 }; | 877 }; |
(...skipping 1468 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2314 EXPECT_TRUE(credentials_set); | 2346 EXPECT_TRUE(credentials_set); |
2315 EXPECT_FALSE(auth3.Empty()); | 2347 EXPECT_FALSE(auth3.Empty()); |
2316 EXPECT_EQ(username, auth1.username()); | 2348 EXPECT_EQ(username, auth1.username()); |
2317 EXPECT_EQ(password, auth1.password()); | 2349 EXPECT_EQ(password, auth1.password()); |
2318 EXPECT_EQ(1u, warning_set.size()); | 2350 EXPECT_EQ(1u, warning_set.size()); |
2319 EXPECT_TRUE(HasWarning(warning_set, "extid2")); | 2351 EXPECT_TRUE(HasWarning(warning_set, "extid2")); |
2320 EXPECT_EQ(3u, capturing_net_log.GetSize()); | 2352 EXPECT_EQ(3u, capturing_net_log.GetSize()); |
2321 } | 2353 } |
2322 | 2354 |
2323 } // namespace extensions | 2355 } // namespace extensions |
OLD | NEW |