| 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/basictypes.h" | 8 #include "base/basictypes.h" |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/callback.h" | 10 #include "base/callback.h" |
| (...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 150 SentMessages::const_iterator sent_end() const { | 150 SentMessages::const_iterator sent_end() const { |
| 151 return sent_messages_.end(); | 151 return sent_messages_.end(); |
| 152 } | 152 } |
| 153 | 153 |
| 154 private: | 154 private: |
| 155 // IPC::Sender | 155 // IPC::Sender |
| 156 virtual bool Send(IPC::Message* message) OVERRIDE { | 156 virtual bool Send(IPC::Message* message) OVERRIDE { |
| 157 EXPECT_EQ(ExtensionMsg_MessageInvoke::ID, message->type()); | 157 EXPECT_EQ(ExtensionMsg_MessageInvoke::ID, message->type()); |
| 158 | 158 |
| 159 EXPECT_FALSE(task_queue_.empty()); | 159 EXPECT_FALSE(task_queue_.empty()); |
| 160 MessageLoop::current()->PostTask(FROM_HERE, task_queue_.front()); | 160 base::MessageLoop::current()->PostTask(FROM_HERE, task_queue_.front()); |
| 161 task_queue_.pop(); | 161 task_queue_.pop(); |
| 162 | 162 |
| 163 sent_messages_.push_back(linked_ptr<IPC::Message>(message)); | 163 sent_messages_.push_back(linked_ptr<IPC::Message>(message)); |
| 164 return true; | 164 return true; |
| 165 } | 165 } |
| 166 | 166 |
| 167 std::queue<base::Closure> task_queue_; | 167 std::queue<base::Closure> task_queue_; |
| 168 SentMessages sent_messages_; | 168 SentMessages sent_messages_; |
| 169 }; | 169 }; |
| 170 | 170 |
| (...skipping 20 matching lines...) Expand all Loading... |
| 191 context_->Init(); | 191 context_->Init(); |
| 192 } | 192 } |
| 193 | 193 |
| 194 // Fires a URLRequest with the specified |method|, |content_type| and three | 194 // Fires a URLRequest with the specified |method|, |content_type| and three |
| 195 // elements of upload data: bytes_1, a dummy empty file, bytes_2. | 195 // elements of upload data: bytes_1, a dummy empty file, bytes_2. |
| 196 void FireURLRequestWithData(const std::string& method, | 196 void FireURLRequestWithData(const std::string& method, |
| 197 const char* content_type, | 197 const char* content_type, |
| 198 const std::vector<char>& bytes_1, | 198 const std::vector<char>& bytes_1, |
| 199 const std::vector<char>& bytes_2); | 199 const std::vector<char>& bytes_2); |
| 200 | 200 |
| 201 MessageLoopForIO message_loop_; | 201 base::MessageLoopForIO message_loop_; |
| 202 content::TestBrowserThread ui_thread_; | 202 content::TestBrowserThread ui_thread_; |
| 203 content::TestBrowserThread io_thread_; | 203 content::TestBrowserThread io_thread_; |
| 204 TestingProfile profile_; | 204 TestingProfile profile_; |
| 205 TestingProfileManager profile_manager_; | 205 TestingProfileManager profile_manager_; |
| 206 net::TestDelegate delegate_; | 206 net::TestDelegate delegate_; |
| 207 BooleanPrefMember enable_referrers_; | 207 BooleanPrefMember enable_referrers_; |
| 208 TestIPCSender ipc_sender_; | 208 TestIPCSender ipc_sender_; |
| 209 scoped_refptr<EventRouterForwarder> event_router_; | 209 scoped_refptr<EventRouterForwarder> event_router_; |
| 210 scoped_refptr<ExtensionInfoMap> extension_info_map_; | 210 scoped_refptr<ExtensionInfoMap> extension_info_map_; |
| 211 scoped_ptr<ChromeNetworkDelegate> network_delegate_; | 211 scoped_ptr<ChromeNetworkDelegate> network_delegate_; |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 269 | 269 |
| 270 // Extension1 response to the redirected URL. Arrives second, and ignored. | 270 // Extension1 response to the redirected URL. Arrives second, and ignored. |
| 271 response = new ExtensionWebRequestEventRouter::EventResponse( | 271 response = new ExtensionWebRequestEventRouter::EventResponse( |
| 272 extension1_id, base::Time::FromDoubleT(1)); | 272 extension1_id, base::Time::FromDoubleT(1)); |
| 273 ipc_sender_.PushTask( | 273 ipc_sender_.PushTask( |
| 274 base::Bind(&EventHandledOnIOThread, | 274 base::Bind(&EventHandledOnIOThread, |
| 275 &profile_, extension1_id, kEventName, kEventName + "/1", | 275 &profile_, extension1_id, kEventName, kEventName + "/1", |
| 276 request.identifier(), response)); | 276 request.identifier(), response)); |
| 277 | 277 |
| 278 request.Start(); | 278 request.Start(); |
| 279 MessageLoop::current()->Run(); | 279 base::MessageLoop::current()->Run(); |
| 280 | 280 |
| 281 EXPECT_TRUE(!request.is_pending()); | 281 EXPECT_TRUE(!request.is_pending()); |
| 282 EXPECT_EQ(net::URLRequestStatus::SUCCESS, request.status().status()); | 282 EXPECT_EQ(net::URLRequestStatus::SUCCESS, request.status().status()); |
| 283 EXPECT_EQ(0, request.status().error()); | 283 EXPECT_EQ(0, request.status().error()); |
| 284 EXPECT_EQ(redirect_url, request.url()); | 284 EXPECT_EQ(redirect_url, request.url()); |
| 285 EXPECT_EQ(2U, request.url_chain().size()); | 285 EXPECT_EQ(2U, request.url_chain().size()); |
| 286 EXPECT_EQ(0U, ipc_sender_.GetNumTasks()); | 286 EXPECT_EQ(0U, ipc_sender_.GetNumTasks()); |
| 287 } | 287 } |
| 288 | 288 |
| 289 // Now test the same thing but the extensions answer in reverse order. | 289 // Now test the same thing but the extensions answer in reverse order. |
| (...skipping 29 matching lines...) Expand all Loading... |
| 319 | 319 |
| 320 // Extension1 response to the redirected URL. Arrives second, and ignored. | 320 // Extension1 response to the redirected URL. Arrives second, and ignored. |
| 321 response = new ExtensionWebRequestEventRouter::EventResponse( | 321 response = new ExtensionWebRequestEventRouter::EventResponse( |
| 322 extension1_id, base::Time::FromDoubleT(1)); | 322 extension1_id, base::Time::FromDoubleT(1)); |
| 323 ipc_sender_.PushTask( | 323 ipc_sender_.PushTask( |
| 324 base::Bind(&EventHandledOnIOThread, | 324 base::Bind(&EventHandledOnIOThread, |
| 325 &profile_, extension1_id, kEventName, kEventName + "/1", | 325 &profile_, extension1_id, kEventName, kEventName + "/1", |
| 326 request2.identifier(), response)); | 326 request2.identifier(), response)); |
| 327 | 327 |
| 328 request2.Start(); | 328 request2.Start(); |
| 329 MessageLoop::current()->Run(); | 329 base::MessageLoop::current()->Run(); |
| 330 | 330 |
| 331 EXPECT_TRUE(!request2.is_pending()); | 331 EXPECT_TRUE(!request2.is_pending()); |
| 332 EXPECT_EQ(net::URLRequestStatus::SUCCESS, request2.status().status()); | 332 EXPECT_EQ(net::URLRequestStatus::SUCCESS, request2.status().status()); |
| 333 EXPECT_EQ(0, request2.status().error()); | 333 EXPECT_EQ(0, request2.status().error()); |
| 334 EXPECT_EQ(redirect_url, request2.url()); | 334 EXPECT_EQ(redirect_url, request2.url()); |
| 335 EXPECT_EQ(2U, request2.url_chain().size()); | 335 EXPECT_EQ(2U, request2.url_chain().size()); |
| 336 EXPECT_EQ(0U, ipc_sender_.GetNumTasks()); | 336 EXPECT_EQ(0U, ipc_sender_.GetNumTasks()); |
| 337 } | 337 } |
| 338 | 338 |
| 339 ExtensionWebRequestEventRouter::GetInstance()->RemoveEventListener( | 339 ExtensionWebRequestEventRouter::GetInstance()->RemoveEventListener( |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 383 response = new ExtensionWebRequestEventRouter::EventResponse( | 383 response = new ExtensionWebRequestEventRouter::EventResponse( |
| 384 extension2_id, base::Time::FromDoubleT(2)); | 384 extension2_id, base::Time::FromDoubleT(2)); |
| 385 response->new_url = redirect_url; | 385 response->new_url = redirect_url; |
| 386 ipc_sender_.PushTask( | 386 ipc_sender_.PushTask( |
| 387 base::Bind(&EventHandledOnIOThread, | 387 base::Bind(&EventHandledOnIOThread, |
| 388 &profile_, extension2_id, kEventName, kEventName + "/2", | 388 &profile_, extension2_id, kEventName, kEventName + "/2", |
| 389 request.identifier(), response)); | 389 request.identifier(), response)); |
| 390 | 390 |
| 391 request.Start(); | 391 request.Start(); |
| 392 | 392 |
| 393 MessageLoop::current()->Run(); | 393 base::MessageLoop::current()->Run(); |
| 394 | 394 |
| 395 EXPECT_TRUE(!request.is_pending()); | 395 EXPECT_TRUE(!request.is_pending()); |
| 396 EXPECT_EQ(net::URLRequestStatus::FAILED, request.status().status()); | 396 EXPECT_EQ(net::URLRequestStatus::FAILED, request.status().status()); |
| 397 EXPECT_EQ(net::ERR_BLOCKED_BY_CLIENT, request.status().error()); | 397 EXPECT_EQ(net::ERR_BLOCKED_BY_CLIENT, request.status().error()); |
| 398 EXPECT_EQ(request_url, request.url()); | 398 EXPECT_EQ(request_url, request.url()); |
| 399 EXPECT_EQ(1U, request.url_chain().size()); | 399 EXPECT_EQ(1U, request.url_chain().size()); |
| 400 EXPECT_EQ(0U, ipc_sender_.GetNumTasks()); | 400 EXPECT_EQ(0U, ipc_sender_.GetNumTasks()); |
| 401 | 401 |
| 402 ExtensionWebRequestEventRouter::GetInstance()->RemoveEventListener( | 402 ExtensionWebRequestEventRouter::GetInstance()->RemoveEventListener( |
| 403 &profile_, extension1_id, kEventName + "/1"); | 403 &profile_, extension1_id, kEventName + "/1"); |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 437 extension_id, base::Time::FromDoubleT(1)); | 437 extension_id, base::Time::FromDoubleT(1)); |
| 438 GURL redirect_url("about:redirected"); | 438 GURL redirect_url("about:redirected"); |
| 439 response->new_url = redirect_url; | 439 response->new_url = redirect_url; |
| 440 ipc_sender_.PushTask( | 440 ipc_sender_.PushTask( |
| 441 base::Bind(&EventHandledOnIOThread, | 441 base::Bind(&EventHandledOnIOThread, |
| 442 &profile_, extension_id, kEventName, kEventName + "/1", | 442 &profile_, extension_id, kEventName, kEventName + "/1", |
| 443 request.identifier(), response)); | 443 request.identifier(), response)); |
| 444 | 444 |
| 445 // Extension response for OnErrorOccurred: Terminate the message loop. | 445 // Extension response for OnErrorOccurred: Terminate the message loop. |
| 446 ipc_sender_.PushTask( | 446 ipc_sender_.PushTask( |
| 447 base::Bind(&MessageLoop::PostTask, | 447 base::Bind(&base::MessageLoop::PostTask, |
| 448 base::Unretained(MessageLoop::current()), | 448 base::Unretained(base::MessageLoop::current()), |
| 449 FROM_HERE, MessageLoop::QuitClosure() | 449 FROM_HERE, |
| 450 )); | 450 base::MessageLoop::QuitClosure())); |
| 451 | 451 |
| 452 request.Start(); | 452 request.Start(); |
| 453 // request.Start() will have submitted OnBeforeRequest by the time we cancel. | 453 // request.Start() will have submitted OnBeforeRequest by the time we cancel. |
| 454 request.Cancel(); | 454 request.Cancel(); |
| 455 MessageLoop::current()->Run(); | 455 base::MessageLoop::current()->Run(); |
| 456 | 456 |
| 457 EXPECT_TRUE(!request.is_pending()); | 457 EXPECT_TRUE(!request.is_pending()); |
| 458 EXPECT_EQ(net::URLRequestStatus::CANCELED, request.status().status()); | 458 EXPECT_EQ(net::URLRequestStatus::CANCELED, request.status().status()); |
| 459 EXPECT_EQ(net::ERR_ABORTED, request.status().error()); | 459 EXPECT_EQ(net::ERR_ABORTED, request.status().error()); |
| 460 EXPECT_EQ(request_url, request.url()); | 460 EXPECT_EQ(request_url, request.url()); |
| 461 EXPECT_EQ(1U, request.url_chain().size()); | 461 EXPECT_EQ(1U, request.url_chain().size()); |
| 462 EXPECT_EQ(0U, ipc_sender_.GetNumTasks()); | 462 EXPECT_EQ(0U, ipc_sender_.GetNumTasks()); |
| 463 | 463 |
| 464 ExtensionWebRequestEventRouter::GetInstance()->RemoveEventListener( | 464 ExtensionWebRequestEventRouter::GetInstance()->RemoveEventListener( |
| 465 &profile_, extension_id, kEventName + "/1"); | 465 &profile_, extension_id, kEventName + "/1"); |
| (...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 609 // Subscribe to OnBeforeRequest with requestBody requirement. | 609 // Subscribe to OnBeforeRequest with requestBody requirement. |
| 610 ASSERT_TRUE(GenerateInfoSpec(string_spec_post, &extra_info_spec_body)); | 610 ASSERT_TRUE(GenerateInfoSpec(string_spec_post, &extra_info_spec_body)); |
| 611 ExtensionWebRequestEventRouter::GetInstance()->AddEventListener( | 611 ExtensionWebRequestEventRouter::GetInstance()->AddEventListener( |
| 612 &profile_, extension_id, extension_id, kEventName, kEventName + "/1", | 612 &profile_, extension_id, extension_id, kEventName, kEventName + "/1", |
| 613 filter, extra_info_spec_body, -1, -1, | 613 filter, extra_info_spec_body, -1, -1, |
| 614 ipc_sender_factory.GetWeakPtr()); | 614 ipc_sender_factory.GetWeakPtr()); |
| 615 | 615 |
| 616 FireURLRequestWithData(kMethodPost, kMultipart, form_1, form_2); | 616 FireURLRequestWithData(kMethodPost, kMultipart, form_1, form_2); |
| 617 | 617 |
| 618 // We inspect the result in the message list of |ipc_sender_| later. | 618 // We inspect the result in the message list of |ipc_sender_| later. |
| 619 MessageLoop::current()->RunUntilIdle(); | 619 base::MessageLoop::current()->RunUntilIdle(); |
| 620 | 620 |
| 621 ExtensionWebRequestEventRouter::GetInstance()->RemoveEventListener( | 621 ExtensionWebRequestEventRouter::GetInstance()->RemoveEventListener( |
| 622 &profile_, extension_id, kEventName + "/1"); | 622 &profile_, extension_id, kEventName + "/1"); |
| 623 | 623 |
| 624 // Part 2. | 624 // Part 2. |
| 625 // Now subscribe to OnBeforeRequest *without* the requestBody requirement. | 625 // Now subscribe to OnBeforeRequest *without* the requestBody requirement. |
| 626 ASSERT_TRUE( | 626 ASSERT_TRUE( |
| 627 GenerateInfoSpec(string_spec_no_post, &extra_info_spec_empty)); | 627 GenerateInfoSpec(string_spec_no_post, &extra_info_spec_empty)); |
| 628 ExtensionWebRequestEventRouter::GetInstance()->AddEventListener( | 628 ExtensionWebRequestEventRouter::GetInstance()->AddEventListener( |
| 629 &profile_, extension_id, extension_id, kEventName, kEventName + "/1", | 629 &profile_, extension_id, extension_id, kEventName, kEventName + "/1", |
| (...skipping 12 matching lines...) Expand all Loading... |
| 642 ipc_sender_factory.GetWeakPtr()); | 642 ipc_sender_factory.GetWeakPtr()); |
| 643 | 643 |
| 644 // Part 3. | 644 // Part 3. |
| 645 // Now send a POST request with body which is not parseable as a form. | 645 // Now send a POST request with body which is not parseable as a form. |
| 646 FireURLRequestWithData(kMethodPost, NULL /*no header*/, plain_1, plain_2); | 646 FireURLRequestWithData(kMethodPost, NULL /*no header*/, plain_1, plain_2); |
| 647 | 647 |
| 648 // Part 4. | 648 // Part 4. |
| 649 // Now send a PUT request with the same body as above. | 649 // Now send a PUT request with the same body as above. |
| 650 FireURLRequestWithData(kMethodPut, NULL /*no header*/, plain_1, plain_2); | 650 FireURLRequestWithData(kMethodPut, NULL /*no header*/, plain_1, plain_2); |
| 651 | 651 |
| 652 MessageLoop::current()->RunUntilIdle(); | 652 base::MessageLoop::current()->RunUntilIdle(); |
| 653 | 653 |
| 654 // Clean-up. | 654 // Clean-up. |
| 655 ExtensionWebRequestEventRouter::GetInstance()->RemoveEventListener( | 655 ExtensionWebRequestEventRouter::GetInstance()->RemoveEventListener( |
| 656 &profile_, extension_id, kEventName + "/1"); | 656 &profile_, extension_id, kEventName + "/1"); |
| 657 | 657 |
| 658 IPC::Message* message = NULL; | 658 IPC::Message* message = NULL; |
| 659 TestIPCSender::SentMessages::const_iterator i = ipc_sender_.sent_begin(); | 659 TestIPCSender::SentMessages::const_iterator i = ipc_sender_.sent_begin(); |
| 660 for (size_t test = 0; test < arraysize(kExpected); ++test) { | 660 for (size_t test = 0; test < arraysize(kExpected); ++test) { |
| 661 SCOPED_TRACE(testing::Message("iteration number ") << test); | 661 SCOPED_TRACE(testing::Message("iteration number ") << test); |
| 662 EXPECT_NE(i, ipc_sender_.sent_end()); | 662 EXPECT_NE(i, ipc_sender_.sent_end()); |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 703 const GURL request_url("http://www.example.com"); | 703 const GURL request_url("http://www.example.com"); |
| 704 | 704 |
| 705 for (size_t i = 0; i < arraysize(kMethods); ++i) { | 705 for (size_t i = 0; i < arraysize(kMethods); ++i) { |
| 706 net::URLRequest request(request_url, &delegate_, context_.get()); | 706 net::URLRequest request(request_url, &delegate_, context_.get()); |
| 707 request.set_method(kMethods[i]); | 707 request.set_method(kMethods[i]); |
| 708 ipc_sender_.PushTask(base::Bind(&base::DoNothing)); | 708 ipc_sender_.PushTask(base::Bind(&base::DoNothing)); |
| 709 request.Start(); | 709 request.Start(); |
| 710 } | 710 } |
| 711 | 711 |
| 712 // We inspect the result in the message list of |ipc_sender_| later. | 712 // We inspect the result in the message list of |ipc_sender_| later. |
| 713 MessageLoop::current()->RunUntilIdle(); | 713 base::MessageLoop::current()->RunUntilIdle(); |
| 714 | 714 |
| 715 ExtensionWebRequestEventRouter::GetInstance()->RemoveEventListener( | 715 ExtensionWebRequestEventRouter::GetInstance()->RemoveEventListener( |
| 716 &profile_, extension_id, kEventName + "/1"); | 716 &profile_, extension_id, kEventName + "/1"); |
| 717 | 717 |
| 718 TestIPCSender::SentMessages::const_iterator i = ipc_sender_.sent_begin(); | 718 TestIPCSender::SentMessages::const_iterator i = ipc_sender_.sent_begin(); |
| 719 for (size_t test = 0; test < arraysize(kMethods); ++test, ++i) { | 719 for (size_t test = 0; test < arraysize(kMethods); ++test, ++i) { |
| 720 SCOPED_TRACE(testing::Message("iteration number ") << test); | 720 SCOPED_TRACE(testing::Message("iteration number ") << test); |
| 721 EXPECT_NE(i, ipc_sender_.sent_end()); | 721 EXPECT_NE(i, ipc_sender_.sent_end()); |
| 722 IPC::Message* message = i->get(); | 722 IPC::Message* message = i->get(); |
| 723 const DictionaryValue* details = NULL; | 723 const DictionaryValue* details = NULL; |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 776 network_delegate_->set_cookie_settings( | 776 network_delegate_->set_cookie_settings( |
| 777 CookieSettings::Factory::GetForProfile(&profile_)); | 777 CookieSettings::Factory::GetForProfile(&profile_)); |
| 778 context_.reset(new net::TestURLRequestContext(true)); | 778 context_.reset(new net::TestURLRequestContext(true)); |
| 779 host_resolver_.reset(new net::MockHostResolver()); | 779 host_resolver_.reset(new net::MockHostResolver()); |
| 780 host_resolver_->rules()->AddSimulatedFailure("doesnotexist"); | 780 host_resolver_->rules()->AddSimulatedFailure("doesnotexist"); |
| 781 context_->set_host_resolver(host_resolver_.get()); | 781 context_->set_host_resolver(host_resolver_.get()); |
| 782 context_->set_network_delegate(network_delegate_.get()); | 782 context_->set_network_delegate(network_delegate_.get()); |
| 783 context_->Init(); | 783 context_->Init(); |
| 784 } | 784 } |
| 785 | 785 |
| 786 MessageLoopForIO message_loop_; | 786 base::MessageLoopForIO message_loop_; |
| 787 content::TestBrowserThread ui_thread_; | 787 content::TestBrowserThread ui_thread_; |
| 788 content::TestBrowserThread io_thread_; | 788 content::TestBrowserThread io_thread_; |
| 789 TestingProfile profile_; | 789 TestingProfile profile_; |
| 790 TestingProfileManager profile_manager_; | 790 TestingProfileManager profile_manager_; |
| 791 net::TestDelegate delegate_; | 791 net::TestDelegate delegate_; |
| 792 BooleanPrefMember enable_referrers_; | 792 BooleanPrefMember enable_referrers_; |
| 793 TestIPCSender ipc_sender_; | 793 TestIPCSender ipc_sender_; |
| 794 scoped_refptr<EventRouterForwarder> event_router_; | 794 scoped_refptr<EventRouterForwarder> event_router_; |
| 795 scoped_refptr<ExtensionInfoMap> extension_info_map_; | 795 scoped_refptr<ExtensionInfoMap> extension_info_map_; |
| 796 scoped_ptr<ChromeNetworkDelegate> network_delegate_; | 796 scoped_ptr<ChromeNetworkDelegate> network_delegate_; |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 874 // Don't do anything for the onSendHeaders message. | 874 // Don't do anything for the onSendHeaders message. |
| 875 ipc_sender_.PushTask(base::Bind(&base::DoNothing)); | 875 ipc_sender_.PushTask(base::Bind(&base::DoNothing)); |
| 876 | 876 |
| 877 // Note that we mess up the headers slightly: | 877 // Note that we mess up the headers slightly: |
| 878 // request.Start() will first add additional headers (e.g. the User-Agent) | 878 // request.Start() will first add additional headers (e.g. the User-Agent) |
| 879 // and then send an event to the extension. When we have prepared our | 879 // and then send an event to the extension. When we have prepared our |
| 880 // answers to the onBeforeSendHeaders events above, these headers did not | 880 // answers to the onBeforeSendHeaders events above, these headers did not |
| 881 // exists and are therefore not listed in the responses. This makes | 881 // exists and are therefore not listed in the responses. This makes |
| 882 // them seem deleted. | 882 // them seem deleted. |
| 883 request.Start(); | 883 request.Start(); |
| 884 MessageLoop::current()->Run(); | 884 base::MessageLoop::current()->Run(); |
| 885 | 885 |
| 886 EXPECT_TRUE(!request.is_pending()); | 886 EXPECT_TRUE(!request.is_pending()); |
| 887 // This cannot succeed as we send the request to a server that does not exist. | 887 // This cannot succeed as we send the request to a server that does not exist. |
| 888 EXPECT_EQ(net::URLRequestStatus::FAILED, request.status().status()); | 888 EXPECT_EQ(net::URLRequestStatus::FAILED, request.status().status()); |
| 889 EXPECT_EQ(request_url, request.url()); | 889 EXPECT_EQ(request_url, request.url()); |
| 890 EXPECT_EQ(1U, request.url_chain().size()); | 890 EXPECT_EQ(1U, request.url_chain().size()); |
| 891 EXPECT_EQ(0U, ipc_sender_.GetNumTasks()); | 891 EXPECT_EQ(0U, ipc_sender_.GetNumTasks()); |
| 892 | 892 |
| 893 // Calculate the expected headers. | 893 // Calculate the expected headers. |
| 894 net::HttpRequestHeaders expected_headers; | 894 net::HttpRequestHeaders expected_headers; |
| (...skipping 1231 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2126 EXPECT_TRUE(credentials_set); | 2126 EXPECT_TRUE(credentials_set); |
| 2127 EXPECT_FALSE(auth3.Empty()); | 2127 EXPECT_FALSE(auth3.Empty()); |
| 2128 EXPECT_EQ(username, auth1.username()); | 2128 EXPECT_EQ(username, auth1.username()); |
| 2129 EXPECT_EQ(password, auth1.password()); | 2129 EXPECT_EQ(password, auth1.password()); |
| 2130 EXPECT_EQ(1u, warning_set.size()); | 2130 EXPECT_EQ(1u, warning_set.size()); |
| 2131 EXPECT_TRUE(HasWarning(warning_set, "extid2")); | 2131 EXPECT_TRUE(HasWarning(warning_set, "extid2")); |
| 2132 EXPECT_EQ(3u, capturing_net_log.GetSize()); | 2132 EXPECT_EQ(3u, capturing_net_log.GetSize()); |
| 2133 } | 2133 } |
| 2134 | 2134 |
| 2135 } // namespace extensions | 2135 } // namespace extensions |
| OLD | NEW |