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

Side by Side Diff: chrome/browser/extensions/extension_webrequest_api_unittest.cc

Issue 7523042: Add a status message "Waiting for extension Foo..." when there's a request (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: final Created 9 years, 4 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 <queue> 5 #include <queue>
6 6
7 #include "base/file_util.h" 7 #include "base/file_util.h"
8 #include "base/path_service.h" 8 #include "base/path_service.h"
9 9
10 #include "chrome/browser/extensions/extension_event_router_forwarder.h" 10 #include "chrome/browser/extensions/extension_event_router_forwarder.h"
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
104 // Tests that we handle disagreements among extensions about responses to 104 // Tests that we handle disagreements among extensions about responses to
105 // blocking events (redirection) by choosing the response from the 105 // blocking events (redirection) by choosing the response from the
106 // most-recently-installed extension. 106 // most-recently-installed extension.
107 TEST_F(ExtensionWebRequestTest, BlockingEventPrecedenceRedirect) { 107 TEST_F(ExtensionWebRequestTest, BlockingEventPrecedenceRedirect) {
108 std::string extension1_id("1"); 108 std::string extension1_id("1");
109 std::string extension2_id("2"); 109 std::string extension2_id("2");
110 ExtensionWebRequestEventRouter::RequestFilter filter; 110 ExtensionWebRequestEventRouter::RequestFilter filter;
111 const std::string kEventName(keys::kOnBeforeRequest); 111 const std::string kEventName(keys::kOnBeforeRequest);
112 base::WeakPtrFactory<TestIPCSender> ipc_sender_factory(&ipc_sender_); 112 base::WeakPtrFactory<TestIPCSender> ipc_sender_factory(&ipc_sender_);
113 ExtensionWebRequestEventRouter::GetInstance()->AddEventListener( 113 ExtensionWebRequestEventRouter::GetInstance()->AddEventListener(
114 &profile_, extension1_id, kEventName, kEventName + "/1", filter, 114 &profile_, extension1_id, extension1_id, kEventName, kEventName + "/1",
115 ExtensionWebRequestEventRouter::ExtraInfoSpec::BLOCKING, 115 filter, ExtensionWebRequestEventRouter::ExtraInfoSpec::BLOCKING,
116 ipc_sender_factory.GetWeakPtr()); 116 ipc_sender_factory.GetWeakPtr());
117 ExtensionWebRequestEventRouter::GetInstance()->AddEventListener( 117 ExtensionWebRequestEventRouter::GetInstance()->AddEventListener(
118 &profile_, extension2_id, kEventName, kEventName + "/2", filter, 118 &profile_, extension2_id, extension2_id, kEventName, kEventName + "/2",
119 ExtensionWebRequestEventRouter::ExtraInfoSpec::BLOCKING, 119 filter, ExtensionWebRequestEventRouter::ExtraInfoSpec::BLOCKING,
120 ipc_sender_factory.GetWeakPtr()); 120 ipc_sender_factory.GetWeakPtr());
121 121
122 GURL redirect_url("about:redirected"); 122 GURL redirect_url("about:redirected");
123 GURL not_chosen_redirect_url("about:not_chosen"); 123 GURL not_chosen_redirect_url("about:not_chosen");
124 124
125 net::URLRequest request(GURL("about:blank"), &delegate_); 125 net::URLRequest request(GURL("about:blank"), &delegate_);
126 request.set_context(context_); 126 request.set_context(context_);
127 { 127 {
128 // onBeforeRequest will be dispatched twice initially. The second response - 128 // onBeforeRequest will be dispatched twice initially. The second response -
129 // the redirect - should win, since it has a later |install_time|. The 129 // the redirect - should win, since it has a later |install_time|. The
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
235 235
236 // Test that a request is canceled if this is requested by any extension 236 // Test that a request is canceled if this is requested by any extension
237 // regardless whether it is the extension with the highest precedence. 237 // regardless whether it is the extension with the highest precedence.
238 TEST_F(ExtensionWebRequestTest, BlockingEventPrecedenceCancel) { 238 TEST_F(ExtensionWebRequestTest, BlockingEventPrecedenceCancel) {
239 std::string extension1_id("1"); 239 std::string extension1_id("1");
240 std::string extension2_id("2"); 240 std::string extension2_id("2");
241 ExtensionWebRequestEventRouter::RequestFilter filter; 241 ExtensionWebRequestEventRouter::RequestFilter filter;
242 const std::string kEventName(keys::kOnBeforeRequest); 242 const std::string kEventName(keys::kOnBeforeRequest);
243 base::WeakPtrFactory<TestIPCSender> ipc_sender_factory(&ipc_sender_); 243 base::WeakPtrFactory<TestIPCSender> ipc_sender_factory(&ipc_sender_);
244 ExtensionWebRequestEventRouter::GetInstance()->AddEventListener( 244 ExtensionWebRequestEventRouter::GetInstance()->AddEventListener(
245 &profile_, extension1_id, kEventName, kEventName + "/1", filter, 245 &profile_, extension1_id, extension1_id, kEventName, kEventName + "/1",
246 ExtensionWebRequestEventRouter::ExtraInfoSpec::BLOCKING, 246 filter, ExtensionWebRequestEventRouter::ExtraInfoSpec::BLOCKING,
247 ipc_sender_factory.GetWeakPtr()); 247 ipc_sender_factory.GetWeakPtr());
248 ExtensionWebRequestEventRouter::GetInstance()->AddEventListener( 248 ExtensionWebRequestEventRouter::GetInstance()->AddEventListener(
249 &profile_, extension2_id, kEventName, kEventName + "/2", filter, 249 &profile_, extension2_id, extension2_id, kEventName, kEventName + "/2",
250 ExtensionWebRequestEventRouter::ExtraInfoSpec::BLOCKING, 250 filter, ExtensionWebRequestEventRouter::ExtraInfoSpec::BLOCKING,
251 ipc_sender_factory.GetWeakPtr()); 251 ipc_sender_factory.GetWeakPtr());
252 252
253 GURL request_url("about:blank"); 253 GURL request_url("about:blank");
254 net::URLRequest request(request_url, &delegate_); 254 net::URLRequest request(request_url, &delegate_);
255 request.set_context(context_); 255 request.set_context(context_);
256 256
257 // onBeforeRequest will be dispatched twice. The second response - 257 // onBeforeRequest will be dispatched twice. The second response -
258 // the redirect - would win, since it has a later |install_time|, but 258 // the redirect - would win, since it has a later |install_time|, but
259 // the first response takes precedence because cancel >> redirect. 259 // the first response takes precedence because cancel >> redirect.
260 GURL redirect_url("about:redirected"); 260 GURL redirect_url("about:redirected");
261 ExtensionWebRequestEventRouter::EventResponse* response = NULL; 261 ExtensionWebRequestEventRouter::EventResponse* response = NULL;
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
356 std::string extension1_id("1"); 356 std::string extension1_id("1");
357 std::string extension2_id("2"); 357 std::string extension2_id("2");
358 std::string extension3_id("3"); 358 std::string extension3_id("3");
359 ExtensionWebRequestEventRouter::RequestFilter filter; 359 ExtensionWebRequestEventRouter::RequestFilter filter;
360 const std::string kEventName(keys::kOnBeforeSendHeaders); 360 const std::string kEventName(keys::kOnBeforeSendHeaders);
361 base::WeakPtrFactory<TestIPCSender> ipc_sender_factory(&ipc_sender_); 361 base::WeakPtrFactory<TestIPCSender> ipc_sender_factory(&ipc_sender_);
362 362
363 // Install two extensions that can modify headers. Extension 2 has 363 // Install two extensions that can modify headers. Extension 2 has
364 // higher precedence than extension 1. 364 // higher precedence than extension 1.
365 ExtensionWebRequestEventRouter::GetInstance()->AddEventListener( 365 ExtensionWebRequestEventRouter::GetInstance()->AddEventListener(
366 &profile_, extension1_id, kEventName, kEventName + "/1", filter, 366 &profile_, extension1_id, extension1_id, kEventName, kEventName + "/1",
367 ExtensionWebRequestEventRouter::ExtraInfoSpec::BLOCKING, 367 filter, ExtensionWebRequestEventRouter::ExtraInfoSpec::BLOCKING,
368 ipc_sender_factory.GetWeakPtr()); 368 ipc_sender_factory.GetWeakPtr());
369 ExtensionWebRequestEventRouter::GetInstance()->AddEventListener( 369 ExtensionWebRequestEventRouter::GetInstance()->AddEventListener(
370 &profile_, extension2_id, kEventName, kEventName + "/2", filter, 370 &profile_, extension2_id, extension2_id, kEventName, kEventName + "/2",
371 ExtensionWebRequestEventRouter::ExtraInfoSpec::BLOCKING, 371 filter, ExtensionWebRequestEventRouter::ExtraInfoSpec::BLOCKING,
372 ipc_sender_factory.GetWeakPtr()); 372 ipc_sender_factory.GetWeakPtr());
373 373
374 // Install one extension that observes the final headers. 374 // Install one extension that observes the final headers.
375 ExtensionWebRequestEventRouter::GetInstance()->AddEventListener( 375 ExtensionWebRequestEventRouter::GetInstance()->AddEventListener(
376 &profile_, extension3_id, keys::kOnSendHeaders, 376 &profile_, extension3_id, extension3_id, keys::kOnSendHeaders,
377 std::string(keys::kOnSendHeaders) + "/3", filter, 377 std::string(keys::kOnSendHeaders) + "/3", filter,
378 ExtensionWebRequestEventRouter::ExtraInfoSpec::REQUEST_HEADERS, 378 ExtensionWebRequestEventRouter::ExtraInfoSpec::REQUEST_HEADERS,
379 ipc_sender_factory.GetWeakPtr()); 379 ipc_sender_factory.GetWeakPtr());
380 380
381 GURL request_url("http://doesnotexist/does_not_exist.html"); 381 GURL request_url("http://doesnotexist/does_not_exist.html");
382 net::URLRequest request(request_url, &delegate_); 382 net::URLRequest request(request_url, &delegate_);
383 request.set_context(context_); 383 request.set_context(context_);
384 384
385 // Initialize headers available before extensions are notified of the 385 // Initialize headers available before extensions are notified of the
386 // onBeforeSendHeaders event. 386 // onBeforeSendHeaders event.
(...skipping 258 matching lines...) Expand 10 before | Expand all | Expand 10 after
645 {"header2", "bar"} } 645 {"header2", "bar"} }
646 }, 646 },
647 }; 647 };
648 648
649 INSTANTIATE_TEST_CASE_P( 649 INSTANTIATE_TEST_CASE_P(
650 ExtensionWebRequest, 650 ExtensionWebRequest,
651 ExtensionWebRequestHeaderModificationTest, 651 ExtensionWebRequestHeaderModificationTest,
652 ::testing::ValuesIn(kTests)); 652 ::testing::ValuesIn(kTests));
653 653
654 } // namespace 654 } // namespace
OLDNEW
« no previous file with comments | « chrome/browser/extensions/extension_webrequest_api.cc ('k') | chrome/browser/ui/tab_contents/tab_contents_wrapper.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698