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 <string> | 5 #include <string> |
6 | 6 |
7 #include "base/file_util.h" | 7 #include "base/file_util.h" |
8 #include "base/message_loop/message_loop.h" | 8 #include "base/message_loop/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 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
79 scoped_refptr<Extension> extension( | 79 scoped_refptr<Extension> extension( |
80 Extension::Create(path, Manifest::UNPACKED, manifest, | 80 Extension::Create(path, Manifest::UNPACKED, manifest, |
81 Extension::NO_FLAGS, &error)); | 81 Extension::NO_FLAGS, &error)); |
82 EXPECT_TRUE(extension.get()) << error; | 82 EXPECT_TRUE(extension.get()) << error; |
83 return extension; | 83 return extension; |
84 } | 84 } |
85 | 85 |
86 class ExtensionProtocolTest : public testing::Test { | 86 class ExtensionProtocolTest : public testing::Test { |
87 public: | 87 public: |
88 ExtensionProtocolTest() | 88 ExtensionProtocolTest() |
89 : thread_bundle_(content::TestBrowserThreadBundle::IO_MAINLOOP) {} | 89 : thread_bundle_(content::TestBrowserThreadBundle::IO_MAINLOOP), |
| 90 resource_context_(&test_url_request_context_) {} |
90 | 91 |
91 virtual void SetUp() OVERRIDE { | 92 virtual void SetUp() OVERRIDE { |
92 testing::Test::SetUp(); | 93 testing::Test::SetUp(); |
93 extension_info_map_ = new ExtensionInfoMap(); | 94 extension_info_map_ = new ExtensionInfoMap(); |
94 net::URLRequestContext* request_context = | 95 net::URLRequestContext* request_context = |
95 resource_context_.GetRequestContext(); | 96 resource_context_.GetRequestContext(); |
96 old_factory_ = request_context->job_factory(); | 97 old_factory_ = request_context->job_factory(); |
97 } | 98 } |
98 | 99 |
99 virtual void TearDown() { | 100 virtual void TearDown() { |
(...skipping 21 matching lines...) Expand all Loading... |
121 request->Start(); | 122 request->Start(); |
122 base::MessageLoop::current()->Run(); | 123 base::MessageLoop::current()->Run(); |
123 } | 124 } |
124 | 125 |
125 protected: | 126 protected: |
126 content::TestBrowserThreadBundle thread_bundle_; | 127 content::TestBrowserThreadBundle thread_bundle_; |
127 scoped_refptr<ExtensionInfoMap> extension_info_map_; | 128 scoped_refptr<ExtensionInfoMap> extension_info_map_; |
128 net::URLRequestJobFactoryImpl job_factory_; | 129 net::URLRequestJobFactoryImpl job_factory_; |
129 const net::URLRequestJobFactory* old_factory_; | 130 const net::URLRequestJobFactory* old_factory_; |
130 net::TestDelegate test_delegate_; | 131 net::TestDelegate test_delegate_; |
| 132 net::TestURLRequestContext test_url_request_context_; |
131 content::MockResourceContext resource_context_; | 133 content::MockResourceContext resource_context_; |
132 }; | 134 }; |
133 | 135 |
134 // Tests that making a chrome-extension request in an incognito context is | 136 // Tests that making a chrome-extension request in an incognito context is |
135 // only allowed under the right circumstances (if the extension is allowed | 137 // only allowed under the right circumstances (if the extension is allowed |
136 // in incognito, and it's either a non-main-frame request or a split-mode | 138 // in incognito, and it's either a non-main-frame request or a split-mode |
137 // extension). | 139 // extension). |
138 TEST_F(ExtensionProtocolTest, IncognitoRequest) { | 140 TEST_F(ExtensionProtocolTest, IncognitoRequest) { |
139 // Register an incognito extension protocol handler. | 141 // Register an incognito extension protocol handler. |
140 SetProtocolHandler(true); | 142 SetProtocolHandler(true); |
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
258 | 260 |
259 // We set test.dat as web-accessible, so it should have a CORS header. | 261 // We set test.dat as web-accessible, so it should have a CORS header. |
260 std::string access_control; | 262 std::string access_control; |
261 request.GetResponseHeaderByName("Access-Control-Allow-Origin", | 263 request.GetResponseHeaderByName("Access-Control-Allow-Origin", |
262 &access_control); | 264 &access_control); |
263 EXPECT_EQ("*", access_control); | 265 EXPECT_EQ("*", access_control); |
264 } | 266 } |
265 } | 267 } |
266 | 268 |
267 } // namespace extensions | 269 } // namespace extensions |
OLD | NEW |