| OLD | NEW |
| 1 // Copyright (c) 2014 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "content/shell/renderer/layout_test/layout_test_content_renderer_client
.h" | 5 #include "content/shell/renderer/layout_test/layout_test_content_renderer_client
.h" |
| 6 | 6 |
| 7 #include "base/callback.h" | 7 #include "base/callback.h" |
| 8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
| 9 #include "base/debug/debugger.h" | 9 #include "base/debug/debugger.h" |
| 10 #include "components/test_runner/mock_credential_manager_client.h" | 10 #include "components/test_runner/mock_credential_manager_client.h" |
| 11 #include "components/test_runner/web_frame_test_proxy.h" | 11 #include "components/test_runner/web_frame_test_proxy.h" |
| 12 #include "components/test_runner/web_test_interfaces.h" | 12 #include "components/test_runner/web_test_interfaces.h" |
| 13 #include "components/test_runner/web_test_runner.h" | 13 #include "components/test_runner/web_test_runner.h" |
| 14 #include "components/test_runner/web_view_test_proxy.h" | 14 #include "components/test_runner/web_view_test_proxy.h" |
| 15 #include "components/web_cache/renderer/web_cache_impl.h" | 15 #include "components/web_cache/renderer/web_cache_impl.h" |
| 16 #include "content/public/common/content_constants.h" | 16 #include "content/public/common/content_constants.h" |
| 17 #include "content/public/common/content_switches.h" | 17 #include "content/public/common/content_switches.h" |
| 18 #include "content/public/renderer/render_frame.h" | 18 #include "content/public/renderer/render_frame.h" |
| 19 #include "content/public/renderer/render_thread.h" |
| 19 #include "content/public/renderer/render_view.h" | 20 #include "content/public/renderer/render_view.h" |
| 20 #include "content/public/test/layouttest_support.h" | 21 #include "content/public/test/layouttest_support.h" |
| 21 #include "content/shell/common/layout_test/layout_test_switches.h" | 22 #include "content/shell/common/layout_test/layout_test_switches.h" |
| 22 #include "content/shell/common/shell_switches.h" | 23 #include "content/shell/common/shell_switches.h" |
| 23 #include "content/shell/renderer/layout_test/blink_test_helpers.h" | 24 #include "content/shell/renderer/layout_test/blink_test_helpers.h" |
| 24 #include "content/shell/renderer/layout_test/blink_test_runner.h" | 25 #include "content/shell/renderer/layout_test/blink_test_runner.h" |
| 26 #include "content/shell/renderer/layout_test/interface_registry_js_wrapper.h" |
| 25 #include "content/shell/renderer/layout_test/layout_test_render_frame_observer.h
" | 27 #include "content/shell/renderer/layout_test/layout_test_render_frame_observer.h
" |
| 26 #include "content/shell/renderer/layout_test/layout_test_render_thread_observer.
h" | 28 #include "content/shell/renderer/layout_test/layout_test_render_thread_observer.
h" |
| 27 #include "content/shell/renderer/layout_test/test_media_stream_renderer_factory.
h" | 29 #include "content/shell/renderer/layout_test/test_media_stream_renderer_factory.
h" |
| 28 #include "content/shell/renderer/shell_render_view_observer.h" | 30 #include "content/shell/renderer/shell_render_view_observer.h" |
| 29 #include "content/test/mock_webclipboard_impl.h" | 31 #include "content/test/mock_webclipboard_impl.h" |
| 32 #include "gin/modules/module_registry.h" |
| 30 #include "ppapi/shared_impl/ppapi_switches.h" | 33 #include "ppapi/shared_impl/ppapi_switches.h" |
| 31 #include "third_party/WebKit/public/platform/WebMediaStreamCenter.h" | 34 #include "third_party/WebKit/public/platform/WebMediaStreamCenter.h" |
| 32 #include "third_party/WebKit/public/platform/modules/app_banner/WebAppBannerClie
nt.h" | 35 #include "third_party/WebKit/public/platform/modules/app_banner/WebAppBannerClie
nt.h" |
| 33 #include "third_party/WebKit/public/web/WebFrameWidget.h" | 36 #include "third_party/WebKit/public/web/WebFrameWidget.h" |
| 34 #include "third_party/WebKit/public/web/WebKit.h" | 37 #include "third_party/WebKit/public/web/WebKit.h" |
| 35 #include "third_party/WebKit/public/web/WebPluginParams.h" | 38 #include "third_party/WebKit/public/web/WebPluginParams.h" |
| 36 #include "third_party/WebKit/public/web/WebRuntimeFeatures.h" | 39 #include "third_party/WebKit/public/web/WebRuntimeFeatures.h" |
| 37 #include "third_party/WebKit/public/web/WebTestingSupport.h" | 40 #include "third_party/WebKit/public/web/WebTestingSupport.h" |
| 38 #include "third_party/WebKit/public/web/WebView.h" | 41 #include "third_party/WebKit/public/web/WebView.h" |
| 39 #include "ui/gfx/icc_profile.h" | 42 #include "ui/gfx/icc_profile.h" |
| (...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 242 #else | 245 #else |
| 243 return base::WrapUnique(new gfx::ICCProfile()); | 246 return base::WrapUnique(new gfx::ICCProfile()); |
| 244 #endif | 247 #endif |
| 245 } | 248 } |
| 246 | 249 |
| 247 void LayoutTestContentRendererClient::DidInitializeWorkerContextOnWorkerThread( | 250 void LayoutTestContentRendererClient::DidInitializeWorkerContextOnWorkerThread( |
| 248 v8::Local<v8::Context> context) { | 251 v8::Local<v8::Context> context) { |
| 249 blink::WebTestingSupport::injectInternalsObject(context); | 252 blink::WebTestingSupport::injectInternalsObject(context); |
| 250 } | 253 } |
| 251 | 254 |
| 255 void LayoutTestContentRendererClient::RunScriptsAtDocumentEnd( |
| 256 RenderFrame* render_frame) { |
| 257 v8::Isolate* isolate = blink::mainThreadIsolate(); |
| 258 v8::HandleScope handle_scope(isolate); |
| 259 blink::WebLocalFrame* frame = render_frame->GetWebFrame(); |
| 260 v8::Local<v8::Context> context = frame->mainWorldScriptContext(); |
| 261 v8::Context::Scope context_scope(context); |
| 262 |
| 263 gin::ModuleRegistry* registry = gin::ModuleRegistry::From(context); |
| 264 if (registry->available_modules().count( |
| 265 InterfaceRegistryJsWrapper::kPerFrameModuleName)) { |
| 266 return; |
| 267 } |
| 268 |
| 269 registry->AddBuiltinModule( |
| 270 isolate, InterfaceRegistryJsWrapper::kPerFrameModuleName, |
| 271 InterfaceRegistryJsWrapper::Create(isolate, context, |
| 272 render_frame->GetInterfaceRegistry()) |
| 273 .ToV8()); |
| 274 registry->AddBuiltinModule( |
| 275 isolate, InterfaceRegistryJsWrapper::kPerProcessModuleName, |
| 276 InterfaceRegistryJsWrapper::Create( |
| 277 isolate, context, RenderThread::Get()->GetInterfaceRegistry()) |
| 278 .ToV8()); |
| 279 registry->AttemptToLoadMoreModules(isolate); |
| 280 } |
| 281 |
| 252 void LayoutTestContentRendererClient:: | 282 void LayoutTestContentRendererClient:: |
| 253 SetRuntimeFeaturesDefaultsBeforeBlinkInitialization() { | 283 SetRuntimeFeaturesDefaultsBeforeBlinkInitialization() { |
| 254 // We always expose GC to layout tests. | 284 // We always expose GC to layout tests. |
| 255 std::string flags("--expose-gc"); | 285 std::string flags("--expose-gc"); |
| 256 v8::V8::SetFlagsFromString(flags.c_str(), static_cast<int>(flags.size())); | 286 v8::V8::SetFlagsFromString(flags.c_str(), static_cast<int>(flags.size())); |
| 257 if (!base::CommandLine::ForCurrentProcess()->HasSwitch( | 287 if (!base::CommandLine::ForCurrentProcess()->HasSwitch( |
| 258 switches::kStableReleaseMode)) { | 288 switches::kStableReleaseMode)) { |
| 259 blink::WebRuntimeFeatures::enableTestOnlyFeatures(true); | 289 blink::WebRuntimeFeatures::enableTestOnlyFeatures(true); |
| 260 } | 290 } |
| 261 if (base::CommandLine::ForCurrentProcess()->HasSwitch( | 291 if (base::CommandLine::ForCurrentProcess()->HasSwitch( |
| 262 switches::kEnableFontAntialiasing)) { | 292 switches::kEnableFontAntialiasing)) { |
| 263 blink::setFontAntialiasingEnabledForTest(true); | 293 blink::setFontAntialiasingEnabledForTest(true); |
| 264 } | 294 } |
| 265 if (base::CommandLine::ForCurrentProcess()->HasSwitch( | 295 if (base::CommandLine::ForCurrentProcess()->HasSwitch( |
| 266 switches::kAlwaysUseComplexText)) { | 296 switches::kAlwaysUseComplexText)) { |
| 267 blink::setAlwaysUseComplexTextForTest(true); | 297 blink::setAlwaysUseComplexTextForTest(true); |
| 268 } | 298 } |
| 269 } | 299 } |
| 270 | 300 |
| 271 } // namespace content | 301 } // namespace content |
| OLD | NEW |