Commit 852ffcf3 authored by hlopko's avatar hlopko Committed by Commit bot

Enable runtime features with status=test before WebKit

There was a sligh difference in how status=test and status=experimental were
handled. Content turned on experimental features before initializing webkit and
the content shell enabled test features *after* webkit was started. This is a
problem when the feature alters webkit initialization.

This cl moves enabling test features to the place where experimental features
are enabled.

BUG=268240
LOG=no

Review-Url: https://codereview.chromium.org/2345233002
Cr-Commit-Position: refs/heads/master@{#419192}
parent b15725be
...@@ -338,6 +338,10 @@ class CONTENT_EXPORT ContentRendererClient { ...@@ -338,6 +338,10 @@ class CONTENT_EXPORT ContentRendererClient {
// This method may invalidate the frame. // This method may invalidate the frame.
virtual void RunScriptsAtDocumentEnd(RenderFrame* render_frame) {} virtual void RunScriptsAtDocumentEnd(RenderFrame* render_frame) {}
// Allows subclasses to enable some runtime features before Blink has
// started.
virtual void SetRuntimeFeaturesDefaultsBeforeBlinkInitialization() {}
// Notifies that a service worker context has been created. This function // Notifies that a service worker context has been created. This function
// is called from the worker thread. // is called from the worker thread.
virtual void DidInitializeServiceWorkerContextOnWorkerThread( virtual void DidInitializeServiceWorkerContextOnWorkerThread(
......
...@@ -1171,6 +1171,9 @@ void RenderThreadImpl::InitializeWebKit( ...@@ -1171,6 +1171,9 @@ void RenderThreadImpl::InitializeWebKit(
#endif #endif
SetRuntimeFeaturesDefaultsAndUpdateFromArgs(command_line); SetRuntimeFeaturesDefaultsAndUpdateFromArgs(command_line);
GetContentClient()
->renderer()
->SetRuntimeFeaturesDefaultsBeforeBlinkInitialization();
blink_platform_impl_.reset(new RendererBlinkPlatformImpl( blink_platform_impl_.reset(new RendererBlinkPlatformImpl(
renderer_scheduler_.get(), renderer_scheduler_.get(),
......
...@@ -18,6 +18,7 @@ ...@@ -18,6 +18,7 @@
#include "content/public/renderer/render_frame.h" #include "content/public/renderer/render_frame.h"
#include "content/public/renderer/render_view.h" #include "content/public/renderer/render_view.h"
#include "content/public/test/layouttest_support.h" #include "content/public/test/layouttest_support.h"
#include "content/shell/common/layout_test/layout_test_switches.h"
#include "content/shell/common/shell_switches.h" #include "content/shell/common/shell_switches.h"
#include "content/shell/renderer/layout_test/blink_test_helpers.h" #include "content/shell/renderer/layout_test/blink_test_helpers.h"
#include "content/shell/renderer/layout_test/blink_test_runner.h" #include "content/shell/renderer/layout_test/blink_test_runner.h"
...@@ -30,7 +31,9 @@ ...@@ -30,7 +31,9 @@
#include "third_party/WebKit/public/platform/WebMediaStreamCenter.h" #include "third_party/WebKit/public/platform/WebMediaStreamCenter.h"
#include "third_party/WebKit/public/platform/modules/app_banner/WebAppBannerClient.h" #include "third_party/WebKit/public/platform/modules/app_banner/WebAppBannerClient.h"
#include "third_party/WebKit/public/web/WebFrameWidget.h" #include "third_party/WebKit/public/web/WebFrameWidget.h"
#include "third_party/WebKit/public/web/WebKit.h"
#include "third_party/WebKit/public/web/WebPluginParams.h" #include "third_party/WebKit/public/web/WebPluginParams.h"
#include "third_party/WebKit/public/web/WebRuntimeFeatures.h"
#include "third_party/WebKit/public/web/WebTestingSupport.h" #include "third_party/WebKit/public/web/WebTestingSupport.h"
#include "third_party/WebKit/public/web/WebView.h" #include "third_party/WebKit/public/web/WebView.h"
#include "ui/gfx/icc_profile.h" #include "ui/gfx/icc_profile.h"
...@@ -247,4 +250,23 @@ void LayoutTestContentRendererClient::DidInitializeWorkerContextOnWorkerThread( ...@@ -247,4 +250,23 @@ void LayoutTestContentRendererClient::DidInitializeWorkerContextOnWorkerThread(
blink::WebTestingSupport::injectInternalsObject(context); blink::WebTestingSupport::injectInternalsObject(context);
} }
void LayoutTestContentRendererClient::
SetRuntimeFeaturesDefaultsBeforeBlinkInitialization() {
// We always expose GC to layout tests.
std::string flags("--expose-gc");
v8::V8::SetFlagsFromString(flags.c_str(), static_cast<int>(flags.size()));
if (!base::CommandLine::ForCurrentProcess()->HasSwitch(
switches::kStableReleaseMode)) {
blink::WebRuntimeFeatures::enableTestOnlyFeatures(true);
}
if (base::CommandLine::ForCurrentProcess()->HasSwitch(
switches::kEnableFontAntialiasing)) {
blink::setFontAntialiasingEnabledForTest(true);
}
if (base::CommandLine::ForCurrentProcess()->HasSwitch(
switches::kAlwaysUseComplexText)) {
blink::setAlwaysUseComplexTextForTest(true);
}
}
} // namespace content } // namespace content
...@@ -39,6 +39,7 @@ class LayoutTestContentRendererClient : public ShellContentRendererClient { ...@@ -39,6 +39,7 @@ class LayoutTestContentRendererClient : public ShellContentRendererClient {
std::unique_ptr<gfx::ICCProfile> GetImageDecodeColorProfile() override; std::unique_ptr<gfx::ICCProfile> GetImageDecodeColorProfile() override;
void DidInitializeWorkerContextOnWorkerThread( void DidInitializeWorkerContextOnWorkerThread(
v8::Local<v8::Context> context) override; v8::Local<v8::Context> context) override;
void SetRuntimeFeaturesDefaultsBeforeBlinkInitialization() override;
private: private:
std::unique_ptr<LayoutTestRenderThreadObserver> shell_observer_; std::unique_ptr<LayoutTestRenderThreadObserver> shell_observer_;
......
...@@ -4,7 +4,6 @@ ...@@ -4,7 +4,6 @@
#include "content/shell/renderer/layout_test/layout_test_render_thread_observer.h" #include "content/shell/renderer/layout_test/layout_test_render_thread_observer.h"
#include "base/command_line.h"
#include "components/test_runner/test_interfaces.h" #include "components/test_runner/test_interfaces.h"
#include "components/test_runner/web_test_interfaces.h" #include "components/test_runner/web_test_interfaces.h"
#include "components/test_runner/web_test_runner.h" #include "components/test_runner/web_test_runner.h"
...@@ -14,12 +13,6 @@ ...@@ -14,12 +13,6 @@
#include "content/shell/common/layout_test/layout_test_messages.h" #include "content/shell/common/layout_test/layout_test_messages.h"
#include "content/shell/common/layout_test/layout_test_switches.h" #include "content/shell/common/layout_test/layout_test_switches.h"
#include "content/shell/common/shell_messages.h" #include "content/shell/common/shell_messages.h"
#include "third_party/WebKit/public/web/WebKit.h"
#include "third_party/WebKit/public/web/WebRuntimeFeatures.h"
#include "v8/include/v8.h"
using blink::WebFrame;
using blink::WebRuntimeFeatures;
namespace content { namespace content {
...@@ -39,25 +32,8 @@ LayoutTestRenderThreadObserver::LayoutTestRenderThreadObserver() { ...@@ -39,25 +32,8 @@ LayoutTestRenderThreadObserver::LayoutTestRenderThreadObserver() {
RenderThread::Get()->AddObserver(this); RenderThread::Get()->AddObserver(this);
EnableRendererLayoutTestMode(); EnableRendererLayoutTestMode();
// We always expose GC to layout tests.
std::string flags("--expose-gc");
v8::V8::SetFlagsFromString(flags.c_str(), static_cast<int>(flags.size()));
if (!base::CommandLine::ForCurrentProcess()->HasSwitch(
switches::kStableReleaseMode)) {
WebRuntimeFeatures::enableTestOnlyFeatures(true);
}
test_interfaces_.reset(new test_runner::WebTestInterfaces); test_interfaces_.reset(new test_runner::WebTestInterfaces);
test_interfaces_->ResetAll(); test_interfaces_->ResetAll();
if (base::CommandLine::ForCurrentProcess()->HasSwitch(
switches::kEnableFontAntialiasing)) {
blink::setFontAntialiasingEnabledForTest(true);
}
if (base::CommandLine::ForCurrentProcess()->HasSwitch(
switches::kAlwaysUseComplexText)) {
blink::setAlwaysUseComplexTextForTest(true);
}
} }
LayoutTestRenderThreadObserver::~LayoutTestRenderThreadObserver() { LayoutTestRenderThreadObserver::~LayoutTestRenderThreadObserver() {
......
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