Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(80)

Side by Side Diff: chrome/browser/extensions/api/web_request/web_request_api_unittest.cc

Issue 1577673002: WebRequest API cleanup (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: copy GetSocketAddress().host instead of & to resolve win failure Created 4 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 <queue> 9 #include <queue>
10 10
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
70 using base::TimeDelta; 70 using base::TimeDelta;
71 using base::Value; 71 using base::Value;
72 using helpers::CalculateOnAuthRequiredDelta; 72 using helpers::CalculateOnAuthRequiredDelta;
73 using helpers::CalculateOnBeforeRequestDelta; 73 using helpers::CalculateOnBeforeRequestDelta;
74 using helpers::CalculateOnBeforeSendHeadersDelta; 74 using helpers::CalculateOnBeforeSendHeadersDelta;
75 using helpers::CalculateOnHeadersReceivedDelta; 75 using helpers::CalculateOnHeadersReceivedDelta;
76 using helpers::CharListToString; 76 using helpers::CharListToString;
77 using helpers::EventResponseDelta; 77 using helpers::EventResponseDelta;
78 using helpers::EventResponseDeltas; 78 using helpers::EventResponseDeltas;
79 using helpers::EventResponseDeltas; 79 using helpers::EventResponseDeltas;
80 using helpers::ExtraInfoSpec;
80 using helpers::InDecreasingExtensionInstallationTimeOrder; 81 using helpers::InDecreasingExtensionInstallationTimeOrder;
81 using helpers::MergeCancelOfResponses; 82 using helpers::MergeCancelOfResponses;
82 using helpers::MergeOnBeforeRequestResponses; 83 using helpers::MergeOnBeforeRequestResponses;
83 using helpers::RequestCookieModification; 84 using helpers::RequestCookieModification;
84 using helpers::ResponseCookieModification; 85 using helpers::ResponseCookieModification;
85 using helpers::ResponseHeader; 86 using helpers::ResponseHeader;
86 using helpers::ResponseHeaders; 87 using helpers::ResponseHeaders;
87 using helpers::StringToCharList; 88 using helpers::StringToCharList;
88 89
89 namespace extensions { 90 namespace extensions {
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after
224 // blocking events (redirection) by choosing the response from the 225 // blocking events (redirection) by choosing the response from the
225 // most-recently-installed extension. 226 // most-recently-installed extension.
226 TEST_F(ExtensionWebRequestTest, BlockingEventPrecedenceRedirect) { 227 TEST_F(ExtensionWebRequestTest, BlockingEventPrecedenceRedirect) {
227 std::string extension1_id("1"); 228 std::string extension1_id("1");
228 std::string extension2_id("2"); 229 std::string extension2_id("2");
229 ExtensionWebRequestEventRouter::RequestFilter filter; 230 ExtensionWebRequestEventRouter::RequestFilter filter;
230 const std::string kEventName(web_request::OnBeforeRequest::kEventName); 231 const std::string kEventName(web_request::OnBeforeRequest::kEventName);
231 base::WeakPtrFactory<TestIPCSender> ipc_sender_factory(&ipc_sender_); 232 base::WeakPtrFactory<TestIPCSender> ipc_sender_factory(&ipc_sender_);
232 ExtensionWebRequestEventRouter::GetInstance()->AddEventListener( 233 ExtensionWebRequestEventRouter::GetInstance()->AddEventListener(
233 &profile_, extension1_id, extension1_id, events::FOR_TEST, kEventName, 234 &profile_, extension1_id, extension1_id, events::FOR_TEST, kEventName,
234 kEventName + "/1", filter, 235 kEventName + "/1", filter, ExtraInfoSpec::BLOCKING, 0, 0,
235 ExtensionWebRequestEventRouter::ExtraInfoSpec::BLOCKING, 0, 0,
236 ipc_sender_factory.GetWeakPtr()); 236 ipc_sender_factory.GetWeakPtr());
237 ExtensionWebRequestEventRouter::GetInstance()->AddEventListener( 237 ExtensionWebRequestEventRouter::GetInstance()->AddEventListener(
238 &profile_, extension2_id, extension2_id, events::FOR_TEST, kEventName, 238 &profile_, extension2_id, extension2_id, events::FOR_TEST, kEventName,
239 kEventName + "/2", filter, 239 kEventName + "/2", filter, ExtraInfoSpec::BLOCKING, 0, 0,
240 ExtensionWebRequestEventRouter::ExtraInfoSpec::BLOCKING, 0, 0,
241 ipc_sender_factory.GetWeakPtr()); 240 ipc_sender_factory.GetWeakPtr());
242 241
243 net::URLRequestJobFactoryImpl job_factory; 242 net::URLRequestJobFactoryImpl job_factory;
244 job_factory.SetProtocolHandler( 243 job_factory.SetProtocolHandler(
245 url::kAboutScheme, 244 url::kAboutScheme,
246 make_scoped_ptr(new about_handler::AboutProtocolHandler())); 245 make_scoped_ptr(new about_handler::AboutProtocolHandler()));
247 context_->set_job_factory(&job_factory); 246 context_->set_job_factory(&job_factory);
248 247
249 GURL redirect_url("about:redirected"); 248 GURL redirect_url("about:redirected");
250 GURL not_chosen_redirect_url("about:not_chosen"); 249 GURL not_chosen_redirect_url("about:not_chosen");
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after
363 // Test that a request is canceled if this is requested by any extension 362 // Test that a request is canceled if this is requested by any extension
364 // regardless whether it is the extension with the highest precedence. 363 // regardless whether it is the extension with the highest precedence.
365 TEST_F(ExtensionWebRequestTest, BlockingEventPrecedenceCancel) { 364 TEST_F(ExtensionWebRequestTest, BlockingEventPrecedenceCancel) {
366 std::string extension1_id("1"); 365 std::string extension1_id("1");
367 std::string extension2_id("2"); 366 std::string extension2_id("2");
368 ExtensionWebRequestEventRouter::RequestFilter filter; 367 ExtensionWebRequestEventRouter::RequestFilter filter;
369 const std::string kEventName(web_request::OnBeforeRequest::kEventName); 368 const std::string kEventName(web_request::OnBeforeRequest::kEventName);
370 base::WeakPtrFactory<TestIPCSender> ipc_sender_factory(&ipc_sender_); 369 base::WeakPtrFactory<TestIPCSender> ipc_sender_factory(&ipc_sender_);
371 ExtensionWebRequestEventRouter::GetInstance()->AddEventListener( 370 ExtensionWebRequestEventRouter::GetInstance()->AddEventListener(
372 &profile_, extension1_id, extension1_id, events::FOR_TEST, kEventName, 371 &profile_, extension1_id, extension1_id, events::FOR_TEST, kEventName,
373 kEventName + "/1", filter, 372 kEventName + "/1", filter, ExtraInfoSpec::BLOCKING, 0, 0,
374 ExtensionWebRequestEventRouter::ExtraInfoSpec::BLOCKING, 0, 0,
375 ipc_sender_factory.GetWeakPtr()); 373 ipc_sender_factory.GetWeakPtr());
376 ExtensionWebRequestEventRouter::GetInstance()->AddEventListener( 374 ExtensionWebRequestEventRouter::GetInstance()->AddEventListener(
377 &profile_, extension2_id, extension2_id, events::FOR_TEST, kEventName, 375 &profile_, extension2_id, extension2_id, events::FOR_TEST, kEventName,
378 kEventName + "/2", filter, 376 kEventName + "/2", filter, ExtraInfoSpec::BLOCKING, 0, 0,
379 ExtensionWebRequestEventRouter::ExtraInfoSpec::BLOCKING, 0, 0,
380 ipc_sender_factory.GetWeakPtr()); 377 ipc_sender_factory.GetWeakPtr());
381 378
382 GURL request_url("about:blank"); 379 GURL request_url("about:blank");
383 scoped_ptr<net::URLRequest> request(context_->CreateRequest( 380 scoped_ptr<net::URLRequest> request(context_->CreateRequest(
384 request_url, net::DEFAULT_PRIORITY, &delegate_)); 381 request_url, net::DEFAULT_PRIORITY, &delegate_));
385 382
386 // onBeforeRequest will be dispatched twice. The second response - 383 // onBeforeRequest will be dispatched twice. The second response -
387 // the redirect - would win, since it has a later |install_time|, but 384 // the redirect - would win, since it has a later |install_time|, but
388 // the first response takes precedence because cancel >> redirect. 385 // the first response takes precedence because cancel >> redirect.
389 GURL redirect_url("about:redirected"); 386 GURL redirect_url("about:redirected");
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
434 431
435 std::string extension_id("1"); 432 std::string extension_id("1");
436 ExtensionWebRequestEventRouter::RequestFilter filter; 433 ExtensionWebRequestEventRouter::RequestFilter filter;
437 434
438 // Subscribe to OnBeforeRequest and OnErrorOccurred. 435 // Subscribe to OnBeforeRequest and OnErrorOccurred.
439 const std::string kEventName(web_request::OnBeforeRequest::kEventName); 436 const std::string kEventName(web_request::OnBeforeRequest::kEventName);
440 const std::string kEventName2(web_request::OnErrorOccurred::kEventName); 437 const std::string kEventName2(web_request::OnErrorOccurred::kEventName);
441 base::WeakPtrFactory<TestIPCSender> ipc_sender_factory(&ipc_sender_); 438 base::WeakPtrFactory<TestIPCSender> ipc_sender_factory(&ipc_sender_);
442 ExtensionWebRequestEventRouter::GetInstance()->AddEventListener( 439 ExtensionWebRequestEventRouter::GetInstance()->AddEventListener(
443 &profile_, extension_id, extension_id, events::FOR_TEST, kEventName, 440 &profile_, extension_id, extension_id, events::FOR_TEST, kEventName,
444 kEventName + "/1", filter, 441 kEventName + "/1", filter, ExtraInfoSpec::BLOCKING, 0, 0,
445 ExtensionWebRequestEventRouter::ExtraInfoSpec::BLOCKING, 0, 0,
446 ipc_sender_factory.GetWeakPtr()); 442 ipc_sender_factory.GetWeakPtr());
447 ExtensionWebRequestEventRouter::GetInstance()->AddEventListener( 443 ExtensionWebRequestEventRouter::GetInstance()->AddEventListener(
448 &profile_, extension_id, extension_id, events::FOR_TEST, kEventName2, 444 &profile_, extension_id, extension_id, events::FOR_TEST, kEventName2,
449 kEventName2 + "/1", filter, 0, 0, 0, ipc_sender_factory.GetWeakPtr()); 445 kEventName2 + "/1", filter, 0, 0, 0, ipc_sender_factory.GetWeakPtr());
450 446
451 GURL request_url("about:blank"); 447 GURL request_url("about:blank");
452 scoped_ptr<net::URLRequest> request(context_->CreateRequest( 448 scoped_ptr<net::URLRequest> request(context_->CreateRequest(
453 request_url, net::DEFAULT_PRIORITY, &delegate_)); 449 request_url, net::DEFAULT_PRIORITY, &delegate_));
454 450
455 ExtensionWebRequestEventRouter::EventResponse* response = NULL; 451 ExtensionWebRequestEventRouter::EventResponse* response = NULL;
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
493 489
494 // Create the numerical representation of |values|, strings passed as 490 // Create the numerical representation of |values|, strings passed as
495 // extraInfoSpec by the event handler. Returns true on success, otherwise false. 491 // extraInfoSpec by the event handler. Returns true on success, otherwise false.
496 bool GenerateInfoSpec(const std::string& values, int* result) { 492 bool GenerateInfoSpec(const std::string& values, int* result) {
497 // Create a base::ListValue of strings. 493 // Create a base::ListValue of strings.
498 base::ListValue list_value; 494 base::ListValue list_value;
499 for (const std::string& cur : 495 for (const std::string& cur :
500 base::SplitString(values, ",", base::KEEP_WHITESPACE, 496 base::SplitString(values, ",", base::KEEP_WHITESPACE,
501 base::SPLIT_WANT_NONEMPTY)) 497 base::SPLIT_WANT_NONEMPTY))
502 list_value.Append(new base::StringValue(cur)); 498 list_value.Append(new base::StringValue(cur));
503 return ExtensionWebRequestEventRouter::ExtraInfoSpec::InitFromValue( 499 return ExtraInfoSpec::InitFromValue(list_value, result);
504 list_value, result);
505 } 500 }
506 501
507 } // namespace 502 } // namespace
508 503
509 void ExtensionWebRequestTest::FireURLRequestWithData( 504 void ExtensionWebRequestTest::FireURLRequestWithData(
510 const std::string& method, 505 const std::string& method,
511 const char* content_type, 506 const char* content_type,
512 const std::vector<char>& bytes_1, 507 const std::vector<char>& bytes_1,
513 const std::vector<char>& bytes_2) { 508 const std::vector<char>& bytes_2) {
514 // The request URL can be arbitrary but must have an HTTP or HTTPS scheme. 509 // The request URL can be arbitrary but must have an HTTP or HTTPS scheme.
(...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after
696 EXPECT_TRUE(details->Get(*(kPath[test]), &result)); 691 EXPECT_TRUE(details->Get(*(kPath[test]), &result));
697 EXPECT_TRUE(kExpected[test]->Equals(result)); 692 EXPECT_TRUE(kExpected[test]->Equals(result));
698 } else { 693 } else {
699 EXPECT_FALSE(details->Get(*(kPath[test]), &result)); 694 EXPECT_FALSE(details->Get(*(kPath[test]), &result));
700 } 695 }
701 } 696 }
702 697
703 EXPECT_EQ(i, ipc_sender_.sent_end()); 698 EXPECT_EQ(i, ipc_sender_.sent_end());
704 } 699 }
705 700
701 // Tests whether requestBody is only present on the events that requested it.
702 TEST_F(ExtensionWebRequestTest, MinimalAccessRequestBodyData) {
703 const std::string kEventName(web_request::OnBeforeRequest::kEventName);
704 ExtensionWebRequestEventRouter::RequestFilter filter;
705 const std::string extension_id1("1");
706 const std::string extension_id2("2");
707 int extra_info_spec_body = 0;
708 int extra_info_spec_empty = 0;
709 ASSERT_TRUE(GenerateInfoSpec("requestBody", &extra_info_spec_body));
710 base::WeakPtrFactory<TestIPCSender> ipc_sender_factory(&ipc_sender_);
711
712 bool kExpected[] = {
713 true,
714 false,
715 false,
716 true,
717 };
718
719 // Extension 1 with requestBody spec.
720 ExtensionWebRequestEventRouter::GetInstance()->AddEventListener(
721 &profile_, extension_id1, extension_id1, events::FOR_TEST, kEventName,
722 kEventName + "/1", filter, extra_info_spec_body, 0, 0,
723 ipc_sender_factory.GetWeakPtr());
724
725 // Extension 1 without requestBody spec.
726 ExtensionWebRequestEventRouter::GetInstance()->AddEventListener(
727 &profile_, extension_id1, extension_id1, events::FOR_TEST, kEventName,
728 kEventName + "/2", filter, extra_info_spec_empty, 0, 0,
729 ipc_sender_factory.GetWeakPtr());
730
731 // Extension 2, without requestBody spec.
732 ExtensionWebRequestEventRouter::GetInstance()->AddEventListener(
733 &profile_, extension_id2, extension_id2, events::FOR_TEST, kEventName,
734 kEventName + "/1", filter, extra_info_spec_empty, 0, 0,
735 ipc_sender_factory.GetWeakPtr());
736
737 // Extension 2, with requestBody spec.
738 ExtensionWebRequestEventRouter::GetInstance()->AddEventListener(
739 &profile_, extension_id2, extension_id2, events::FOR_TEST, kEventName,
740 kEventName + "/2", filter, extra_info_spec_body, 0, 0,
741 ipc_sender_factory.GetWeakPtr());
742
743 // Only one request is sent, but more than one event will be triggered.
744 for (size_t i = 1; i < arraysize(kExpected); ++i)
745 ipc_sender_.PushTask(base::Bind(&base::DoNothing));
746
747 const std::vector<char> part_of_body(1);
748 FireURLRequestWithData("POST", nullptr, part_of_body, part_of_body);
749
750 base::MessageLoop::current()->RunUntilIdle();
751
752 // Clean-up
753 ExtensionWebRequestEventRouter::GetInstance()->RemoveEventListener(
754 &profile_, extension_id1, kEventName + "/1", 0, 0);
755 ExtensionWebRequestEventRouter::GetInstance()->RemoveEventListener(
756 &profile_, extension_id2, kEventName + "/2", 0, 0);
757 ExtensionWebRequestEventRouter::GetInstance()->RemoveEventListener(
758 &profile_, extension_id1, kEventName + "/1", 0, 0);
759 ExtensionWebRequestEventRouter::GetInstance()->RemoveEventListener(
760 &profile_, extension_id2, kEventName + "/2", 0, 0);
761
762 TestIPCSender::SentMessages::const_iterator i = ipc_sender_.sent_begin();
763
764 for (size_t test = 0; test < arraysize(kExpected); ++test, ++i) {
765 SCOPED_TRACE(testing::Message("iteration number ") << test);
766 EXPECT_NE(i, ipc_sender_.sent_end());
767 IPC::Message* message = i->get();
768 const base::DictionaryValue* details = nullptr;
769 ExtensionMsg_MessageInvoke::Param param;
770 GetPartOfMessageArguments(message, &details, &param);
771 ASSERT_TRUE(details != nullptr);
772 EXPECT_EQ(kExpected[test], details->HasKey(keys::kRequestBodyKey));
773 }
774
775 EXPECT_EQ(i, ipc_sender_.sent_end());
776 }
777
706 TEST_F(ExtensionWebRequestTest, NoAccessRequestBodyData) { 778 TEST_F(ExtensionWebRequestTest, NoAccessRequestBodyData) {
707 // We verify that URLRequest body is NOT accessible to OnBeforeRequest 779 // We verify that URLRequest body is NOT accessible to OnBeforeRequest
708 // listeners when the type of the request is different from POST or PUT, or 780 // listeners when the type of the request is different from POST or PUT, or
709 // when the request body is empty. 3 requests are fired, without upload data, 781 // when the request body is empty. 3 requests are fired, without upload data,
710 // a POST, PUT and GET request. For none of them the "requestBody" object 782 // a POST, PUT and GET request. For none of them the "requestBody" object
711 // property should be present in the details passed to the onBeforeRequest 783 // property should be present in the details passed to the onBeforeRequest
712 // event listener. 784 // event listener.
713 const char* const kMethods[] = { "POST", "PUT", "GET" }; 785 const char* const kMethods[] = { "POST", "PUT", "GET" };
714 786
715 // Set up a dummy extension name. 787 // Set up a dummy extension name.
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after
829 std::string extension2_id("2"); 901 std::string extension2_id("2");
830 std::string extension3_id("3"); 902 std::string extension3_id("3");
831 ExtensionWebRequestEventRouter::RequestFilter filter; 903 ExtensionWebRequestEventRouter::RequestFilter filter;
832 const std::string kEventName(keys::kOnBeforeSendHeadersEvent); 904 const std::string kEventName(keys::kOnBeforeSendHeadersEvent);
833 base::WeakPtrFactory<TestIPCSender> ipc_sender_factory(&ipc_sender_); 905 base::WeakPtrFactory<TestIPCSender> ipc_sender_factory(&ipc_sender_);
834 906
835 // Install two extensions that can modify headers. Extension 2 has 907 // Install two extensions that can modify headers. Extension 2 has
836 // higher precedence than extension 1. 908 // higher precedence than extension 1.
837 ExtensionWebRequestEventRouter::GetInstance()->AddEventListener( 909 ExtensionWebRequestEventRouter::GetInstance()->AddEventListener(
838 &profile_, extension1_id, extension1_id, events::FOR_TEST, kEventName, 910 &profile_, extension1_id, extension1_id, events::FOR_TEST, kEventName,
839 kEventName + "/1", filter, 911 kEventName + "/1", filter, ExtraInfoSpec::BLOCKING, 0, 0,
840 ExtensionWebRequestEventRouter::ExtraInfoSpec::BLOCKING, 0, 0,
841 ipc_sender_factory.GetWeakPtr()); 912 ipc_sender_factory.GetWeakPtr());
842 ExtensionWebRequestEventRouter::GetInstance()->AddEventListener( 913 ExtensionWebRequestEventRouter::GetInstance()->AddEventListener(
843 &profile_, extension2_id, extension2_id, events::FOR_TEST, kEventName, 914 &profile_, extension2_id, extension2_id, events::FOR_TEST, kEventName,
844 kEventName + "/2", filter, 915 kEventName + "/2", filter, ExtraInfoSpec::BLOCKING, 0, 0,
845 ExtensionWebRequestEventRouter::ExtraInfoSpec::BLOCKING, 0, 0,
846 ipc_sender_factory.GetWeakPtr()); 916 ipc_sender_factory.GetWeakPtr());
847 917
848 // Install one extension that observes the final headers. 918 // Install one extension that observes the final headers.
849 ExtensionWebRequestEventRouter::GetInstance()->AddEventListener( 919 ExtensionWebRequestEventRouter::GetInstance()->AddEventListener(
850 &profile_, extension3_id, extension3_id, events::FOR_TEST, 920 &profile_, extension3_id, extension3_id, events::FOR_TEST,
851 keys::kOnSendHeadersEvent, std::string(keys::kOnSendHeadersEvent) + "/3", 921 keys::kOnSendHeadersEvent, std::string(keys::kOnSendHeadersEvent) + "/3",
852 filter, ExtensionWebRequestEventRouter::ExtraInfoSpec::REQUEST_HEADERS, 0, 922 filter, ExtraInfoSpec::REQUEST_HEADERS, 0, 0,
853 0, ipc_sender_factory.GetWeakPtr()); 923 ipc_sender_factory.GetWeakPtr());
854 924
855 GURL request_url("http://doesnotexist/does_not_exist.html"); 925 GURL request_url("http://doesnotexist/does_not_exist.html");
856 scoped_ptr<net::URLRequest> request(context_->CreateRequest( 926 scoped_ptr<net::URLRequest> request(context_->CreateRequest(
857 request_url, net::DEFAULT_PRIORITY, &delegate_)); 927 request_url, net::DEFAULT_PRIORITY, &delegate_));
858 928
859 // Initialize headers available before extensions are notified of the 929 // Initialize headers available before extensions are notified of the
860 // onBeforeSendHeaders event. 930 // onBeforeSendHeaders event.
861 HeaderModificationTest test = GetParam(); 931 HeaderModificationTest test = GetParam();
862 net::HttpRequestHeaders before_headers; 932 net::HttpRequestHeaders before_headers;
863 for (int i = 0; i < test.before_size; ++i) 933 for (int i = 0; i < test.before_size; ++i)
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after
993 1063
994 } // namespace 1064 } // namespace
995 1065
996 TEST_F(ExtensionWebRequestTest, InitFromValue) { 1066 TEST_F(ExtensionWebRequestTest, InitFromValue) {
997 TestInitFromValue(std::string(), true, 0); 1067 TestInitFromValue(std::string(), true, 0);
998 1068
999 // Single valid values. 1069 // Single valid values.
1000 TestInitFromValue( 1070 TestInitFromValue(
1001 "requestHeaders", 1071 "requestHeaders",
1002 true, 1072 true,
1003 ExtensionWebRequestEventRouter::ExtraInfoSpec::REQUEST_HEADERS); 1073 ExtraInfoSpec::REQUEST_HEADERS);
1004 TestInitFromValue( 1074 TestInitFromValue(
1005 "responseHeaders", 1075 "responseHeaders",
1006 true, 1076 true,
1007 ExtensionWebRequestEventRouter::ExtraInfoSpec::RESPONSE_HEADERS); 1077 ExtraInfoSpec::RESPONSE_HEADERS);
1008 TestInitFromValue( 1078 TestInitFromValue(
1009 "blocking", 1079 "blocking",
1010 true, 1080 true,
1011 ExtensionWebRequestEventRouter::ExtraInfoSpec::BLOCKING); 1081 ExtraInfoSpec::BLOCKING);
1012 TestInitFromValue( 1082 TestInitFromValue(
1013 "asyncBlocking", 1083 "asyncBlocking",
1014 true, 1084 true,
1015 ExtensionWebRequestEventRouter::ExtraInfoSpec::ASYNC_BLOCKING); 1085 ExtraInfoSpec::ASYNC_BLOCKING);
1016 TestInitFromValue( 1086 TestInitFromValue(
1017 "requestBody", 1087 "requestBody",
1018 true, 1088 true,
1019 ExtensionWebRequestEventRouter::ExtraInfoSpec::REQUEST_BODY); 1089 ExtraInfoSpec::REQUEST_BODY);
1020 1090
1021 // Multiple valid values are bitwise-or'ed. 1091 // Multiple valid values are bitwise-or'ed.
1022 TestInitFromValue( 1092 TestInitFromValue(
1023 "requestHeaders,blocking", 1093 "requestHeaders,blocking",
1024 true, 1094 true,
1025 ExtensionWebRequestEventRouter::ExtraInfoSpec::REQUEST_HEADERS | 1095 ExtraInfoSpec::REQUEST_HEADERS | ExtraInfoSpec::BLOCKING);
1026 ExtensionWebRequestEventRouter::ExtraInfoSpec::BLOCKING);
1027 1096
1028 // Any invalid values lead to a bad parse. 1097 // Any invalid values lead to a bad parse.
1029 TestInitFromValue("invalidValue", false, 0); 1098 TestInitFromValue("invalidValue", false, 0);
1030 TestInitFromValue("blocking,invalidValue", false, 0); 1099 TestInitFromValue("blocking,invalidValue", false, 0);
1031 TestInitFromValue("invalidValue1,invalidValue2", false, 0); 1100 TestInitFromValue("invalidValue1,invalidValue2", false, 0);
1032 1101
1033 // BLOCKING and ASYNC_BLOCKING are mutually exclusive. 1102 // BLOCKING and ASYNC_BLOCKING are mutually exclusive.
1034 TestInitFromValue("blocking,asyncBlocking", false, 0); 1103 TestInitFromValue("blocking,asyncBlocking", false, 0);
1035 } 1104 }
1036 1105
(...skipping 1209 matching lines...) Expand 10 before | Expand all | Expand 10 after
2246 EXPECT_TRUE(credentials_set); 2315 EXPECT_TRUE(credentials_set);
2247 EXPECT_FALSE(auth3.Empty()); 2316 EXPECT_FALSE(auth3.Empty());
2248 EXPECT_EQ(username, auth1.username()); 2317 EXPECT_EQ(username, auth1.username());
2249 EXPECT_EQ(password, auth1.password()); 2318 EXPECT_EQ(password, auth1.password());
2250 EXPECT_EQ(1u, warning_set.size()); 2319 EXPECT_EQ(1u, warning_set.size());
2251 EXPECT_TRUE(HasWarning(warning_set, "extid2")); 2320 EXPECT_TRUE(HasWarning(warning_set, "extid2"));
2252 EXPECT_EQ(3u, capturing_net_log.GetSize()); 2321 EXPECT_EQ(3u, capturing_net_log.GetSize());
2253 } 2322 }
2254 2323
2255 } // namespace extensions 2324 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698