| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/shell_render_process_observer.h" | 5 #include "content/shell/shell_render_process_observer.h" |
| 6 | 6 |
| 7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
| 8 #include "content/public/renderer/render_view.h" | 8 #include "content/public/renderer/render_view.h" |
| 9 #include "content/public/renderer/render_thread.h" | 9 #include "content/public/renderer/render_thread.h" |
| 10 #include "content/public/test/layouttest_support.h" | 10 #include "content/public/test/layouttest_support.h" |
| 11 #include "content/shell/shell_messages.h" | 11 #include "content/shell/shell_messages.h" |
| 12 #include "content/shell/shell_switches.h" | 12 #include "content/shell/shell_switches.h" |
| 13 #include "content/shell/webkit_test_runner.h" | 13 #include "content/shell/webkit_test_runner.h" |
| 14 #include "content/shell/webkit_test_runner_bindings.h" | 14 #include "content/shell/webkit_test_runner_bindings.h" |
| 15 #include "third_party/WebKit/Source/WebKit/chromium/public/WebRuntimeFeatures.h" | 15 #include "third_party/WebKit/Source/WebKit/chromium/public/WebRuntimeFeatures.h" |
| 16 #include "third_party/WebKit/Source/WebKit/chromium/public/WebTestingSupport.h" | 16 #include "third_party/WebKit/Source/WebKit/chromium/public/WebTestingSupport.h" |
| 17 #include "third_party/WebKit/Source/WebKit/chromium/public/WebView.h" | 17 #include "third_party/WebKit/Source/WebKit/chromium/public/WebView.h" |
| 18 #include "third_party/WebKit/Tools/DumpRenderTree/chromium/TestRunner/public/Web
TestInterfaces.h" | |
| 19 #include "webkit/glue/webkit_glue.h" | 18 #include "webkit/glue/webkit_glue.h" |
| 20 #include "webkit/support/gc_extension.h" | 19 #include "webkit/support/gc_extension.h" |
| 21 | 20 |
| 22 using WebKit::WebFrame; | 21 using WebKit::WebFrame; |
| 23 using WebKit::WebRuntimeFeatures; | 22 using WebKit::WebRuntimeFeatures; |
| 24 using WebKit::WebTestingSupport; | 23 using WebKit::WebTestingSupport; |
| 25 using WebTestRunner::WebTestDelegate; | 24 using WebTestRunner::WebTestDelegate; |
| 26 using WebTestRunner::WebTestInterfaces; | |
| 27 | 25 |
| 28 namespace content { | 26 namespace content { |
| 29 | 27 |
| 30 namespace { | 28 namespace { |
| 31 ShellRenderProcessObserver* g_instance = NULL; | 29 ShellRenderProcessObserver* g_instance = NULL; |
| 32 } | 30 } |
| 33 | 31 |
| 34 // static | 32 // static |
| 35 ShellRenderProcessObserver* ShellRenderProcessObserver::GetInstance() { | 33 ShellRenderProcessObserver* ShellRenderProcessObserver::GetInstance() { |
| 36 return g_instance; | 34 return g_instance; |
| (...skipping 19 matching lines...) Expand all Loading... |
| 56 | 54 |
| 57 ShellRenderProcessObserver::~ShellRenderProcessObserver() { | 55 ShellRenderProcessObserver::~ShellRenderProcessObserver() { |
| 58 CHECK(g_instance == this); | 56 CHECK(g_instance == this); |
| 59 g_instance = NULL; | 57 g_instance = NULL; |
| 60 } | 58 } |
| 61 | 59 |
| 62 void ShellRenderProcessObserver::SetMainWindow( | 60 void ShellRenderProcessObserver::SetMainWindow( |
| 63 RenderView* view, | 61 RenderView* view, |
| 64 WebKitTestRunner* test_runner, | 62 WebKitTestRunner* test_runner, |
| 65 WebTestDelegate* delegate) { | 63 WebTestDelegate* delegate) { |
| 66 test_interfaces_->setDelegate(delegate); | |
| 67 test_interfaces_->setWebView(view->GetWebView()); | |
| 68 test_interfaces_->setTestRunner(test_runner); | |
| 69 main_render_view_ = view; | 64 main_render_view_ = view; |
| 70 main_test_runner_ = test_runner; | 65 main_test_runner_ = test_runner; |
| 71 test_delegate_ = delegate; | 66 test_delegate_ = delegate; |
| 72 } | 67 } |
| 73 | 68 |
| 74 void ShellRenderProcessObserver::BindTestRunnersToWindow(WebFrame* frame) { | 69 void ShellRenderProcessObserver::BindTestRunnersToWindow(WebFrame* frame) { |
| 75 WebTestingSupport::injectInternalsObject(frame); | 70 WebTestingSupport::injectInternalsObject(frame); |
| 76 test_interfaces_->bindTo(frame); | |
| 77 } | 71 } |
| 78 | 72 |
| 79 void ShellRenderProcessObserver::WebKitInitialized() { | 73 void ShellRenderProcessObserver::WebKitInitialized() { |
| 80 if (!CommandLine::ForCurrentProcess()->HasSwitch(switches::kDumpRenderTree)) | 74 if (!CommandLine::ForCurrentProcess()->HasSwitch(switches::kDumpRenderTree)) |
| 81 return; | 75 return; |
| 82 | 76 |
| 83 // To implement a catch-all for not yet implemented controller properties. | 77 // To implement a catch-all for not yet implemented controller properties. |
| 84 webkit_glue::SetJavaScriptFlags(" --harmony_proxies"); | 78 webkit_glue::SetJavaScriptFlags(" --harmony_proxies"); |
| 85 RenderThread::Get()->RegisterExtension(new WebKitTestRunnerBindings()); | 79 RenderThread::Get()->RegisterExtension(new WebKitTestRunnerBindings()); |
| 86 | 80 |
| 87 // We always expose GC to layout tests. | 81 // We always expose GC to layout tests. |
| 88 webkit_glue::SetJavaScriptFlags(" --expose-gc"); | 82 webkit_glue::SetJavaScriptFlags(" --expose-gc"); |
| 89 RenderThread::Get()->RegisterExtension(extensions_v8::GCExtension::Get()); | 83 RenderThread::Get()->RegisterExtension(extensions_v8::GCExtension::Get()); |
| 90 | |
| 91 test_interfaces_.reset(new WebTestInterfaces); | |
| 92 } | 84 } |
| 93 | 85 |
| 94 bool ShellRenderProcessObserver::OnControlMessageReceived( | 86 bool ShellRenderProcessObserver::OnControlMessageReceived( |
| 95 const IPC::Message& message) { | 87 const IPC::Message& message) { |
| 96 bool handled = true; | 88 bool handled = true; |
| 97 IPC_BEGIN_MESSAGE_MAP(ShellRenderProcessObserver, message) | 89 IPC_BEGIN_MESSAGE_MAP(ShellRenderProcessObserver, message) |
| 98 IPC_MESSAGE_HANDLER(ShellViewMsg_ResetAll, OnResetAll) | 90 IPC_MESSAGE_HANDLER(ShellViewMsg_ResetAll, OnResetAll) |
| 99 IPC_MESSAGE_HANDLER(ShellViewMsg_SetWebKitSourceDir, OnSetWebKitSourceDir) | 91 IPC_MESSAGE_HANDLER(ShellViewMsg_SetWebKitSourceDir, OnSetWebKitSourceDir) |
| 100 IPC_MESSAGE_UNHANDLED(handled = false) | 92 IPC_MESSAGE_UNHANDLED(handled = false) |
| 101 IPC_END_MESSAGE_MAP() | 93 IPC_END_MESSAGE_MAP() |
| 102 | 94 |
| 103 return handled; | 95 return handled; |
| 104 } | 96 } |
| 105 | 97 |
| 106 void ShellRenderProcessObserver::OnResetAll() { | 98 void ShellRenderProcessObserver::OnResetAll() { |
| 107 test_interfaces_->resetAll(); | |
| 108 if (main_render_view_) { | 99 if (main_render_view_) { |
| 109 main_test_runner_->Reset(); | 100 main_test_runner_->Reset(); |
| 110 WebTestingSupport::resetInternalsObject( | 101 WebTestingSupport::resetInternalsObject( |
| 111 main_render_view_->GetWebView()->mainFrame()); | 102 main_render_view_->GetWebView()->mainFrame()); |
| 112 } | 103 } |
| 113 WebKitTestRunnerBindings::Reset(); | 104 WebKitTestRunnerBindings::Reset(); |
| 114 } | 105 } |
| 115 | 106 |
| 116 void ShellRenderProcessObserver::OnSetWebKitSourceDir( | 107 void ShellRenderProcessObserver::OnSetWebKitSourceDir( |
| 117 const FilePath& webkit_source_dir) { | 108 const FilePath& webkit_source_dir) { |
| 118 webkit_source_dir_ = webkit_source_dir; | 109 webkit_source_dir_ = webkit_source_dir; |
| 119 } | 110 } |
| 120 | 111 |
| 121 } // namespace content | 112 } // namespace content |
| OLD | NEW |