Route serve_internal_file requests with --custom-devtools-frontend
crrev.com/c/4224291 fixed an issue in which "serve_file" was not being
handled by the custom-devtools-frontend directory.
This change handles the same problem for "serve_internal_file".
Bug: 1433271
Change-Id: I12e7fe8ae6023f158cb4ca31a63b7509be7cf99d
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4427491
Reviewed-by: Andrey Kosyakov <caseq@chromium.org>
Commit-Queue: Joanmarie Diggs <jdiggs@igalia.com>
Reviewed-by: Alex Rudenko <alexrudenko@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1130873}
diff --git a/chrome/browser/ui/webui/devtools_ui_data_source.cc b/chrome/browser/ui/webui/devtools_ui_data_source.cc
index 8119b63..c60d70f 100644
--- a/chrome/browser/ui/webui/devtools_ui_data_source.cc
+++ b/chrome/browser/ui/webui/devtools_ui_data_source.cc
@@ -127,6 +127,8 @@
std::string stripped_path =
StripDevToolsRevisionWithPrefix(path, "serve_rev/");
stripped_path = StripDevToolsRevisionWithPrefix(stripped_path, "serve_file/");
+ stripped_path =
+ StripDevToolsRevisionWithPrefix(stripped_path, "serve_internal_file/");
if (custom_devtools_frontend.SchemeIsFile()) {
// Fetch from file system but strip all the params.
StartFileRequest(PathWithoutParams(stripped_path), std::move(*callback));
diff --git a/chrome/browser/ui/webui/devtools_ui_data_source_unittest.cc b/chrome/browser/ui/webui/devtools_ui_data_source_unittest.cc
index cc70be2..b4f41411 100644
--- a/chrome/browser/ui/webui/devtools_ui_data_source_unittest.cc
+++ b/chrome/browser/ui/webui/devtools_ui_data_source_unittest.cc
@@ -255,6 +255,23 @@
EXPECT_EQ(data(), "file: devtools_app.html");
}
+TEST_F(DevToolsUIDataSourceTest,
+ TestDevToolsRemoteFileURLWithSwitchAndServeInternalFileParameters) {
+#if BUILDFLAG(IS_WIN)
+ const char* flag_value = "file://C:/tmp/";
+#else
+ const char* flag_value = "file://tmp/";
+#endif
+ base::CommandLine::ForCurrentProcess()->AppendSwitchASCII(
+ switches::kCustomDevtoolsFrontend, flag_value);
+ const GURL path = DevToolsUrl().Resolve(DevToolsRemotePath(
+ "/serve_internal_file/@76e4c1bb2ab4671b8beba3444e61c0f17584b2fc/"
+ "devtools_app.html"));
+ StartRequest(path.path());
+ EXPECT_TRUE(data_received());
+ EXPECT_EQ(data(), "file: devtools_app.html");
+}
+
TEST_F(DevToolsUIDataSourceTest, TestDevToolsRemoteURL) {
const GURL path =
DevToolsUrl().Resolve(DevToolsRemotePath(kDevToolsUITestFrontEndUrl));