Commit f32af4ae authored by Noel Gordon's avatar Noel Gordon Committed by Commit Bot

[filesapp] Support SVG files in file manager unittest harness

Update the file manager unittest harness: add SVG files to the list of
allowable file types that it can serve.

Bug: 1061388
Change-Id: I6ee69e26946a368da77373c2cd8c643cc856c603
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2138931Reviewed-by: default avatarLuciano Pacheco <lucmult@chromium.org>
Reviewed-by: default avatarNoel Gordon <noel@chromium.org>
Commit-Queue: Noel Gordon <noel@chromium.org>
Cr-Commit-Position: refs/heads/master@{#756931}
parent 18fa197b
...@@ -73,9 +73,10 @@ class TestFilesDataSource : public content::URLDataSource { ...@@ -73,9 +73,10 @@ class TestFilesDataSource : public content::URLDataSource {
// Do some basic validation of the file extension. // Do some basic validation of the file extension.
CHECK(src_file_path.Extension() == ".html" || CHECK(src_file_path.Extension() == ".html" ||
src_file_path.Extension() == ".js" || src_file_path.Extension() == ".js" ||
src_file_path.Extension() == ".css") src_file_path.Extension() == ".css" ||
<< "chrome://file_manager_test/ only supports .html/.js/.css extension " src_file_path.Extension() == ".svg")
"files"; << "chrome://file_manager_test/ only supports .html/.js/.css/.svg "
"extension files";
CHECK(base::PathExists(src_file_path) || base::PathExists(gen_file_path)) CHECK(base::PathExists(src_file_path) || base::PathExists(gen_file_path))
<< src_file_path << " or: " << gen_file_path << " input path: " << path; << src_file_path << " or: " << gen_file_path << " input path: " << path;
...@@ -88,7 +89,7 @@ class TestFilesDataSource : public content::URLDataSource { ...@@ -88,7 +89,7 @@ class TestFilesDataSource : public content::URLDataSource {
std::move(callback).Run(response.get()); std::move(callback).Run(response.get());
} }
// It currently only serves HTML/JS/CSS. // It currently only serves HTML/JS/CSS/SVG.
std::string GetMimeType(const std::string& path) override { std::string GetMimeType(const std::string& path) override {
if (base::EndsWith(path, ".html", base::CompareCase::INSENSITIVE_ASCII)) { if (base::EndsWith(path, ".html", base::CompareCase::INSENSITIVE_ASCII)) {
return "text/html"; return "text/html";
...@@ -98,10 +99,18 @@ class TestFilesDataSource : public content::URLDataSource { ...@@ -98,10 +99,18 @@ class TestFilesDataSource : public content::URLDataSource {
return "text/css"; return "text/css";
} }
CHECK(base::EndsWith(path, ".js", base::CompareCase::INSENSITIVE_ASCII)); if (base::EndsWith(path, ".js", base::CompareCase::INSENSITIVE_ASCII)) {
return "application/javascript"; return "application/javascript";
} }
if (base::EndsWith(path, ".svg", base::CompareCase::INSENSITIVE_ASCII)) {
return "image/svg+xml";
}
LOG(FATAL) << "unsupported file type: " << path;
return {};
}
std::string GetContentSecurityPolicyScriptSrc() override { std::string GetContentSecurityPolicyScriptSrc() override {
// Add 'unsafe-inline' to CSP to allow the inline <script> in the generated // Add 'unsafe-inline' to CSP to allow the inline <script> in the generated
// HTML to run see js_test_gen_html.py. // HTML to run see js_test_gen_html.py.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment