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

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

Issue 15984016: Call scoped_refptr<T>::get() rather than relying on implicit "operator T*" (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebased Created 7 years, 6 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) 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 <string> 5 #include <string>
6 6
7 #include "base/file_util.h" 7 #include "base/file_util.h"
8 #include "base/message_loop.h" 8 #include "base/message_loop.h"
9 #include "base/strings/string_util.h" 9 #include "base/strings/string_util.h"
10 #include "base/values.h" 10 #include "base/values.h"
(...skipping 219 matching lines...) Expand 10 before | Expand all | Expand 10 after
230 } 230 }
231 } 231 }
232 232
233 // Tests that a URL request for resource from an extension returns a few 233 // Tests that a URL request for resource from an extension returns a few
234 // expected response headers. 234 // expected response headers.
235 TEST_F(ExtensionProtocolTest, ResourceRequestResponseHeaders) { 235 TEST_F(ExtensionProtocolTest, ResourceRequestResponseHeaders) {
236 // Register a non-incognito extension protocol handler. 236 // Register a non-incognito extension protocol handler.
237 SetProtocolHandler(false); 237 SetProtocolHandler(false);
238 238
239 scoped_refptr<Extension> extension = CreateTestResponseHeaderExtension(); 239 scoped_refptr<Extension> extension = CreateTestResponseHeaderExtension();
240 extension_info_map_->AddExtension(extension, base::Time::Now(), false); 240 extension_info_map_->AddExtension(extension.get(), base::Time::Now(), false);
241 241
242 { 242 {
243 net::URLRequest request(extension->GetResourceURL("test.dat"), 243 net::URLRequest request(extension->GetResourceURL("test.dat"),
244 &test_delegate_, 244 &test_delegate_,
245 resource_context_.GetRequestContext()); 245 resource_context_.GetRequestContext());
246 StartRequest(&request, ResourceType::MEDIA); 246 StartRequest(&request, ResourceType::MEDIA);
247 EXPECT_EQ(net::URLRequestStatus::SUCCESS, request.status().status()); 247 EXPECT_EQ(net::URLRequestStatus::SUCCESS, request.status().status());
248 248
249 // Check that cache-related headers are set. 249 // Check that cache-related headers are set.
250 std::string etag; 250 std::string etag;
251 request.GetResponseHeaderByName("ETag", &etag); 251 request.GetResponseHeaderByName("ETag", &etag);
252 EXPECT_TRUE(StartsWithASCII(etag, "\"", false)); 252 EXPECT_TRUE(StartsWithASCII(etag, "\"", false));
253 EXPECT_TRUE(EndsWith(etag, "\"", false)); 253 EXPECT_TRUE(EndsWith(etag, "\"", false));
254 254
255 std::string revalidation_header; 255 std::string revalidation_header;
256 request.GetResponseHeaderByName("cache-control", &revalidation_header); 256 request.GetResponseHeaderByName("cache-control", &revalidation_header);
257 EXPECT_EQ("no-cache", revalidation_header); 257 EXPECT_EQ("no-cache", revalidation_header);
258 258
259 // We set test.dat as web-accessible, so it should have a CORS header. 259 // We set test.dat as web-accessible, so it should have a CORS header.
260 std::string access_control; 260 std::string access_control;
261 request.GetResponseHeaderByName("Access-Control-Allow-Origin", 261 request.GetResponseHeaderByName("Access-Control-Allow-Origin",
262 &access_control); 262 &access_control);
263 EXPECT_EQ("*", access_control); 263 EXPECT_EQ("*", access_control);
264 } 264 }
265 } 265 }
266 266
267 } // namespace extensions 267 } // namespace extensions
OLDNEW
« no previous file with comments | « chrome/browser/extensions/extension_process_manager.cc ('k') | chrome/browser/extensions/extension_service.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698