Commit f29f54bd authored by danakj's avatar danakj Committed by Commit Bot

Move web test setup from ShellMainDelegate to WebTestBrowserMain.

This code is for web tests only so does not need to live inside
content shell.

We still read the kRunWebTests switch in ShellMainDelegate, which is
actually a content shell switch (it modifies content shell to inject
web test code).

This puts code to set command lines that was previously running in
every process into just the browser process, and relies on the allow-
lists of switches for each process to pass the appropriate flags.

This uncovered 2 interesting points along the way:

The kRegisterFontFiles switch is only for windows. It is used as a
global variable in the browser process to set the list of font files,
and then to open a hole in the renderer sandbox to read those files.
Then it is passed to the renderer which reads those files. I've made
this more clear with code, ifdefs and comments.

Web tests were setting --disable-gpu-rasterization in the gpu process
unconditionally, since every process sets command line flags but the
--force-gpu-rasterization is not passed to the gpu process. This doesn't
seem to have an impact on results except for on mac. By removing this
--disable-gpu-rasterization from the gpu process, when gpu raster is
being used in virtual/gpu-rasterization/ tests, the results change.
This CL rebaselines them.

R=nasko@chromium.org

Bug: 866140
Change-Id: Ia49983517ff0b9c91b1ae7549a47fd16a45d3497
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2116535
Commit-Queue: danakj <danakj@chromium.org>
Reviewed-by: default avatarvmpstr <vmpstr@chromium.org>
Reviewed-by: default avatarNasko Oskov <nasko@chromium.org>
Reviewed-by: default avatarFlorin Malita <fmalita@chromium.org>
Cr-Commit-Position: refs/heads/master@{#754724}
parent 7910ceae
...@@ -3325,10 +3325,6 @@ void RenderProcessHostImpl::PropagateBrowserCommandLineToRenderer( ...@@ -3325,10 +3325,6 @@ void RenderProcessHostImpl::PropagateBrowserCommandLineToRenderer(
switches::kUseFakeCodecForPeerConnection, switches::kUseFakeCodecForPeerConnection,
switches::kUseFakeUIForMediaStream, switches::kUseFakeUIForMediaStream,
switches::kUseLegacyFormControls, switches::kUseLegacyFormControls,
// This flag needs to be propagated to the renderer process for
// --in-process-webgl.
switches::kUseGL,
switches::kUseGpuInTests,
switches::kUseMobileUserAgent, switches::kUseMobileUserAgent,
switches::kV, switches::kV,
switches::kVideoCaptureUseGpuMemoryBuffer, switches::kVideoCaptureUseGpuMemoryBuffer,
......
...@@ -65,9 +65,6 @@ jumbo_static_library("content_shell_lib") { ...@@ -65,9 +65,6 @@ jumbo_static_library("content_shell_lib") {
sources = [ sources = [
"android/shell_manager.cc", "android/shell_manager.cc",
"android/shell_manager.h", "android/shell_manager.h",
"app/blink_test_platform_support.h",
"app/blink_test_platform_support_mac.mm",
"app/blink_test_platform_support_win.cc",
"app/paths_mac.h", "app/paths_mac.h",
"app/paths_mac.mm", "app/paths_mac.mm",
"app/shell_crash_reporter_client.cc", "app/shell_crash_reporter_client.cc",
...@@ -150,10 +147,14 @@ jumbo_static_library("content_shell_lib") { ...@@ -150,10 +147,14 @@ jumbo_static_library("content_shell_lib") {
"browser/web_test/web_test_bluetooth_fake_adapter_setter_impl.h", "browser/web_test/web_test_bluetooth_fake_adapter_setter_impl.h",
"browser/web_test/web_test_browser_context.cc", "browser/web_test/web_test_browser_context.cc",
"browser/web_test/web_test_browser_context.h", "browser/web_test/web_test_browser_context.h",
"browser/web_test/web_test_browser_main.cc",
"browser/web_test/web_test_browser_main.h",
"browser/web_test/web_test_browser_main_parts.cc", "browser/web_test/web_test_browser_main_parts.cc",
"browser/web_test/web_test_browser_main_parts.h", "browser/web_test/web_test_browser_main_parts.h",
"browser/web_test/web_test_browser_main_platform_support.h",
"browser/web_test/web_test_browser_main_platform_support_linux.cc",
"browser/web_test/web_test_browser_main_platform_support_mac.mm",
"browser/web_test/web_test_browser_main_platform_support_win.cc",
"browser/web_test/web_test_browser_main_runner.cc",
"browser/web_test/web_test_browser_main_runner.h",
"browser/web_test/web_test_client_impl.cc", "browser/web_test/web_test_client_impl.cc",
"browser/web_test/web_test_client_impl.h", "browser/web_test/web_test_client_impl.h",
"browser/web_test/web_test_content_browser_client.cc", "browser/web_test/web_test_content_browser_client.cc",
......
// Copyright 2013 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef CONTENT_SHELL_APP_BLINK_TEST_PLATFORM_SUPPORT_H_
#define CONTENT_SHELL_APP_BLINK_TEST_PLATFORM_SUPPORT_H_
namespace content {
bool CheckLayoutSystemDeps();
void BlinkTestPlatformInitialize();
} // namespace content
#endif // CONTENT_SHELL_APP_BLINK_TEST_PLATFORM_SUPPORT_H_
This diff is collapsed.
...@@ -18,10 +18,11 @@ class ShellContentBrowserClient; ...@@ -18,10 +18,11 @@ class ShellContentBrowserClient;
class ShellContentGpuClient; class ShellContentGpuClient;
class ShellContentRendererClient; class ShellContentRendererClient;
class ShellContentUtilityClient; class ShellContentUtilityClient;
class WebTestBrowserMainRunner;
class ShellMainDelegate : public ContentMainDelegate { class ShellMainDelegate : public ContentMainDelegate {
public: public:
explicit ShellMainDelegate(bool is_browsertest = false); explicit ShellMainDelegate(bool is_content_browsertests = false);
~ShellMainDelegate() override; ~ShellMainDelegate() override;
// ContentMainDelegate implementation: // ContentMainDelegate implementation:
...@@ -42,7 +43,18 @@ class ShellMainDelegate : public ContentMainDelegate { ...@@ -42,7 +43,18 @@ class ShellMainDelegate : public ContentMainDelegate {
static void InitializeResourceBundle(); static void InitializeResourceBundle();
private: private:
bool is_browsertest_; // Only present when running content_browsertests, which run inside Content
// Shell.
//
// content_browsertests should not set the kRunWebTests command line flag, so
// |is_content_browsertests_| and |web_test_runner_| are mututally exclusive.
bool is_content_browsertests_;
// Only present when running web tests, which run inside Content Shell.
//
// Web tests are not browser tests, so |is_content_browsertests_| and
// |web_test_runner_| are mututally exclusive.
std::unique_ptr<WebTestBrowserMainRunner> web_test_runner_;
std::unique_ptr<ShellContentBrowserClient> browser_client_; std::unique_ptr<ShellContentBrowserClient> browser_client_;
std::unique_ptr<ShellContentGpuClient> gpu_client_; std::unique_ptr<ShellContentGpuClient> gpu_client_;
std::unique_ptr<ShellContentRendererClient> renderer_client_; std::unique_ptr<ShellContentRendererClient> renderer_client_;
......
...@@ -71,11 +71,6 @@ ...@@ -71,11 +71,6 @@
#include "content/public/common/content_descriptors.h" #include "content/public/common/content_descriptors.h"
#endif #endif
#if defined(OS_WIN)
#include "sandbox/win/src/sandbox.h"
#include "services/service_manager/sandbox/win/sandbox_win.h"
#endif
#if BUILDFLAG(ENABLE_CAST_RENDERER) #if BUILDFLAG(ENABLE_CAST_RENDERER)
#include "media/mojo/services/media_service_factory.h" // nogncheck #include "media/mojo/services/media_service_factory.h" // nogncheck
#endif #endif
...@@ -180,14 +175,25 @@ bool ShellContentBrowserClient::ShouldTerminateOnServiceQuit( ...@@ -180,14 +175,25 @@ bool ShellContentBrowserClient::ShouldTerminateOnServiceQuit(
void ShellContentBrowserClient::AppendExtraCommandLineSwitches( void ShellContentBrowserClient::AppendExtraCommandLineSwitches(
base::CommandLine* command_line, base::CommandLine* command_line,
int child_process_id) { int child_process_id) {
if (base::CommandLine::ForCurrentProcess()->HasSwitch( static const char* kForwardSwitches[] = {
switches::kExposeInternalsForTesting)) { #if defined(OS_MACOSX)
command_line->AppendSwitch(switches::kExposeInternalsForTesting); // Needed since on Mac, content_browsertests doesn't use
} // content_test_launcher.cc and instead uses shell_main.cc. So give a signal
// to shell_main.cc that it's a browser test.
switches::kBrowserTest,
#endif
switches::kCrashDumpsDir,
switches::kEnableCrashReporter,
switches::kExposeInternalsForTesting,
};
command_line->CopySwitchesFrom(*base::CommandLine::ForCurrentProcess(),
kForwardSwitches,
base::size(kForwardSwitches));
#if defined(OS_LINUX)
if (base::CommandLine::ForCurrentProcess()->HasSwitch( if (base::CommandLine::ForCurrentProcess()->HasSwitch(
switches::kEnableCrashReporter)) { switches::kEnableCrashReporter)) {
command_line->AppendSwitch(switches::kEnableCrashReporter);
#if defined(OS_LINUX)
int fd; int fd;
pid_t pid; pid_t pid;
if (crash_reporter::GetHandlerSocket(&fd, &pid)) { if (crash_reporter::GetHandlerSocket(&fd, &pid)) {
...@@ -195,32 +201,8 @@ void ShellContentBrowserClient::AppendExtraCommandLineSwitches( ...@@ -195,32 +201,8 @@ void ShellContentBrowserClient::AppendExtraCommandLineSwitches(
crash_reporter::switches::kCrashpadHandlerPid, crash_reporter::switches::kCrashpadHandlerPid,
base::NumberToString(pid)); base::NumberToString(pid));
} }
#endif // OS_LINUX
} }
if (base::CommandLine::ForCurrentProcess()->HasSwitch( #endif // OS_LINUX
switches::kCrashDumpsDir)) {
command_line->AppendSwitchPath(
switches::kCrashDumpsDir,
base::CommandLine::ForCurrentProcess()->GetSwitchValuePath(
switches::kCrashDumpsDir));
}
if (base::CommandLine::ForCurrentProcess()->HasSwitch(
switches::kRegisterFontFiles)) {
command_line->AppendSwitchASCII(
switches::kRegisterFontFiles,
base::CommandLine::ForCurrentProcess()->GetSwitchValueASCII(
switches::kRegisterFontFiles));
}
#if defined(OS_MACOSX)
// Needed since on Mac, content_browsertests doesn't use
// content_test_launcher.cc and instead uses shell_main.cc. So give a signal
// to shell_main.cc that it's a browser test.
if (base::CommandLine::ForCurrentProcess()->HasSwitch(
switches::kBrowserTest)) {
command_line->AppendSwitch(switches::kBrowserTest);
}
#endif
} }
std::string ShellContentBrowserClient::GetAcceptLangs(BrowserContext* context) { std::string ShellContentBrowserClient::GetAcceptLangs(BrowserContext* context) {
...@@ -366,23 +348,6 @@ void ShellContentBrowserClient::GetAdditionalMappedFilesForChildProcess( ...@@ -366,23 +348,6 @@ void ShellContentBrowserClient::GetAdditionalMappedFilesForChildProcess(
} }
#endif // defined(OS_LINUX) || defined(OS_ANDROID) #endif // defined(OS_LINUX) || defined(OS_ANDROID)
#if defined(OS_WIN)
bool ShellContentBrowserClient::PreSpawnRenderer(sandbox::TargetPolicy* policy,
RendererSpawnFlags flags) {
// Add sideloaded font files for testing. See also DIR_WINDOWS_FONTS
// addition in |StartSandboxedProcess|.
std::vector<std::string> font_files = switches::GetSideloadFontFiles();
for (std::vector<std::string>::const_iterator i(font_files.begin());
i != font_files.end();
++i) {
policy->AddRule(sandbox::TargetPolicy::SUBSYS_FILES,
sandbox::TargetPolicy::FILES_ALLOW_READONLY,
base::UTF8ToWide(*i).c_str());
}
return true;
}
#endif // OS_WIN
mojo::Remote<network::mojom::NetworkContext> mojo::Remote<network::mojom::NetworkContext>
ShellContentBrowserClient::CreateNetworkContext( ShellContentBrowserClient::CreateNetworkContext(
BrowserContext* context, BrowserContext* context,
......
...@@ -92,11 +92,6 @@ class ShellContentBrowserClient : public ContentBrowserClient { ...@@ -92,11 +92,6 @@ class ShellContentBrowserClient : public ContentBrowserClient {
content::PosixFileDescriptorInfo* mappings) override; content::PosixFileDescriptorInfo* mappings) override;
#endif // defined(OS_LINUX) || defined(OS_ANDROID) #endif // defined(OS_LINUX) || defined(OS_ANDROID)
#if defined(OS_WIN)
bool PreSpawnRenderer(sandbox::TargetPolicy* policy,
RendererSpawnFlags flags) override;
#endif
mojo::Remote<network::mojom::NetworkContext> CreateNetworkContext( mojo::Remote<network::mojom::NetworkContext> CreateNetworkContext(
BrowserContext* context, BrowserContext* context,
bool in_memory, bool in_memory,
......
// Copyright 2013 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef CONTENT_SHELL_BROWSER_WEB_TEST_WEB_TEST_BROWSER_MAIN_PLATFORM_SUPPORT_H_
#define CONTENT_SHELL_BROWSER_WEB_TEST_WEB_TEST_BROWSER_MAIN_PLATFORM_SUPPORT_H_
#include "build/build_config.h"
namespace content {
#if defined(OS_WIN)
// Called in the browser process to ensure the system is set up correctly before
// running web tests.
bool WebTestBrowserCheckLayoutSystemDeps();
#endif
// Called in the browser process to initialize anything platform-specific for
// web tests.
void WebTestBrowserPlatformInitialize();
} // namespace content
#endif // CONTENT_SHELL_BROWSER_WEB_TEST_WEB_TEST_BROWSER_MAIN_PLATFORM_SUPPORT_H_
// Copyright 2019 The Chromium Authors. All rights reserved. // Copyright 2020 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
#include "skia/ext/test_fonts.h" #include "content/shell/browser/web_test/web_test_browser_main_platform_support.h"
#include "base/test/fontconfig_util_linux.h" #include "base/test/fontconfig_util_linux.h"
namespace skia { namespace content {
void ConfigureTestFont() { namespace {
void SetupFonts() {
base::SetUpFontconfig(); base::SetUpFontconfig();
} }
} // namespace
} // namespace skia void WebTestBrowserPlatformInitialize() {
SetupFonts();
}
} // namespace content
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
#include "content/shell/app/blink_test_platform_support.h" #include "content/shell/browser/web_test/web_test_browser_main_platform_support.h"
#include <AppKit/AppKit.h> #include <AppKit/AppKit.h>
#include <Foundation/Foundation.h> #include <Foundation/Foundation.h>
...@@ -17,26 +17,21 @@ void SetDefaultsToWebTestValues(void) { ...@@ -17,26 +17,21 @@ void SetDefaultsToWebTestValues(void) {
// (We want to do this as early as possible in application startup so // (We want to do this as early as possible in application startup so
// the settings are in before any higher layers could cache values.) // the settings are in before any higher layers could cache values.)
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults]; NSUserDefaults* defaults = [NSUserDefaults standardUserDefaults];
// Do not set text-rendering prefs (AppleFontSmoothing, // Do not set text-rendering prefs (AppleFontSmoothing,
// AppleAntiAliasingThreshold) here: Skia picks the right settings for this // AppleAntiAliasingThreshold) here: Skia picks the right settings for this
// in web test mode, see FontSkia.cpp in WebKit and // in web test mode, see FontSkia.cpp in WebKit and
// SkFontHost_mac_coretext.cpp in skia. // SkFontHost_mac_coretext.cpp in skia.
const NSInteger kBlueTintedAppearance = 1; const NSInteger kBlueTintedAppearance = 1;
[defaults setInteger:kBlueTintedAppearance [defaults setInteger:kBlueTintedAppearance forKey:@"AppleAquaColorVariant"];
forKey:@"AppleAquaColorVariant"];
[defaults setObject:@"0.709800 0.835300 1.000000" [defaults setObject:@"0.709800 0.835300 1.000000"
forKey:@"AppleHighlightColor"]; forKey:@"AppleHighlightColor"];
[defaults setObject:@"0.500000 0.500000 0.500000" [defaults setObject:@"0.500000 0.500000 0.500000"
forKey:@"AppleOtherHighlightColor"]; forKey:@"AppleOtherHighlightColor"];
[defaults setObject:[NSArray arrayWithObject:@"en"] [defaults setObject:[NSArray arrayWithObject:@"en"] forKey:@"AppleLanguages"];
forKey:@"AppleLanguages"]; [defaults setBool:NO forKey:@"AppleScrollAnimationEnabled"];
[defaults setBool:NO [defaults setBool:NO forKey:@"NSScrollAnimationEnabled"];
forKey:@"AppleScrollAnimationEnabled"]; [defaults setObject:@"Always" forKey:@"AppleShowScrollBars"];
[defaults setBool:NO
forKey:@"NSScrollAnimationEnabled"];
[defaults setObject:@"Always"
forKey:@"AppleShowScrollBars"];
// Disable AppNap since web tests do not always meet the requirements to // Disable AppNap since web tests do not always meet the requirements to
// avoid "napping" which will cause test timeouts. http://crbug.com/811525. // avoid "napping" which will cause test timeouts. http://crbug.com/811525.
...@@ -45,7 +40,7 @@ void SetDefaultsToWebTestValues(void) { ...@@ -45,7 +40,7 @@ void SetDefaultsToWebTestValues(void) {
} // namespace } // namespace
void BlinkTestPlatformInitialize() { void WebTestBrowserPlatformInitialize() {
SetDefaultsToWebTestValues(); SetDefaultsToWebTestValues();
} }
......
...@@ -2,10 +2,10 @@ ...@@ -2,10 +2,10 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
#include "content/shell/app/blink_test_platform_support.h" #include "content/shell/browser/web_test/web_test_browser_main_platform_support.h"
#include <windows.h>
#include <stddef.h> #include <stddef.h>
#include <windows.h>
#include <iostream> #include <iostream>
#include <list> #include <list>
#include <string> #include <string>
...@@ -40,7 +40,7 @@ void SetupFonts() { ...@@ -40,7 +40,7 @@ void SetupFonts() {
} // namespace } // namespace
bool CheckLayoutSystemDeps() { bool WebTestBrowserCheckLayoutSystemDeps() {
std::list<std::string> errors; std::list<std::string> errors;
// This metric will be 17 when font size is "Normal". // This metric will be 17 when font size is "Normal".
...@@ -50,11 +50,11 @@ bool CheckLayoutSystemDeps() { ...@@ -50,11 +50,11 @@ bool CheckLayoutSystemDeps() {
NONCLIENTMETRICS metrics = {0}; NONCLIENTMETRICS metrics = {0};
metrics.cbSize = sizeof(NONCLIENTMETRICS); metrics.cbSize = sizeof(NONCLIENTMETRICS);
bool success = !!::SystemParametersInfo( bool success = !!::SystemParametersInfo(SPI_GETNONCLIENTMETRICS,
SPI_GETNONCLIENTMETRICS, metrics.cbSize, &metrics, 0); metrics.cbSize, &metrics, 0);
PCHECK(success); PCHECK(success);
LOGFONTW* system_fonts[] = LOGFONTW* system_fonts[] = {&metrics.lfStatusFont, &metrics.lfMenuFont,
{&metrics.lfStatusFont, &metrics.lfMenuFont, &metrics.lfSmCaptionFont}; &metrics.lfSmCaptionFont};
const wchar_t required_font[] = L"Segoe UI"; const wchar_t required_font[] = L"Segoe UI";
int required_font_size = -12; int required_font_size = -12;
for (size_t i = 0; i < base::size(system_fonts); ++i) { for (size_t i = 0; i < base::size(system_fonts); ++i) {
...@@ -70,7 +70,7 @@ bool CheckLayoutSystemDeps() { ...@@ -70,7 +70,7 @@ bool CheckLayoutSystemDeps() {
return errors.empty(); return errors.empty();
} }
void BlinkTestPlatformInitialize() { void WebTestBrowserPlatformInitialize() {
SetupFonts(); SetupFonts();
} }
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
#include "content/shell/browser/web_test/web_test_browser_main.h" #include "content/shell/browser/web_test/web_test_browser_main_runner.h"
#include <iostream> #include <iostream>
#include <memory> #include <memory>
...@@ -21,17 +21,32 @@ ...@@ -21,17 +21,32 @@
#include "base/threading/thread_restrictions.h" #include "base/threading/thread_restrictions.h"
#include "base/threading/thread_task_runner_handle.h" #include "base/threading/thread_task_runner_handle.h"
#include "build/build_config.h" #include "build/build_config.h"
#include "cc/base/switches.h"
#include "components/network_session_configurator/common/network_switches.h" #include "components/network_session_configurator/common/network_switches.h"
#include "components/viz/common/switches.h"
#include "content/public/browser/browser_main_runner.h" #include "content/public/browser/browser_main_runner.h"
#include "content/public/common/content_switches.h"
#include "content/public/common/url_constants.h" #include "content/public/common/url_constants.h"
#include "content/public/test/ppapi_test_utils.h"
#include "content/public/test/web_test_support.h"
#include "content/shell/browser/shell.h" #include "content/shell/browser/shell.h"
#include "content/shell/browser/web_test/blink_test_controller.h" #include "content/shell/browser/web_test/blink_test_controller.h"
#include "content/shell/browser/web_test/test_info_extractor.h" #include "content/shell/browser/web_test/test_info_extractor.h"
#include "content/shell/browser/web_test/web_test_browser_main_platform_support.h"
#include "content/shell/common/shell_switches.h" #include "content/shell/common/shell_switches.h"
#include "content/shell/common/web_test/web_test_switches.h" #include "content/shell/common/web_test/web_test_switches.h"
#include "content/shell/renderer/web_test/blink_test_helpers.h" #include "content/shell/renderer/web_test/blink_test_helpers.h"
#include "gpu/config/gpu_switches.h" #include "gpu/config/gpu_switches.h"
#include "media/base/media_switches.h"
#include "net/base/filename_util.h" #include "net/base/filename_util.h"
#include "ppapi/buildflags/buildflags.h"
#include "services/network/public/cpp/network_switches.h"
#include "ui/base/ui_base_switches.h"
#include "ui/display/display_switches.h"
#include "ui/gl/gl_implementation.h"
#include "ui/gl/gl_switches.h"
namespace content {
namespace { namespace {
...@@ -80,30 +95,134 @@ void RunTests(content::BrowserMainRunner* main_runner) { ...@@ -80,30 +95,134 @@ void RunTests(content::BrowserMainRunner* main_runner) {
} // namespace } // namespace
// Main routine for running as the Browser process. void WebTestBrowserMainRunner::Initialize() {
void WebTestBrowserMain(const content::MainFunctionParams& parameters) { #if defined(OS_WIN)
std::unique_ptr<content::BrowserMainRunner> main_runner = bool layout_system_deps_ok = content::WebTestBrowserCheckLayoutSystemDeps();
content::BrowserMainRunner::Create(); CHECK(layout_system_deps_ok);
#endif
base::ScopedTempDir browser_context_path_for_web_tests; base::CommandLine& command_line = *base::CommandLine::ForCurrentProcess();
CHECK(browser_context_path_for_web_tests.CreateUniqueTempDir()); CHECK(browser_context_path_for_web_tests_.CreateUniqueTempDir());
CHECK(!browser_context_path_for_web_tests.GetPath().MaybeAsASCII().empty()); CHECK(!browser_context_path_for_web_tests_.GetPath().MaybeAsASCII().empty());
base::CommandLine::ForCurrentProcess()->AppendSwitch( command_line.AppendSwitchASCII(
switches::kIgnoreCertificateErrors);
base::CommandLine::ForCurrentProcess()->AppendSwitchASCII(
switches::kContentShellDataPath, switches::kContentShellDataPath,
browser_context_path_for_web_tests.GetPath().MaybeAsASCII()); browser_context_path_for_web_tests_.GetPath().MaybeAsASCII());
command_line.AppendSwitch(switches::kIgnoreCertificateErrors);
// Always disable the unsandbox GPU process for DX12 and Vulkan Info
// collection to avoid interference. This GPU process is launched 120
// seconds after chrome starts.
command_line.AppendSwitch(
switches::kDisableGpuProcessForDX12VulkanInfoCollection);
#if BUILDFLAG(ENABLE_PLUGINS)
bool ppapi_ok = ppapi::RegisterBlinkTestPlugin(&command_line);
CHECK(ppapi_ok);
#endif
command_line.AppendSwitch(cc::switches::kEnableGpuBenchmarking);
command_line.AppendSwitch(switches::kEnableLogging);
command_line.AppendSwitch(switches::kAllowFileAccessFromFiles);
// only default to a software GL if the flag isn't already specified.
if (!command_line.HasSwitch(switches::kUseGpuInTests) &&
!command_line.HasSwitch(switches::kUseGL)) {
command_line.AppendSwitchASCII(
switches::kUseGL,
gl::GetGLImplementationName(gl::GetSoftwareGLImplementation()));
}
command_line.AppendSwitchASCII(switches::kTouchEventFeatureDetection,
switches::kTouchEventFeatureDetectionEnabled);
if (!command_line.HasSwitch(switches::kForceDeviceScaleFactor))
command_line.AppendSwitchASCII(switches::kForceDeviceScaleFactor, "1.0");
if (!command_line.HasSwitch(switches::kAutoplayPolicy)) {
command_line.AppendSwitchASCII(
switches::kAutoplayPolicy,
switches::autoplay::kNoUserGestureRequiredPolicy);
}
if (!command_line.HasSwitch(switches::kStableReleaseMode))
command_line.AppendSwitch(switches::kEnableExperimentalWebPlatformFeatures);
if (!command_line.HasSwitch(switches::kEnableThreadedCompositing)) {
command_line.AppendSwitch(switches::kDisableThreadedCompositing);
command_line.AppendSwitch(cc::switches::kDisableThreadedAnimation);
}
// With display compositor pixel dumps, we ensure that we complete all
// stages of compositing before draw. We also can't have checker imaging,
// since it's incompatible with single threaded compositor and display
// compositor pixel dumps.
//
// TODO(crbug.com/894613) Add kRunAllCompositorStagesBeforeDraw back here
// once you figure out why it causes so much web test flakiness.
// command_line.AppendSwitch(switches::kRunAllCompositorStagesBeforeDraw);
command_line.AppendSwitch(cc::switches::kDisableCheckerImaging);
command_line.AppendSwitch(switches::kMuteAudio);
command_line.AppendSwitch(switches::kEnablePreciseMemoryInfo);
command_line.AppendSwitchASCII(network::switches::kHostResolverRules,
"MAP nonexistent.*.test ~NOTFOUND,"
"MAP *.test. 127.0.0.1,"
"MAP *.test 127.0.0.1");
// We want to know determanistically from command line flags if the Gpu
// process will provide gpu raster in its capabilities or not.
//
// If kForceGpuRasterization is specified, the renderer ignores the gpu
// capabilities and uses gpu raster always.
// If kEnableGpuRasterization is specified, the Gpu process always reports
// that it can gpu raster, and the renderer will use it.
// Thus, kForceGpuRasterization nad kEnableGpuRasterization have the same
// effect.
// TODO(danakj): We should remove the kForceGpuRasterization switch and just
// have the gpu process report the right thing (with the
// kEnableGpuRasterization switch) instead of ignoring it in the renderer.
//
// If neither is specified, then we don't want to choose at runtime, and we
// ensure that gpu raster is disabled.
if (!command_line.HasSwitch(switches::kForceGpuRasterization) &&
!command_line.HasSwitch(switches::kEnableGpuRasterization))
command_line.AppendSwitch(switches::kDisableGpuRasterization);
// If the virtual test suite didn't specify a display color space, then
// force sRGB.
if (!command_line.HasSwitch(switches::kForceDisplayColorProfile))
command_line.AppendSwitchASCII(switches::kForceDisplayColorProfile, "srgb");
// We want stable/baseline results when running web tests.
command_line.AppendSwitch(switches::kDisableSkiaRuntimeOpts);
command_line.AppendSwitch(switches::kDisallowNonExactResourceReuse);
// Always run with fake media devices.
command_line.AppendSwitch(switches::kUseFakeUIForMediaStream);
command_line.AppendSwitch(switches::kUseFakeDeviceForMediaStream);
// Always disable the unsandbox GPU process for DX12 and Vulkan Info // Always disable the unsandbox GPU process for DX12 and Vulkan Info
// collection to avoid interference. This GPU process is launched 120 // collection to avoid interference. This GPU process is launched 120
// seconds after chrome starts. // seconds after chrome starts.
base::CommandLine::ForCurrentProcess()->AppendSwitch( command_line.AppendSwitch(
switches::kDisableGpuProcessForDX12VulkanInfoCollection); switches::kDisableGpuProcessForDX12VulkanInfoCollection);
#if defined(OS_WIN) || defined(OS_MACOSX) || defined(OS_LINUX)
content::WebTestBrowserPlatformInitialize();
#endif
content::EnableBrowserWebTestMode();
}
void WebTestBrowserMainRunner::RunBrowserMain(
const content::MainFunctionParams& parameters) {
std::unique_ptr<content::BrowserMainRunner> main_runner =
content::BrowserMainRunner::Create();
int initialize_exit_code = main_runner->Initialize(parameters); int initialize_exit_code = main_runner->Initialize(parameters);
DCHECK_LT(initialize_exit_code, 0) DCHECK_LT(initialize_exit_code, 0)
<< "BrowserMainRunner::Initialize failed in WebTestBrowserMain"; << "BrowserMainRunner::Initialize failed in WebTestBrowserMainRunner";
RunTests(main_runner.get()); RunTests(main_runner.get());
base::RunLoop().RunUntilIdle(); base::RunLoop().RunUntilIdle();
...@@ -112,3 +231,5 @@ void WebTestBrowserMain(const content::MainFunctionParams& parameters) { ...@@ -112,3 +231,5 @@ void WebTestBrowserMain(const content::MainFunctionParams& parameters) {
main_runner->Shutdown(); main_runner->Shutdown();
} }
} // namespace content
...@@ -2,13 +2,28 @@ ...@@ -2,13 +2,28 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
#ifndef CONTENT_SHELL_BROWSER_WEB_TEST_WEB_TEST_BROWSER_MAIN_H_ #ifndef CONTENT_SHELL_BROWSER_WEB_TEST_WEB_TEST_BROWSER_MAIN_RUNNER_H_
#define CONTENT_SHELL_BROWSER_WEB_TEST_WEB_TEST_BROWSER_MAIN_H_ #define CONTENT_SHELL_BROWSER_WEB_TEST_WEB_TEST_BROWSER_MAIN_RUNNER_H_
#include "base/files/scoped_temp_dir.h"
namespace content { namespace content {
struct MainFunctionParams; struct MainFunctionParams;
} // namespace content
void WebTestBrowserMain(const content::MainFunctionParams& parameters); class WebTestBrowserMainRunner {
public:
// Run at the beginning of startup, before any child processes (including the
// renderer zygote) are launched. Any command line flags should be set in
// here.
void Initialize();
// Main routine for running as the Browser process.
void RunBrowserMain(const content::MainFunctionParams& parameters);
private:
base::ScopedTempDir browser_context_path_for_web_tests_;
};
} // namespace content
#endif // CONTENT_SHELL_BROWSER_WEB_TEST_WEB_TEST_BROWSER_MAIN_H_ #endif // CONTENT_SHELL_BROWSER_WEB_TEST_WEB_TEST_BROWSER_MAIN_RUNNER_H_
...@@ -15,6 +15,7 @@ ...@@ -15,6 +15,7 @@
#include "base/stl_util.h" #include "base/stl_util.h"
#include "base/strings/pattern.h" #include "base/strings/pattern.h"
#include "base/task/post_task.h" #include "base/task/post_task.h"
#include "cc/base/switches.h"
#include "content/public/browser/browser_context.h" #include "content/public/browser/browser_context.h"
#include "content/public/browser/browser_task_traits.h" #include "content/public/browser/browser_task_traits.h"
#include "content/public/browser/browser_thread.h" #include "content/public/browser/browser_thread.h"
...@@ -57,8 +58,15 @@ ...@@ -57,8 +58,15 @@
#include "services/service_manager/public/cpp/manifest_builder.h" #include "services/service_manager/public/cpp/manifest_builder.h"
#include "storage/browser/quota/quota_settings.h" #include "storage/browser/quota/quota_settings.h"
#include "third_party/blink/public/common/associated_interfaces/associated_interface_registry.h" #include "third_party/blink/public/common/associated_interfaces/associated_interface_registry.h"
#include "ui/base/ui_base_switches.h"
#include "url/origin.h" #include "url/origin.h"
#if defined(OS_WIN)
#include "base/strings/utf_string_conversions.h"
#include "sandbox/win/src/sandbox.h"
#include "services/service_manager/sandbox/win/sandbox_win.h"
#endif
namespace content { namespace content {
namespace { namespace {
...@@ -247,28 +255,26 @@ void WebTestContentBrowserClient::OverrideWebkitPrefs( ...@@ -247,28 +255,26 @@ void WebTestContentBrowserClient::OverrideWebkitPrefs(
void WebTestContentBrowserClient::AppendExtraCommandLineSwitches( void WebTestContentBrowserClient::AppendExtraCommandLineSwitches(
base::CommandLine* command_line, base::CommandLine* command_line,
int child_process_id) { int child_process_id) {
command_line->AppendSwitch(switches::kRunWebTests);
ShellContentBrowserClient::AppendExtraCommandLineSwitches(command_line, ShellContentBrowserClient::AppendExtraCommandLineSwitches(command_line,
child_process_id); child_process_id);
if (base::CommandLine::ForCurrentProcess()->HasSwitch(
switches::kAlwaysUseComplexText)) { static const char* kForwardSwitches[] = {
command_line->AppendSwitch(switches::kAlwaysUseComplexText); // Indicates we're running web tests. Would be present in order to get
} // here.
if (base::CommandLine::ForCurrentProcess()->HasSwitch( switches::kRunWebTests,
switches::kEnableFontAntialiasing)) { // Switches from web_test_switches.h that are used in the renderer.
command_line->AppendSwitch(switches::kEnableFontAntialiasing); switches::kEnableAccelerated2DCanvas,
} switches::kEnableFontAntialiasing,
if (base::CommandLine::ForCurrentProcess()->HasSwitch( switches::kAlwaysUseComplexText,
switches::kStableReleaseMode)) { switches::kStableReleaseMode,
command_line->AppendSwitch(switches::kStableReleaseMode); #if defined(OS_WIN)
} switches::kRegisterFontFiles,
if (base::CommandLine::ForCurrentProcess()->HasSwitch( #endif
switches::kEnableLeakDetection)) { };
command_line->AppendSwitchASCII(
switches::kEnableLeakDetection, command_line->CopySwitchesFrom(*base::CommandLine::ForCurrentProcess(),
base::CommandLine::ForCurrentProcess()->GetSwitchValueASCII( kForwardSwitches,
switches::kEnableLeakDetection)); base::size(kForwardSwitches));
}
} }
std::unique_ptr<BrowserMainParts> std::unique_ptr<BrowserMainParts>
...@@ -480,4 +486,21 @@ void WebTestContentBrowserClient::BindWebTestController( ...@@ -480,4 +486,21 @@ void WebTestContentBrowserClient::BindWebTestController(
network_context, std::move(receiver)); network_context, std::move(receiver));
} }
#if defined(OS_WIN)
bool WebTestContentBrowserClient::PreSpawnRenderer(
sandbox::TargetPolicy* policy,
RendererSpawnFlags flags) {
// Add sideloaded font files for testing. See also DIR_WINDOWS_FONTS
// addition in |StartSandboxedProcess|.
std::vector<std::string> font_files = switches::GetSideloadFontFiles();
for (std::vector<std::string>::const_iterator i(font_files.begin());
i != font_files.end(); ++i) {
policy->AddRule(sandbox::TargetPolicy::SUBSYS_FILES,
sandbox::TargetPolicy::FILES_ALLOW_READONLY,
base::UTF8ToWide(*i).c_str());
}
return true;
}
#endif // OS_WIN
} // namespace content } // namespace content
...@@ -9,6 +9,7 @@ ...@@ -9,6 +9,7 @@
#include <string> #include <string>
#include <vector> #include <vector>
#include "build/build_config.h"
#include "content/public/common/client_hints.mojom.h" #include "content/public/common/client_hints.mojom.h"
#include "content/shell/browser/shell_content_browser_client.h" #include "content/shell/browser/shell_content_browser_client.h"
#include "content/shell/common/blink_test.mojom-forward.h" #include "content/shell/common/blink_test.mojom-forward.h"
...@@ -101,8 +102,6 @@ class WebTestContentBrowserClient : public ShellContentBrowserClient { ...@@ -101,8 +102,6 @@ class WebTestContentBrowserClient : public ShellContentBrowserClient {
content::TtsControllerDelegate* GetTtsControllerDelegate() override; content::TtsControllerDelegate* GetTtsControllerDelegate() override;
content::TtsPlatform* GetTtsPlatform() override; content::TtsPlatform* GetTtsPlatform() override;
bool CanEnterFullscreenWithoutUserActivation() override; bool CanEnterFullscreenWithoutUserActivation() override;
// ShellContentBrowserClient overrides.
std::unique_ptr<LoginDelegate> CreateLoginDelegate( std::unique_ptr<LoginDelegate> CreateLoginDelegate(
const net::AuthChallengeInfo& auth_info, const net::AuthChallengeInfo& auth_info,
content::WebContents* web_contents, content::WebContents* web_contents,
...@@ -112,6 +111,10 @@ class WebTestContentBrowserClient : public ShellContentBrowserClient { ...@@ -112,6 +111,10 @@ class WebTestContentBrowserClient : public ShellContentBrowserClient {
scoped_refptr<net::HttpResponseHeaders> response_headers, scoped_refptr<net::HttpResponseHeaders> response_headers,
bool first_auth_attempt, bool first_auth_attempt,
LoginAuthRequiredCallback auth_required_callback) override; LoginAuthRequiredCallback auth_required_callback) override;
#if defined(OS_WIN)
bool PreSpawnRenderer(sandbox::TargetPolicy* policy,
RendererSpawnFlags flags) override;
#endif
private: private:
// ShellContentBrowserClient overrides. // ShellContentBrowserClient overrides.
......
...@@ -5,7 +5,6 @@ ...@@ -5,7 +5,6 @@
#include "content/shell/common/shell_switches.h" #include "content/shell/common/shell_switches.h"
#include "base/command_line.h" #include "base/command_line.h"
#include "base/strings/string_split.h"
#include "content/shell/common/web_test/web_test_switches.h" #include "content/shell/common/web_test/web_test_switches.h"
namespace switches { namespace switches {
...@@ -20,29 +19,12 @@ const char kCrashDumpsDir[] = "crash-dumps-dir"; ...@@ -20,29 +19,12 @@ const char kCrashDumpsDir[] = "crash-dumps-dir";
// and debugging of web tests that rely on it. // and debugging of web tests that rely on it.
const char kExposeInternalsForTesting[] = "expose-internals-for-testing"; const char kExposeInternalsForTesting[] = "expose-internals-for-testing";
// Registers additional font files on Windows (for fonts outside the usual
// %WINDIR%\Fonts location). Multiple files can be used by separating them
// with a semicolon (;).
const char kRegisterFontFiles[] = "register-font-files";
// Size for the content_shell's host window (i.e. "800x600"). // Size for the content_shell's host window (i.e. "800x600").
const char kContentShellHostWindowSize[] = "content-shell-host-window-size"; const char kContentShellHostWindowSize[] = "content-shell-host-window-size";
// Hides toolbar from content_shell's host window. // Hides toolbar from content_shell's host window.
const char kContentShellHideToolbar[] = "content-shell-hide-toolbar"; const char kContentShellHideToolbar[] = "content-shell-hide-toolbar";
std::vector<std::string> GetSideloadFontFiles() {
std::vector<std::string> files;
const base::CommandLine& command_line =
*base::CommandLine::ForCurrentProcess();
if (command_line.HasSwitch(switches::kRegisterFontFiles)) {
files = base::SplitString(
command_line.GetSwitchValueASCII(switches::kRegisterFontFiles),
";", base::TRIM_WHITESPACE, base::SPLIT_WANT_ALL);
}
return files;
}
bool IsRunWebTestsSwitchPresent() { bool IsRunWebTestsSwitchPresent() {
return base::CommandLine::ForCurrentProcess()->HasSwitch( return base::CommandLine::ForCurrentProcess()->HasSwitch(
switches::kRunWebTests); switches::kRunWebTests);
......
...@@ -15,13 +15,9 @@ namespace switches { ...@@ -15,13 +15,9 @@ namespace switches {
extern const char kContentShellDataPath[]; extern const char kContentShellDataPath[];
extern const char kCrashDumpsDir[]; extern const char kCrashDumpsDir[];
extern const char kExposeInternalsForTesting[]; extern const char kExposeInternalsForTesting[];
extern const char kRegisterFontFiles[];
extern const char kContentShellHostWindowSize[]; extern const char kContentShellHostWindowSize[];
extern const char kContentShellHideToolbar[]; extern const char kContentShellHideToolbar[];
// Returns list of extra font files to be made accessible to the renderer.
std::vector<std::string> GetSideloadFontFiles();
// Tells if content shell is running web_tests. // Tells if content shell is running web_tests.
// TODO(lukasza): The function below somewhat violates the layering (by // TODO(lukasza): The function below somewhat violates the layering (by
// enabling shell -> layout_tests dependency) but at least narrows the extent of // enabling shell -> layout_tests dependency) but at least narrows the extent of
......
...@@ -4,6 +4,9 @@ ...@@ -4,6 +4,9 @@
#include "content/shell/common/web_test/web_test_switches.h" #include "content/shell/common/web_test/web_test_switches.h"
#include "base/command_line.h"
#include "base/strings/string_split.h"
namespace switches { namespace switches {
// Allow access to external pages during web tests. // Allow access to external pages during web tests.
...@@ -47,4 +50,23 @@ const char kStableReleaseMode[] = "stable-release-mode"; ...@@ -47,4 +50,23 @@ const char kStableReleaseMode[] = "stable-release-mode";
// kRunWebTests is set. // kRunWebTests is set.
const char kDisableHeadlessMode[] = "disable-headless-mode"; const char kDisableHeadlessMode[] = "disable-headless-mode";
#if defined(OS_WIN)
// Registers additional font files on Windows (for fonts outside the usual
// %WINDIR%\Fonts location). Multiple files can be used by separating them
// with a semicolon (;).
const char kRegisterFontFiles[] = "register-font-files";
std::vector<std::string> GetSideloadFontFiles() {
std::vector<std::string> files;
const base::CommandLine& command_line =
*base::CommandLine::ForCurrentProcess();
if (command_line.HasSwitch(switches::kRegisterFontFiles)) {
files = base::SplitString(
command_line.GetSwitchValueASCII(switches::kRegisterFontFiles), ";",
base::TRIM_WHITESPACE, base::SPLIT_WANT_ALL);
}
return files;
}
#endif
} // namespace switches } // namespace switches
...@@ -26,6 +26,14 @@ extern const char kRunWebTests[]; ...@@ -26,6 +26,14 @@ extern const char kRunWebTests[];
extern const char kStableReleaseMode[]; extern const char kStableReleaseMode[];
extern const char kDisableHeadlessMode[]; extern const char kDisableHeadlessMode[];
#if defined(OS_WIN)
extern const char kRegisterFontFiles[];
// Returns list of extra font files to be made accessible to the renderer, that
// are specified via kRegisterFontFiles.
std::vector<std::string> GetSideloadFontFiles();
#endif
} // namespace switches } // namespace switches
#endif // CONTENT_SHELL_COMMON_WEB_TEST_WEB_TEST_SWITCHES_H_ #endif // CONTENT_SHELL_COMMON_WEB_TEST_WEB_TEST_SWITCHES_H_
...@@ -10,6 +10,7 @@ ...@@ -10,6 +10,7 @@
#include "base/callback.h" #include "base/callback.h"
#include "base/command_line.h" #include "base/command_line.h"
#include "base/debug/debugger.h" #include "base/debug/debugger.h"
#include "build/build_config.h"
#include "components/web_cache/renderer/web_cache_impl.h" #include "components/web_cache/renderer/web_cache_impl.h"
#include "content/public/common/content_constants.h" #include "content/public/common/content_constants.h"
#include "content/public/common/content_switches.h" #include "content/public/common/content_switches.h"
...@@ -41,6 +42,15 @@ ...@@ -41,6 +42,15 @@
#include "ui/gfx/icc_profile.h" #include "ui/gfx/icc_profile.h"
#include "v8/include/v8.h" #include "v8/include/v8.h"
#if defined(OS_WIN)
#include "third_party/blink/public/web/win/web_font_rendering.h"
#include "third_party/skia/include/ports/SkTypeface_win.h"
#endif
#if defined(OS_FUCHSIA) || defined(OS_MACOSX) || defined(OS_ANDROID)
#include "skia/ext/test_fonts.h"
#endif
using blink::WebAudioDevice; using blink::WebAudioDevice;
using blink::WebFrame; using blink::WebFrame;
using blink::WebLocalFrame; using blink::WebLocalFrame;
...@@ -55,11 +65,30 @@ WebTestContentRendererClient::WebTestContentRendererClient() { ...@@ -55,11 +65,30 @@ WebTestContentRendererClient::WebTestContentRendererClient() {
SetWorkerRewriteURLFunction(RewriteWebTestsURL); SetWorkerRewriteURLFunction(RewriteWebTestsURL);
} }
WebTestContentRendererClient::~WebTestContentRendererClient() {} WebTestContentRendererClient::~WebTestContentRendererClient() = default;
void WebTestContentRendererClient::RenderThreadStarted() { void WebTestContentRendererClient::RenderThreadStarted() {
ShellContentRendererClient::RenderThreadStarted(); ShellContentRendererClient::RenderThreadStarted();
shell_observer_.reset(new WebTestRenderThreadObserver()); shell_observer_ = std::make_unique<WebTestRenderThreadObserver>();
#if defined(OS_FUCHSIA) || defined(OS_MACOSX) || defined(OS_ANDROID)
// On these platforms, fonts are set up in the renderer process. Other
// platforms set up fonts as part of WebTestBrowserMainRunner in the
// browser process, via WebTestBrowserPlatformInitialize().
skia::ConfigureTestFont();
#elif defined(OS_WIN)
// DirectWrite only has access to %WINDIR%\Fonts by default. For developer
// side-loading, support kRegisterFontFiles to allow access to additional
// fonts. The browser process sets these files and punches a hole in the
// sandbox for the renderer to load them here.
{
sk_sp<SkFontMgr> fontmgr = SkFontMgr_New_DirectWrite();
for (const auto& file : switches::GetSideloadFontFiles()) {
sk_sp<SkTypeface> typeface = fontmgr->makeFromFile(file.c_str());
blink::WebFontRendering::AddSideloadedFontForTesting(std::move(typeface));
}
}
#endif
} }
void WebTestContentRendererClient::RenderFrameCreated( void WebTestContentRendererClient::RenderFrameCreated(
......
...@@ -22,7 +22,6 @@ ...@@ -22,7 +22,6 @@
#include "content/renderer/render_thread_impl.h" #include "content/renderer/render_thread_impl.h"
#include "content/renderer/render_view_impl.h" #include "content/renderer/render_view_impl.h"
#include "content/renderer/render_widget.h" #include "content/renderer/render_widget.h"
#include "content/shell/common/shell_switches.h"
#include "content/shell/renderer/web_test/blink_test_runner.h" #include "content/shell/renderer/web_test/blink_test_runner.h"
#include "content/shell/renderer/web_test/web_test_render_thread_observer.h" #include "content/shell/renderer/web_test/web_test_render_thread_observer.h"
#include "content/shell/test_runner/web_frame_test_proxy.h" #include "content/shell/test_runner/web_frame_test_proxy.h"
...@@ -46,12 +45,6 @@ ...@@ -46,12 +45,6 @@
#include "content/browser/frame_host/popup_menu_helper_mac.h" #include "content/browser/frame_host/popup_menu_helper_mac.h"
#include "content/browser/sandbox_parameters_mac.h" #include "content/browser/sandbox_parameters_mac.h"
#include "net/test/test_data_directory.h" #include "net/test/test_data_directory.h"
#elif defined(OS_WIN)
#include "content/child/font_warmup_win.h"
#include "third_party/blink/public/web/win/web_font_rendering.h"
#include "third_party/skia/include/core/SkFontMgr.h"
#include "third_party/skia/include/core/SkRefCnt.h"
#include "third_party/skia/include/ports/SkTypeface_win.h"
#endif #endif
using blink::WebRect; using blink::WebRect;
...@@ -106,17 +99,6 @@ RenderFrameImpl* CreateWebFrameTestProxy(RenderFrameImpl::CreateParams params) { ...@@ -106,17 +99,6 @@ RenderFrameImpl* CreateWebFrameTestProxy(RenderFrameImpl::CreateParams params) {
return render_frame_proxy; return render_frame_proxy;
} }
#if defined(OS_WIN)
// DirectWrite only has access to %WINDIR%\Fonts by default. For developer
// side-loading, support kRegisterFontFiles to allow access to additional fonts.
void RegisterSideloadedTypefaces(SkFontMgr* fontmgr) {
for (const auto& file : switches::GetSideloadFontFiles()) {
blink::WebFontRendering::AddSideloadedFontForTesting(
fontmgr->makeFromFile(file.c_str()));
}
}
#endif // OS_WIN
} // namespace } // namespace
test_runner::WebWidgetTestProxy* GetWebWidgetTestProxy( test_runner::WebWidgetTestProxy* GetWebWidgetTestProxy(
...@@ -150,10 +132,6 @@ void EnableRendererWebTestMode() { ...@@ -150,10 +132,6 @@ void EnableRendererWebTestMode() {
RenderThreadImpl::current()->enable_web_test_mode(); RenderThreadImpl::current()->enable_web_test_mode();
UniqueNameHelper::PreserveStableUniqueNameForTesting(); UniqueNameHelper::PreserveStableUniqueNameForTesting();
#if defined(OS_WIN)
RegisterSideloadedTypefaces(SkFontMgr_New_DirectWrite().get());
#endif
} }
void EnableBrowserWebTestMode() { void EnableBrowserWebTestMode() {
......
...@@ -898,9 +898,6 @@ source_set("test_fonts") { ...@@ -898,9 +898,6 @@ source_set("test_fonts") {
"//third_party/fuchsia-sdk/sdk/pkg/sys_cpp", "//third_party/fuchsia-sdk/sdk/pkg/sys_cpp",
] ]
} }
if (is_linux) {
sources += [ "ext/test_fonts_linux.cc" ]
}
if (is_mac) { if (is_mac) {
sources += [ "ext/test_fonts_mac.mm" ] sources += [ "ext/test_fonts_mac.mm" ]
} }
......
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