Commit 0be0cd3c authored by Ben Reich's avatar Ben Reich Committed by Commit Bot

[js-code-coverage] Disable $i18n{} for Files app during browser tests

When collecting JS code coverage for Files app, $i18n labels are being
replaced per normal, but that causes a mismatch in character offsets
in the JS coverage data compared to the original JS source files.

Disable $i18n{} JS string replacements for ChromeOS FilesApp extension
when the --devtools-code-coverage flag is supplied.

For now, the only builder running the Files app tests with the JS code
--devtools-code-coverage flag is a CI builder:

  linux-chromeos-js-code-coverage

which is in development. Followup CLs will start updating the files app
tests to work with both this disabled $i18n{} mode, and the normal app
$i18n{} replaced mode, using a files app browser test sendTestCommand
helper called 'devtoolsCoverageActive' (added in this CL).

	:Gallery*:*FilesApp*:*SelectFileDialogExtension*

Bug: 1152612
Test: browser_tests --gtest_filer=*AudioPlayer*:VideoPlayer*\
Change-Id: I62eb2c66ea0c2d7ef0158dedbc41928d6e3b75ab
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2559234
Commit-Queue: Ben Reich <benreich@chromium.org>
Reviewed-by: default avatarBen Wells <benwells@chromium.org>
Reviewed-by: default avatarNoel Gordon <noel@chromium.org>
Cr-Commit-Position: refs/heads/master@{#830858}
parent 0bc73e54
......@@ -2032,6 +2032,12 @@ void FileManagerBrowserTestBase::OnCommand(const std::string& name,
return;
}
if (name == "isDevtoolsCoverageActive") {
LOG(INFO) << "isDevtoolsCoverageActive: " << devtools_code_coverage_;
*output = devtools_code_coverage_ ? "true" : "false";
return;
}
if (name == "launchAppOnDrive") {
auto* integration_service =
drive::DriveIntegrationServiceFactory::FindForProfile(profile());
......
......@@ -24,6 +24,7 @@
#if defined(OS_CHROMEOS)
#include "ash/keyboard/ui/resources/keyboard_resource_util.h"
#include "base/command_line.h"
#include "chrome/browser/browser_process.h"
#include "chrome/browser/chromeos/file_manager/file_manager_string_util.h"
#include "third_party/ink/grit/ink_resources.h"
......@@ -195,6 +196,16 @@ ChromeComponentExtensionResourceManager::GetTemplateReplacementsForExtension(
DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
LazyInitData();
#if defined(OS_CHROMEOS)
if (extension_id == extension_misc::kFilesManagerAppId) {
base::CommandLine* command_line = base::CommandLine::ForCurrentProcess();
// Disable $i18n{} template JS string replacement during JS code coverage.
if (command_line->HasSwitch("devtools-code-coverage"))
return nullptr;
}
#endif
auto it = data_->template_replacements().find(extension_id);
return it != data_->template_replacements().end() ? &it->second : nullptr;
}
......
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