Chromium Code Reviews| Index: chrome/browser/extensions/extension_protocols_unittest.cc |
| diff --git a/chrome/browser/extensions/extension_protocols_unittest.cc b/chrome/browser/extensions/extension_protocols_unittest.cc |
| index c762e8d5599b815cced82bf59933402c5a3a1010..324e263f2f8cfdccf749e6600a5c3f92e9f3b991 100644 |
| --- a/chrome/browser/extensions/extension_protocols_unittest.cc |
| +++ b/chrome/browser/extensions/extension_protocols_unittest.cc |
| @@ -553,4 +553,44 @@ TEST_F(ExtensionProtocolsTest, VerificationSeenForFileAccessErrors) { |
| test_job_delegate.WaitForDoneReading(extension->id()); |
| } |
| +// Tests that zero byte files correctly go through ContentVerifyJob. |
| +TEST_F(ExtensionProtocolsTest, VerificationSeenForZeroByteFile) { |
| + 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.
|
| + JobDelegate test_job_delegate(kFooJsContents); |
| + SetProtocolHandler(false); |
| + |
| + const std::string kFooJs("foo.js"); |
| + // Create a temporary directory that a fake extension will live in and fill |
| + // it with some test files. |
| + base::ScopedTempDir temp_dir; |
| + ASSERT_TRUE(temp_dir.CreateUniqueTempDir()); |
| + base::FilePath foo_js(FILE_PATH_LITERAL("foo.js")); |
| + ASSERT_TRUE(AddFileToDirectory(temp_dir.GetPath(), foo_js, kFooJsContents)) |
| + << "Failed to write " << temp_dir.GetPath().value() << "/" |
| + << foo_js.value(); |
| + |
| + ExtensionBuilder builder; |
| + builder |
| + .SetManifest(DictionaryBuilder() |
| + .Set("name", "Foo") |
| + .Set("version", "1.0") |
| + .Set("manifest_version", 2) |
| + .Set("update_url", |
| + "https://clients2.google.com/service/update2/crx") |
| + .Build()) |
| + .SetID(crx_file::id_util::GenerateId("whatever")) |
| + .SetPath(temp_dir.GetPath()) |
| + .SetLocation(Manifest::INTERNAL); |
| + scoped_refptr<Extension> extension(builder.Build()); |
| + |
| + ASSERT_TRUE(extension.get()); |
| + content_verifier_->OnExtensionLoaded(testing_profile_.get(), extension.get()); |
| + // Wait for PostTask to ContentVerifierIOData::AddData() to finish. |
| + content::RunAllPendingInMessageLoop(); |
| + |
| + // Request foo.js. |
| + EXPECT_EQ(net::OK, DoRequest(*extension, kFooJs)); |
| + test_job_delegate.WaitForDoneReading(extension->id()); |
| +} |
| + |
| } // namespace extensions |