summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--content/shell/shell.cc16
-rw-r--r--content/shell/shell.h3
-rw-r--r--content/shell/shell_messages.h2
-rw-r--r--content/shell/webkit_test_controller.cc24
-rw-r--r--content/shell/webkit_test_controller.h2
-rw-r--r--content/shell/webkit_test_runner.cc17
-rw-r--r--content/shell/webkit_test_runner.h4
-rw-r--r--content/shell/webkit_test_runner.js10
-rw-r--r--content/shell/webkit_test_runner_bindings.cc40
9 files changed, 111 insertions, 7 deletions
diff --git a/content/shell/shell.cc b/content/shell/shell.cc
index db6b856..739630b 100644
--- a/content/shell/shell.cc
+++ b/content/shell/shell.cc
@@ -41,7 +41,8 @@ base::Callback<void(Shell*)> Shell::shell_created_callback_;
bool Shell::quit_message_loop_ = true;
Shell::Shell(WebContents* web_contents)
- : is_fullscreen_(false),
+ : dev_tools_(NULL),
+ is_fullscreen_(false),
window_(NULL),
url_edit_view_(NULL)
#if defined(OS_WIN) && !defined(USE_AURA)
@@ -159,6 +160,10 @@ void Shell::UpdateNavigationControls() {
}
void Shell::ShowDevTools() {
+ if (dev_tools_) {
+ dev_tools_->web_contents()->Focus();
+ return;
+ }
ShellContentBrowserClient* browser_client =
static_cast<ShellContentBrowserClient*>(
GetContentClient()->browser());
@@ -166,11 +171,18 @@ void Shell::ShowDevTools() {
browser_client->shell_browser_main_parts()->devtools_delegate();
GURL url = delegate->devtools_http_handler()->GetFrontendURL(
web_contents()->GetRenderViewHost());
- CreateNewWindow(
+ dev_tools_ = CreateNewWindow(
web_contents()->GetBrowserContext(),
url, NULL, MSG_ROUTING_NONE, NULL);
}
+void Shell::CloseDevTools() {
+ if (!dev_tools_)
+ return;
+ dev_tools_->Close();
+ dev_tools_ = NULL;
+}
+
gfx::NativeView Shell::GetContentView() {
if (!web_contents_.get())
return NULL;
diff --git a/content/shell/shell.h b/content/shell/shell.h
index 441efcb..24173b9 100644
--- a/content/shell/shell.h
+++ b/content/shell/shell.h
@@ -59,6 +59,7 @@ class Shell : public WebContentsDelegate,
void UpdateNavigationControls();
void Close();
void ShowDevTools();
+ void CloseDevTools();
// Do one time initialization at application startup.
static void PlatformInitialize();
@@ -206,6 +207,8 @@ class Shell : public WebContentsDelegate,
scoped_ptr<WebContents> web_contents_;
+ Shell* dev_tools_;
+
bool is_fullscreen_;
gfx::NativeWindow window_;
diff --git a/content/shell/shell_messages.h b/content/shell/shell_messages.h
index 49d2738..d3e5cfe 100644
--- a/content/shell/shell_messages.h
+++ b/content/shell/shell_messages.h
@@ -70,6 +70,8 @@ IPC_MESSAGE_ROUTED0(ShellViewHostMsg_WaitUntilDone)
IPC_MESSAGE_ROUTED1(ShellViewHostMsg_OverridePreferences,
content::ShellWebPreferences /* preferences */)
IPC_MESSAGE_ROUTED0(ShellViewHostMsg_CanOpenWindows)
+IPC_MESSAGE_ROUTED0(ShellViewHostMsg_ShowWebInspector)
+IPC_MESSAGE_ROUTED0(ShellViewHostMsg_CloseWebInspector)
IPC_MESSAGE_ROUTED2(ShellViewHostMsg_NotImplemented,
std::string /* object_name */,
diff --git a/content/shell/webkit_test_controller.cc b/content/shell/webkit_test_controller.cc
index caeee9d..1e9a62e 100644
--- a/content/shell/webkit_test_controller.cc
+++ b/content/shell/webkit_test_controller.cc
@@ -148,11 +148,6 @@ bool WebKitTestController::PrepareForLayoutTest(
current_working_directory_ = current_working_directory;
enable_pixel_dumping_ = enable_pixel_dumping;
expected_pixel_hash_ = expected_pixel_hash;
- if (test_url.spec().find("/dumpAsText/") != std::string::npos ||
- test_url.spec().find("\\dumpAsText\\") != std::string::npos) {
- dump_as_text_ = true;
- enable_pixel_dumping_ = false;
- }
printer_->reset();
printer_->PrintTextHeader();
content::ShellBrowserContext* browser_context =
@@ -165,6 +160,15 @@ bool WebKitTestController::PrepareForLayoutTest(
MSG_ROUTING_NONE,
NULL);
Observe(main_window_->web_contents());
+ if (test_url.spec().find("/dumpAsText/") != std::string::npos ||
+ test_url.spec().find("\\dumpAsText\\") != std::string::npos) {
+ dump_as_text_ = true;
+ enable_pixel_dumping_ = false;
+ }
+ if (test_url.spec().find("/inspector/") != std::string::npos ||
+ test_url.spec().find("\\inspector\\") != std::string::npos) {
+ main_window_->ShowDevTools();
+ }
return true;
}
@@ -226,6 +230,8 @@ bool WebKitTestController::OnMessageReceived(const IPC::Message& message) {
OnSetShouldStayOnPageAfterHandlingBeforeUnload)
IPC_MESSAGE_HANDLER(ShellViewHostMsg_WaitUntilDone, OnWaitUntilDone)
IPC_MESSAGE_HANDLER(ShellViewHostMsg_CanOpenWindows, OnCanOpenWindows)
+ IPC_MESSAGE_HANDLER(ShellViewHostMsg_ShowWebInspector, OnShowWebInspector)
+ IPC_MESSAGE_HANDLER(ShellViewHostMsg_CloseWebInspector, OnCloseWebInspector)
IPC_MESSAGE_HANDLER(ShellViewHostMsg_NotImplemented, OnNotImplemented)
IPC_MESSAGE_UNHANDLED(handled = false)
IPC_END_MESSAGE_MAP()
@@ -397,6 +403,14 @@ void WebKitTestController::OnCanOpenWindows() {
can_open_windows_ = true;
}
+void WebKitTestController::OnShowWebInspector() {
+ main_window_->ShowDevTools();
+}
+
+void WebKitTestController::OnCloseWebInspector() {
+ main_window_->CloseDevTools();
+}
+
void WebKitTestController::OnNotImplemented(
const std::string& object_name,
const std::string& property_name) {
diff --git a/content/shell/webkit_test_controller.h b/content/shell/webkit_test_controller.h
index bd8fb11..26a616a 100644
--- a/content/shell/webkit_test_controller.h
+++ b/content/shell/webkit_test_controller.h
@@ -120,6 +120,8 @@ class WebKitTestController : public base::NonThreadSafe,
void OnSetShouldStayOnPageAfterHandlingBeforeUnload(bool should_stay_on_page);
void OnWaitUntilDone();
void OnCanOpenWindows();
+ void OnShowWebInspector();
+ void OnCloseWebInspector();
void OnNotImplemented(const std::string& object_name,
const std::string& method_name);
diff --git a/content/shell/webkit_test_runner.cc b/content/shell/webkit_test_runner.cc
index ae2e161..89e709a 100644
--- a/content/shell/webkit_test_runner.cc
+++ b/content/shell/webkit_test_runner.cc
@@ -24,6 +24,7 @@
#include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebSize.h"
#include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebString.h"
#include "third_party/WebKit/Source/WebKit/chromium/public/WebContextMenuData.h"
+#include "third_party/WebKit/Source/WebKit/chromium/public/WebDevToolsAgent.h"
#include "third_party/WebKit/Source/WebKit/chromium/public/WebDocument.h"
#include "third_party/WebKit/Source/WebKit/chromium/public/WebElement.h"
#include "third_party/WebKit/Source/WebKit/chromium/public/WebFrame.h"
@@ -35,6 +36,7 @@
#include "webkit/glue/webpreferences.h"
using WebKit::WebContextMenuData;
+using WebKit::WebDevToolsAgent;
using WebKit::WebElement;
using WebKit::WebFrame;
using WebKit::WebGamepads;
@@ -310,6 +312,21 @@ void WebKitTestRunner::CanOpenWindows() {
Send(new ShellViewHostMsg_CanOpenWindows(routing_id()));
}
+void WebKitTestRunner::ShowWebInspector() {
+ Send(new ShellViewHostMsg_ShowWebInspector(routing_id()));
+}
+
+void WebKitTestRunner::CloseWebInspector() {
+ Send(new ShellViewHostMsg_CloseWebInspector(routing_id()));
+}
+
+void WebKitTestRunner::EvaluateInWebInspector(int32_t call_id,
+ const std::string& script) {
+ WebDevToolsAgent* agent = render_view()->GetWebView()->devToolsAgent();
+ if (agent)
+ agent->evaluateInWebInspector(call_id, WebString::fromUTF8(script));
+}
+
void WebKitTestRunner::NotImplemented(const std::string& object,
const std::string& method) {
Send(new ShellViewHostMsg_NotImplemented(routing_id(), object, method));
diff --git a/content/shell/webkit_test_runner.h b/content/shell/webkit_test_runner.h
index 8c1e294..08c3dcd 100644
--- a/content/shell/webkit_test_runner.h
+++ b/content/shell/webkit_test_runner.h
@@ -68,6 +68,10 @@ class WebKitTestRunner : public RenderViewObserver,
void SetShouldStayOnPageAfterHandlingBeforeUnload(bool should_stay_on_page);
void WaitUntilDone();
void CanOpenWindows();
+ void ShowWebInspector();
+ void CloseWebInspector();
+ void EvaluateInWebInspector(int32_t call_id, const std::string& script);
+
void NotImplemented(const std::string& object, const std::string& method);
void set_proxy(WebTestRunner::WebTestProxyBase* proxy) { proxy_ = proxy; }
diff --git a/content/shell/webkit_test_runner.js b/content/shell/webkit_test_runner.js
index 7665a90..fce7e2ef 100644
--- a/content/shell/webkit_test_runner.js
+++ b/content/shell/webkit_test_runner.js
@@ -5,7 +5,9 @@
var testRunner = testRunner || {};
(function() {
+ native function CloseWebInspector();
native function Display();
+ native function EvaluateInWebInspector();
native function GetWorkerThreadCount();
native function NotifyDone();
native function SetCanOpenWindows();
@@ -15,6 +17,7 @@ var testRunner = testRunner || {};
native function SetShouldStayOnPageAfterHandlingBeforeUnload();
native function SetWaitUntilDone();
native function SetXSSAuditorEnabled();
+ native function ShowWebInspector();
native function NotImplemented();
@@ -54,6 +57,13 @@ var testRunner = testRunner || {};
"setXSSAuditorEnabled",
{value: SetXSSAuditorEnabled});
Object.defineProperty(this, "waitUntilDone", {value: SetWaitUntilDone});
+ Object.defineProperty(this, "showWebInspector", {value: ShowWebInspector});
+ Object.defineProperty(this,
+ "closeWebInspector",
+ {value: CloseWebInspector});
+ Object.defineProperty(this,
+ "evaluateInWebInspector",
+ {value: EvaluateInWebInspector});
var stubs = [
"overridePreference", // not really a stub, but required to pass
diff --git a/content/shell/webkit_test_runner_bindings.cc b/content/shell/webkit_test_runner_bindings.cc
index 7f524a1..9d1c9b4 100644
--- a/content/shell/webkit_test_runner_bindings.cc
+++ b/content/shell/webkit_test_runner_bindings.cc
@@ -126,6 +126,40 @@ v8::Handle<v8::Value> GetWorkerThreadCount(const v8::Arguments& args) {
return v8::Integer::NewFromUnsigned(WebWorkerInfo::dedicatedWorkerCount());
}
+v8::Handle<v8::Value> ShowWebInspector(const v8::Arguments& args) {
+ WebKitTestRunner* runner =
+ ShellRenderProcessObserver::GetInstance()->main_test_runner();
+ if (!runner)
+ return v8::Undefined();
+
+ runner->ShowWebInspector();
+ return v8::Undefined();
+}
+
+v8::Handle<v8::Value> CloseWebInspector(const v8::Arguments& args) {
+ WebKitTestRunner* runner =
+ ShellRenderProcessObserver::GetInstance()->main_test_runner();
+ if (!runner)
+ return v8::Undefined();
+
+ runner->CloseWebInspector();
+ return v8::Undefined();
+}
+
+v8::Handle<v8::Value> EvaluateInWebInspector(const v8::Arguments& args) {
+ if (args.Length() != 2 || !args[0]->IsNumber() || !args[1]->IsString())
+ return v8::Undefined();
+
+ WebKitTestRunner* runner =
+ ShellRenderProcessObserver::GetInstance()->main_test_runner();
+ if (!runner)
+ return v8::Undefined();
+
+ runner->EvaluateInWebInspector(args[0]->Int32Value(),
+ *v8::String::AsciiValue(args[1]));
+ return v8::Undefined();
+}
+
v8::Handle<v8::Value> NotImplemented(const v8::Arguments& args) {
if (args.Length() != 2 || !args[0]->IsString() || !args[1]->IsString())
return v8::Undefined();
@@ -180,6 +214,12 @@ WebKitTestRunnerBindings::GetNativeFunction(v8::Handle<v8::String> name) {
return v8::FunctionTemplate::New(SetXSSAuditorEnabled);
if (name->Equals(v8::String::New("GetWorkerThreadCount")))
return v8::FunctionTemplate::New(GetWorkerThreadCount);
+ if (name->Equals(v8::String::New("ShowWebInspector")))
+ return v8::FunctionTemplate::New(ShowWebInspector);
+ if (name->Equals(v8::String::New("CloseWebInspector")))
+ return v8::FunctionTemplate::New(CloseWebInspector);
+ if (name->Equals(v8::String::New("EvaluateInWebInspector")))
+ return v8::FunctionTemplate::New(EvaluateInWebInspector);
if (name->Equals(v8::String::New("NotImplemented")))
return v8::FunctionTemplate::New(NotImplemented);