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

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

Issue 2771953003: Fix content verification code for undreadable and deleted files. (Closed)
Patch Set: . Created 3 years, 9 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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 6
7 #include <memory> 7 #include <memory>
8 #include <string> 8 #include <string>
9 9
10 #include "base/command_line.h"
10 #include "base/files/file_util.h" 11 #include "base/files/file_util.h"
11 #include "base/macros.h" 12 #include "base/macros.h"
12 #include "base/message_loop/message_loop.h"
13 #include "base/run_loop.h" 13 #include "base/run_loop.h"
14 #include "base/strings/string_number_conversions.h" 14 #include "base/strings/string_number_conversions.h"
15 #include "base/strings/string_util.h" 15 #include "base/strings/string_util.h"
16 #include "base/test/test_file_util.h"
16 #include "base/values.h" 17 #include "base/values.h"
18 #include "chrome/browser/extensions/chrome_content_verifier_delegate.h"
17 #include "chrome/common/chrome_paths.h" 19 #include "chrome/common/chrome_paths.h"
20 #include "chrome/common/chrome_switches.h"
21 #include "chrome/test/base/testing_profile.h"
22 #include "components/crx_file/id_util.h"
18 #include "content/public/browser/resource_request_info.h" 23 #include "content/public/browser/resource_request_info.h"
19 #include "content/public/common/browser_side_navigation_policy.h" 24 #include "content/public/common/browser_side_navigation_policy.h"
20 #include "content/public/common/previews_state.h" 25 #include "content/public/common/previews_state.h"
21 #include "content/public/test/mock_resource_context.h" 26 #include "content/public/test/mock_resource_context.h"
22 #include "content/public/test/test_browser_thread_bundle.h" 27 #include "content/public/test/test_browser_thread_bundle.h"
28 #include "content/public/test/test_utils.h"
29 #include "extensions/browser/content_verifier.h"
23 #include "extensions/browser/extension_protocols.h" 30 #include "extensions/browser/extension_protocols.h"
24 #include "extensions/browser/info_map.h" 31 #include "extensions/browser/info_map.h"
25 #include "extensions/common/constants.h" 32 #include "extensions/common/constants.h"
26 #include "extensions/common/extension.h" 33 #include "extensions/common/extension.h"
34 #include "extensions/common/extension_builder.h"
27 #include "extensions/common/file_util.h" 35 #include "extensions/common/file_util.h"
28 #include "net/base/request_priority.h" 36 #include "net/base/request_priority.h"
29 #include "net/url_request/url_request.h" 37 #include "net/url_request/url_request.h"
30 #include "net/url_request/url_request_job_factory_impl.h" 38 #include "net/url_request/url_request_job_factory_impl.h"
31 #include "net/url_request/url_request_status.h" 39 #include "net/url_request/url_request_status.h"
32 #include "net/url_request/url_request_test_util.h" 40 #include "net/url_request/url_request_test_util.h"
33 #include "testing/gtest/include/gtest/gtest.h" 41 #include "testing/gtest/include/gtest/gtest.h"
34 42
35 using content::ResourceType; 43 using content::ResourceType;
36 44
37 namespace extensions { 45 namespace extensions {
38 namespace { 46 namespace {
39 47
40 base::FilePath GetTestPath(const std::string& name) { 48 base::FilePath GetTestPath(const std::string& name) {
41 base::FilePath path; 49 base::FilePath path;
42 EXPECT_TRUE(PathService::Get(chrome::DIR_TEST_DATA, &path)); 50 EXPECT_TRUE(PathService::Get(chrome::DIR_TEST_DATA, &path));
43 return path.AppendASCII("extensions").AppendASCII(name); 51 return path.AppendASCII("extensions").AppendASCII(name);
44 } 52 }
45 53
54 // Helper function that creates a file at |relative_path| within |directory|
55 // and fills it with |content|.
56 bool AddFileToDirectory(const base::FilePath& directory,
57 const base::FilePath& relative_path,
58 const std::string& content) {
59 base::FilePath full_path = directory.Append(relative_path);
60 int result = base::WriteFile(full_path, content.data(), content.size());
61 return (static_cast<size_t>(result) == content.size());
Devlin 2017/03/24 18:50:09 nit: wrapping parens unnecessary
lazyboy 2017/03/24 19:22:54 Done.
62 }
63
46 scoped_refptr<Extension> CreateTestExtension(const std::string& name, 64 scoped_refptr<Extension> CreateTestExtension(const std::string& name,
47 bool incognito_split_mode) { 65 bool incognito_split_mode) {
48 base::DictionaryValue manifest; 66 base::DictionaryValue manifest;
49 manifest.SetString("name", name); 67 manifest.SetString("name", name);
50 manifest.SetString("version", "1"); 68 manifest.SetString("version", "1");
51 manifest.SetInteger("manifest_version", 2); 69 manifest.SetInteger("manifest_version", 2);
52 manifest.SetString("incognito", incognito_split_mode ? "split" : "spanning"); 70 manifest.SetString("incognito", incognito_split_mode ? "split" : "spanning");
53 71
54 base::FilePath path = GetTestPath("response_headers"); 72 base::FilePath path = GetTestPath("response_headers");
55 73
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
91 base::FilePath path = GetTestPath("response_headers"); 109 base::FilePath path = GetTestPath("response_headers");
92 110
93 std::string error; 111 std::string error;
94 scoped_refptr<Extension> extension( 112 scoped_refptr<Extension> extension(
95 Extension::Create(path, Manifest::UNPACKED, manifest, 113 Extension::Create(path, Manifest::UNPACKED, manifest,
96 Extension::NO_FLAGS, &error)); 114 Extension::NO_FLAGS, &error));
97 EXPECT_TRUE(extension.get()) << error; 115 EXPECT_TRUE(extension.get()) << error;
98 return extension; 116 return extension;
99 } 117 }
100 118
119 // A ContentVerifyJob::TestDelegate that observes DoneReading().
120 class JobDelegate : public ContentVerifyJob::TestDelegate {
121 public:
122 explicit JobDelegate(const std::string& expected_contents)
123 : expected_contents_(expected_contents) {}
124 ~JobDelegate() override {}
125
126 ContentVerifyJob::FailureReason BytesRead(const ExtensionId& id,
127 int count,
128 const char* data) override {
129 read_contents_.append(data, count);
130 return ContentVerifyJob::NONE;
131 }
132
133 ContentVerifyJob::FailureReason DoneReading(const ExtensionId& id) override {
134 seen_done_reading_extension_ids_.insert(id);
135 if (waiting_for_extension_id_ == id)
136 run_loop_.Quit();
137
138 if (!base::StartsWith(expected_contents_, read_contents_,
139 base::CompareCase::SENSITIVE)) {
140 ADD_FAILURE() << "Unexpected read, expected: " << expected_contents_
141 << ", but found: " << read_contents_;
142 }
143 return ContentVerifyJob::NONE;
144 }
145
146 void WaitForDoneReading(const ExtensionId& id) {
147 ASSERT_FALSE(waiting_for_extension_id_);
148 if (seen_done_reading_extension_ids_.count(id))
Devlin 2017/03/24 18:50:09 This is actually unnecessary, since RunLoop::Run()
lazyboy 2017/03/24 19:22:53 Assigning waiting_for_extension_id_ in that case s
149 return;
150 waiting_for_extension_id_ = id;
151 run_loop_.Run();
152 }
153
154 void Reset() {
Devlin 2017/03/24 18:50:09 And since Quit() can have preemptive effects, we n
lazyboy 2017/03/24 19:22:52 Added new RunLoop here. Done.
155 read_contents_.clear();
156 waiting_for_extension_id_.reset();
157 seen_done_reading_extension_ids_.clear();
158 }
159
160 private:
161 std::string expected_contents_;
162 std::string read_contents_;
163 std::set<ExtensionId> seen_done_reading_extension_ids_;
164 base::Optional<ExtensionId> waiting_for_extension_id_;
165 base::RunLoop run_loop_;
166
167 DISALLOW_COPY_AND_ASSIGN(JobDelegate);
168 };
169
170 class ScopedVerifyJobDelegateOverride {
Devlin 2017/03/24 18:50:09 Optional: is there a reason to not just have JobDe
lazyboy 2017/03/24 19:22:54 Ah thanks, fixed.
171 public:
172 explicit ScopedVerifyJobDelegateOverride(const std::string& expected_content)
173 : delegate_(expected_content) {
174 ContentVerifyJob::SetDelegateForTests(&delegate_);
175 }
176 ~ScopedVerifyJobDelegateOverride() {
177 ContentVerifyJob::SetDelegateForTests(nullptr);
178 }
179
180 JobDelegate* delegate() { return &delegate_; }
181
182 private:
183 JobDelegate delegate_;
184
185 DISALLOW_COPY_AND_ASSIGN(ScopedVerifyJobDelegateOverride);
186 };
187
101 } // namespace 188 } // namespace
102 189
103 // This test lives in src/chrome instead of src/extensions because it tests 190 // This test lives in src/chrome instead of src/extensions because it tests
104 // functionality delegated back to Chrome via ChromeExtensionsBrowserClient. 191 // functionality delegated back to Chrome via ChromeExtensionsBrowserClient.
105 // See chrome/browser/extensions/chrome_url_request_util.cc. 192 // See chrome/browser/extensions/chrome_url_request_util.cc.
106 class ExtensionProtocolTest : public testing::Test { 193 class ExtensionProtocolsTest : public testing::Test {
107 public: 194 public:
108 ExtensionProtocolTest() 195 ExtensionProtocolsTest()
109 : thread_bundle_(content::TestBrowserThreadBundle::IO_MAINLOOP), 196 : thread_bundle_(content::TestBrowserThreadBundle::IO_MAINLOOP),
110 old_factory_(NULL), 197 old_factory_(NULL),
111 resource_context_(&test_url_request_context_) {} 198 resource_context_(&test_url_request_context_) {}
112 199
113 void SetUp() override { 200 void SetUp() override {
114 testing::Test::SetUp(); 201 testing::Test::SetUp();
202 testing_profile_ = TestingProfile::Builder().Build();
115 extension_info_map_ = new InfoMap(); 203 extension_info_map_ = new InfoMap();
116 net::URLRequestContext* request_context = 204 net::URLRequestContext* request_context =
117 resource_context_.GetRequestContext(); 205 resource_context_.GetRequestContext();
118 old_factory_ = request_context->job_factory(); 206 old_factory_ = request_context->job_factory();
207
208 // Set up content verification.
209 base::CommandLine* command_line = base::CommandLine::ForCurrentProcess();
210 command_line->AppendSwitchASCII(
211 switches::kExtensionContentVerification,
212 switches::kExtensionContentVerificationEnforce);
213 content_verifier_ = new ContentVerifier(
214 testing_profile_.get(),
215 new ChromeContentVerifierDelegate(testing_profile_.get()));
216 extension_info_map_->SetContentVerifier(content_verifier_.get());
119 } 217 }
120 218
121 void TearDown() override { 219 void TearDown() override {
122 net::URLRequestContext* request_context = 220 net::URLRequestContext* request_context =
123 resource_context_.GetRequestContext(); 221 resource_context_.GetRequestContext();
124 request_context->set_job_factory(old_factory_); 222 request_context->set_job_factory(old_factory_);
125 } 223 }
126 224
127 void SetProtocolHandler(bool is_incognito) { 225 void SetProtocolHandler(bool is_incognito) {
128 net::URLRequestContext* request_context = 226 net::URLRequestContext* request_context =
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
168 } 266 }
169 267
170 protected: 268 protected:
171 content::TestBrowserThreadBundle thread_bundle_; 269 content::TestBrowserThreadBundle thread_bundle_;
172 scoped_refptr<InfoMap> extension_info_map_; 270 scoped_refptr<InfoMap> extension_info_map_;
173 net::URLRequestJobFactoryImpl job_factory_; 271 net::URLRequestJobFactoryImpl job_factory_;
174 const net::URLRequestJobFactory* old_factory_; 272 const net::URLRequestJobFactory* old_factory_;
175 net::TestDelegate test_delegate_; 273 net::TestDelegate test_delegate_;
176 net::TestURLRequestContext test_url_request_context_; 274 net::TestURLRequestContext test_url_request_context_;
177 content::MockResourceContext resource_context_; 275 content::MockResourceContext resource_context_;
276 scoped_refptr<ContentVerifier> content_verifier_;
277 std::unique_ptr<TestingProfile> testing_profile_;
178 }; 278 };
179 279
180 // Tests that making a chrome-extension request in an incognito context is 280 // Tests that making a chrome-extension request in an incognito context is
181 // only allowed under the right circumstances (if the extension is allowed 281 // only allowed under the right circumstances (if the extension is allowed
182 // in incognito, and it's either a non-main-frame request or a split-mode 282 // in incognito, and it's either a non-main-frame request or a split-mode
183 // extension). 283 // extension).
184 TEST_F(ExtensionProtocolTest, IncognitoRequest) { 284 TEST_F(ExtensionProtocolsTest, IncognitoRequest) {
185 // Register an incognito extension protocol handler. 285 // Register an incognito extension protocol handler.
186 SetProtocolHandler(true); 286 SetProtocolHandler(true);
187 287
188 struct TestCase { 288 struct TestCase {
189 // Inputs. 289 // Inputs.
190 std::string name; 290 std::string name;
191 bool incognito_split_mode; 291 bool incognito_split_mode;
192 bool incognito_enabled; 292 bool incognito_enabled;
193 293
194 // Expected results. 294 // Expected results.
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
257 request->GetResponseHeaderByName(net::HttpRequestHeaders::kContentLength, 357 request->GetResponseHeaderByName(net::HttpRequestHeaders::kContentLength,
258 &content_length); 358 &content_length);
259 EXPECT_FALSE(content_length.empty()); 359 EXPECT_FALSE(content_length.empty());
260 int length_value = 0; 360 int length_value = 0;
261 EXPECT_TRUE(base::StringToInt(content_length, &length_value)); 361 EXPECT_TRUE(base::StringToInt(content_length, &length_value));
262 EXPECT_GT(length_value, 0); 362 EXPECT_GT(length_value, 0);
263 } 363 }
264 364
265 // Tests getting a resource for a component extension works correctly, both when 365 // Tests getting a resource for a component extension works correctly, both when
266 // the extension is enabled and when it is disabled. 366 // the extension is enabled and when it is disabled.
267 TEST_F(ExtensionProtocolTest, ComponentResourceRequest) { 367 TEST_F(ExtensionProtocolsTest, ComponentResourceRequest) {
268 // Register a non-incognito extension protocol handler. 368 // Register a non-incognito extension protocol handler.
269 SetProtocolHandler(false); 369 SetProtocolHandler(false);
270 370
271 scoped_refptr<Extension> extension = CreateWebStoreExtension(); 371 scoped_refptr<Extension> extension = CreateWebStoreExtension();
272 extension_info_map_->AddExtension(extension.get(), 372 extension_info_map_->AddExtension(extension.get(),
273 base::Time::Now(), 373 base::Time::Now(),
274 false, 374 false,
275 false); 375 false);
276 376
277 // First test it with the extension enabled. 377 // First test it with the extension enabled.
(...skipping 16 matching lines...) Expand all
294 extension->GetResourceURL("webstore_icon_16.png"), 394 extension->GetResourceURL("webstore_icon_16.png"),
295 net::DEFAULT_PRIORITY, &test_delegate_)); 395 net::DEFAULT_PRIORITY, &test_delegate_));
296 StartRequest(request.get(), content::RESOURCE_TYPE_MEDIA); 396 StartRequest(request.get(), content::RESOURCE_TYPE_MEDIA);
297 EXPECT_EQ(net::OK, test_delegate_.request_status()); 397 EXPECT_EQ(net::OK, test_delegate_.request_status());
298 CheckForContentLengthHeader(request.get()); 398 CheckForContentLengthHeader(request.get());
299 } 399 }
300 } 400 }
301 401
302 // Tests that a URL request for resource from an extension returns a few 402 // Tests that a URL request for resource from an extension returns a few
303 // expected response headers. 403 // expected response headers.
304 TEST_F(ExtensionProtocolTest, ResourceRequestResponseHeaders) { 404 TEST_F(ExtensionProtocolsTest, ResourceRequestResponseHeaders) {
305 // Register a non-incognito extension protocol handler. 405 // Register a non-incognito extension protocol handler.
306 SetProtocolHandler(false); 406 SetProtocolHandler(false);
307 407
308 scoped_refptr<Extension> extension = CreateTestResponseHeaderExtension(); 408 scoped_refptr<Extension> extension = CreateTestResponseHeaderExtension();
309 extension_info_map_->AddExtension(extension.get(), 409 extension_info_map_->AddExtension(extension.get(),
310 base::Time::Now(), 410 base::Time::Now(),
311 false, 411 false,
312 false); 412 false);
313 413
314 { 414 {
(...skipping 17 matching lines...) Expand all
332 // We set test.dat as web-accessible, so it should have a CORS header. 432 // We set test.dat as web-accessible, so it should have a CORS header.
333 std::string access_control; 433 std::string access_control;
334 request->GetResponseHeaderByName("Access-Control-Allow-Origin", 434 request->GetResponseHeaderByName("Access-Control-Allow-Origin",
335 &access_control); 435 &access_control);
336 EXPECT_EQ("*", access_control); 436 EXPECT_EQ("*", access_control);
337 } 437 }
338 } 438 }
339 439
340 // Tests that a URL request for main frame or subframe from an extension 440 // Tests that a URL request for main frame or subframe from an extension
341 // succeeds, but subresources fail. See http://crbug.com/312269. 441 // succeeds, but subresources fail. See http://crbug.com/312269.
342 TEST_F(ExtensionProtocolTest, AllowFrameRequests) { 442 TEST_F(ExtensionProtocolsTest, AllowFrameRequests) {
343 // Register a non-incognito extension protocol handler. 443 // Register a non-incognito extension protocol handler.
344 SetProtocolHandler(false); 444 SetProtocolHandler(false);
345 445
346 scoped_refptr<Extension> extension = CreateTestExtension("foo", false); 446 scoped_refptr<Extension> extension = CreateTestExtension("foo", false);
347 extension_info_map_->AddExtension(extension.get(), 447 extension_info_map_->AddExtension(extension.get(),
348 base::Time::Now(), 448 base::Time::Now(),
349 false, 449 false,
350 false); 450 false);
351 451
352 // All MAIN_FRAME requests should succeed. SUB_FRAME requests that are not 452 // All MAIN_FRAME requests should succeed. SUB_FRAME requests that are not
(...skipping 26 matching lines...) Expand all
379 { 479 {
380 std::unique_ptr<net::URLRequest> request( 480 std::unique_ptr<net::URLRequest> request(
381 resource_context_.GetRequestContext()->CreateRequest( 481 resource_context_.GetRequestContext()->CreateRequest(
382 extension->GetResourceURL("test.dat"), net::DEFAULT_PRIORITY, 482 extension->GetResourceURL("test.dat"), net::DEFAULT_PRIORITY,
383 &test_delegate_)); 483 &test_delegate_));
384 StartRequest(request.get(), content::RESOURCE_TYPE_MEDIA); 484 StartRequest(request.get(), content::RESOURCE_TYPE_MEDIA);
385 EXPECT_EQ(net::ERR_BLOCKED_BY_CLIENT, test_delegate_.request_status()); 485 EXPECT_EQ(net::ERR_BLOCKED_BY_CLIENT, test_delegate_.request_status());
386 } 486 }
387 } 487 }
388 488
389 489 TEST_F(ExtensionProtocolsTest, MetadataFolder) {
390 TEST_F(ExtensionProtocolTest, MetadataFolder) {
391 SetProtocolHandler(false); 490 SetProtocolHandler(false);
392 491
393 base::FilePath extension_dir = GetTestPath("metadata_folder"); 492 base::FilePath extension_dir = GetTestPath("metadata_folder");
394 std::string error; 493 std::string error;
395 scoped_refptr<Extension> extension = 494 scoped_refptr<Extension> extension =
396 file_util::LoadExtension(extension_dir, Manifest::INTERNAL, 495 file_util::LoadExtension(extension_dir, Manifest::INTERNAL,
397 Extension::NO_FLAGS, &error); 496 Extension::NO_FLAGS, &error);
398 ASSERT_NE(extension.get(), nullptr) << "error: " << error; 497 ASSERT_NE(extension.get(), nullptr) << "error: " << error;
399 498
400 // Loading "/test.html" should succeed. 499 // Loading "/test.html" should succeed.
401 EXPECT_EQ(net::OK, DoRequest(*extension, "test.html")); 500 EXPECT_EQ(net::OK, DoRequest(*extension, "test.html"));
402 501
403 // Loading "/_metadata/verified_contents.json" should fail. 502 // Loading "/_metadata/verified_contents.json" should fail.
404 base::FilePath relative_path = 503 base::FilePath relative_path =
405 base::FilePath(kMetadataFolder).Append(kVerifiedContentsFilename); 504 base::FilePath(kMetadataFolder).Append(kVerifiedContentsFilename);
406 EXPECT_TRUE(base::PathExists(extension_dir.Append(relative_path))); 505 EXPECT_TRUE(base::PathExists(extension_dir.Append(relative_path)));
407 EXPECT_EQ(net::ERR_FAILED, 506 EXPECT_EQ(net::ERR_FAILED,
408 DoRequest(*extension, relative_path.AsUTF8Unsafe())); 507 DoRequest(*extension, relative_path.AsUTF8Unsafe()));
409 508
410 // Loading "/_metadata/a.txt" should also fail. 509 // Loading "/_metadata/a.txt" should also fail.
411 relative_path = base::FilePath(kMetadataFolder).AppendASCII("a.txt"); 510 relative_path = base::FilePath(kMetadataFolder).AppendASCII("a.txt");
412 EXPECT_TRUE(base::PathExists(extension_dir.Append(relative_path))); 511 EXPECT_TRUE(base::PathExists(extension_dir.Append(relative_path)));
413 EXPECT_EQ(net::ERR_FAILED, 512 EXPECT_EQ(net::ERR_FAILED,
414 DoRequest(*extension, relative_path.AsUTF8Unsafe())); 513 DoRequest(*extension, relative_path.AsUTF8Unsafe()));
415 } 514 }
416 515
516 // Tests that unreadable files and deleted files correctly go through
517 // ContentVerifyJob.
518 TEST_F(ExtensionProtocolsTest, VerificationSeenForFileAccessErrors) {
519 const char kFooJsContents[] = "hello world.";
520 ScopedVerifyJobDelegateOverride scoped_override(kFooJsContents);
521 JobDelegate* test_job_delegate = scoped_override.delegate();
522 SetProtocolHandler(false);
523
524 const std::string kFooJs("foo.js");
525 // Create a temporary directory that a fake extension will live in and fill
526 // it with some test files.
527 base::ScopedTempDir temp_dir;
528 ASSERT_TRUE(temp_dir.CreateUniqueTempDir());
529 base::FilePath foo_js(FILE_PATH_LITERAL(kFooJs));
530 ASSERT_TRUE(AddFileToDirectory(temp_dir.GetPath(), foo_js, kFooJsContents))
531 << "Failed to write " << temp_dir.GetPath().value() << "/"
532 << foo_js.value();
533
534 ExtensionBuilder builder;
535 builder
536 .SetManifest(DictionaryBuilder()
537 .Set("name", "Foo")
538 .Set("version", "1.0")
539 .Set("manifest_version", 2)
540 .Set("update_url",
541 "https://clients2.google.com/service/update2/crx")
542 .Build())
543 .SetID(crx_file::id_util::GenerateId("whatever"))
544 .SetPath(temp_dir.GetPath())
545 .SetLocation(Manifest::INTERNAL);
546 scoped_refptr<Extension> extension(builder.Build());
547
548 EXPECT_TRUE(extension.get());
Devlin 2017/03/24 18:50:09 nit: may as well ASSERT here; we'll crash below an
lazyboy 2017/03/24 19:22:52 Done.
549 content_verifier_->OnExtensionLoaded(testing_profile_.get(), extension.get());
550 // Wait for PostTask to ContentVerifierIOData::AddData() to finish.
551 content::RunAllPendingInMessageLoop();
552
553 // Valid and readable foo.js.
554 EXPECT_EQ(net::OK, DoRequest(*extension, kFooJs));
555 test_job_delegate->WaitForDoneReading(extension->id());
556
557 // chmod -r foo.js.
558 base::FilePath foo_path = temp_dir.GetPath().AppendASCII(kFooJs);
559 ASSERT_TRUE(base::MakeFileUnreadable(foo_path));
560 test_job_delegate->Reset();
561 EXPECT_EQ(net::ERR_ACCESS_DENIED, DoRequest(*extension, kFooJs));
562 test_job_delegate->WaitForDoneReading(extension->id());
563
564 // Delete foo.js.
565 ASSERT_TRUE(base::DieFileDie(foo_path, false));
566 test_job_delegate->Reset();
567 EXPECT_EQ(net::ERR_FILE_NOT_FOUND, DoRequest(*extension, kFooJs));
568 test_job_delegate->WaitForDoneReading(extension->id());
569 }
570
417 } // namespace extensions 571 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698