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