Chromium Code Reviews| OLD | NEW |
|---|---|
| 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/command_line.h" |
| (...skipping 535 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 546 EXPECT_EQ(net::ERR_ACCESS_DENIED, DoRequest(*extension, kFooJs)); | 546 EXPECT_EQ(net::ERR_ACCESS_DENIED, DoRequest(*extension, kFooJs)); |
| 547 test_job_delegate.WaitForDoneReading(extension->id()); | 547 test_job_delegate.WaitForDoneReading(extension->id()); |
| 548 | 548 |
| 549 // Delete foo.js. | 549 // Delete foo.js. |
| 550 ASSERT_TRUE(base::DieFileDie(foo_path, false)); | 550 ASSERT_TRUE(base::DieFileDie(foo_path, false)); |
| 551 test_job_delegate.Reset(); | 551 test_job_delegate.Reset(); |
| 552 EXPECT_EQ(net::ERR_FILE_NOT_FOUND, DoRequest(*extension, kFooJs)); | 552 EXPECT_EQ(net::ERR_FILE_NOT_FOUND, DoRequest(*extension, kFooJs)); |
| 553 test_job_delegate.WaitForDoneReading(extension->id()); | 553 test_job_delegate.WaitForDoneReading(extension->id()); |
| 554 } | 554 } |
| 555 | 555 |
| 556 // Tests that zero byte files correctly go through ContentVerifyJob. | |
| 557 TEST_F(ExtensionProtocolsTest, VerificationSeenForZeroByteFile) { | |
| 558 const char kFooJsContents[] = ""; // Empty. | |
|
Devlin
2017/03/29 18:29:48
This won't do something silly like write a file wi
lazyboy
2017/03/29 20:09:59
Done.
| |
| 559 JobDelegate test_job_delegate(kFooJsContents); | |
| 560 SetProtocolHandler(false); | |
| 561 | |
| 562 const std::string kFooJs("foo.js"); | |
| 563 // Create a temporary directory that a fake extension will live in and fill | |
| 564 // it with some test files. | |
| 565 base::ScopedTempDir temp_dir; | |
| 566 ASSERT_TRUE(temp_dir.CreateUniqueTempDir()); | |
| 567 base::FilePath foo_js(FILE_PATH_LITERAL("foo.js")); | |
| 568 ASSERT_TRUE(AddFileToDirectory(temp_dir.GetPath(), foo_js, kFooJsContents)) | |
| 569 << "Failed to write " << temp_dir.GetPath().value() << "/" | |
| 570 << foo_js.value(); | |
| 571 | |
| 572 ExtensionBuilder builder; | |
| 573 builder | |
| 574 .SetManifest(DictionaryBuilder() | |
| 575 .Set("name", "Foo") | |
| 576 .Set("version", "1.0") | |
| 577 .Set("manifest_version", 2) | |
| 578 .Set("update_url", | |
| 579 "https://clients2.google.com/service/update2/crx") | |
| 580 .Build()) | |
| 581 .SetID(crx_file::id_util::GenerateId("whatever")) | |
| 582 .SetPath(temp_dir.GetPath()) | |
| 583 .SetLocation(Manifest::INTERNAL); | |
| 584 scoped_refptr<Extension> extension(builder.Build()); | |
| 585 | |
| 586 ASSERT_TRUE(extension.get()); | |
| 587 content_verifier_->OnExtensionLoaded(testing_profile_.get(), extension.get()); | |
| 588 // Wait for PostTask to ContentVerifierIOData::AddData() to finish. | |
| 589 content::RunAllPendingInMessageLoop(); | |
| 590 | |
| 591 // Request foo.js. | |
| 592 EXPECT_EQ(net::OK, DoRequest(*extension, kFooJs)); | |
| 593 test_job_delegate.WaitForDoneReading(extension->id()); | |
| 594 } | |
| 595 | |
| 556 } // namespace extensions | 596 } // namespace extensions |
| OLD | NEW |