Index: extensions/browser/content_verify_job_unittest.cc |
diff --git a/extensions/browser/content_verify_job_unittest.cc b/extensions/browser/content_verify_job_unittest.cc |
index 1507ccb990e5b8ad4020e76a0a2301389736bd68..f5d5dda270c4a93417163fc8a2a10f477904d1e8 100644 |
--- a/extensions/browser/content_verify_job_unittest.cc |
+++ b/extensions/browser/content_verify_job_unittest.cc |
@@ -259,4 +259,32 @@ TEST_F(ContentVerifyJobUnittest, LegitimateZeroByteFile) { |
} |
} |
+// Tests that extension resources of different interesting sizes work properly. |
+// Regression test for https://crbug.com/720597, where content verification |
+// always failed for sizes multiple of content hash's block size (4096 bytes). |
+TEST_F(ContentVerifyJobUnittest, DifferentSizedFiles) { |
+ base::FilePath test_dir_base = |
+ GetTestPath(base::FilePath(FILE_PATH_LITERAL("different_sized_files"))); |
+ base::FilePath unzipped_path; |
+ scoped_refptr<Extension> extension = UnzipToTempDirAndLoad( |
+ test_dir_base.AppendASCII("source.zip"), &unzipped_path); |
+ ASSERT_TRUE(extension.get()); |
+ // Make sure there is a verified_contents.json file there as this test cannot |
+ // fetch it. |
+ EXPECT_TRUE( |
+ base::PathExists(file_util::GetVerifiedContentsPath(extension->path()))); |
+ |
+ // Each of these files are named based on their byte sizes. |
+ const std::string files_to_test[] = {"1024.js", "4096.js", "8192.js", |
+ "8191.js", "8193.js"}; |
+ for (size_t i = 0; i < arraysize(files_to_test); ++i) { |
Devlin
2017/06/07 13:27:31
nit: why not const auto& file_to_test : files_to_t
lazyboy
2017/06/07 18:54:15
Done.
|
+ base::FilePath resource_path = |
+ base::FilePath::FromUTF8Unsafe(files_to_test[i]); |
+ std::string contents; |
+ base::ReadFileToString(unzipped_path.Append(files_to_test[i]), &contents); |
Devlin
2017/06/07 13:27:31
as a sanity check, can we expect_eq the size of th
lazyboy
2017/06/07 18:54:15
Done.
|
+ EXPECT_EQ(ContentVerifyJob::NONE, |
+ RunContentVerifyJob(*extension.get(), resource_path, contents)); |
+ } |
+} |
+ |
} // namespace extensions |