diff options
-rw-r--r-- | content/shell/browser/shell.cc | 26 | ||||
-rw-r--r-- | content/shell/browser/shell.h | 2 | ||||
-rw-r--r-- | content/shell/browser/shell_devtools_frontend.cc | 20 | ||||
-rw-r--r-- | content/shell/browser/shell_devtools_frontend.h | 4 | ||||
-rw-r--r-- | content/shell/browser/webkit_test_controller.cc | 6 | ||||
-rw-r--r-- | content/shell/browser/webkit_test_controller.h | 2 | ||||
-rw-r--r-- | content/shell/common/shell_messages.h | 3 | ||||
-rw-r--r-- | content/shell/renderer/test_runner/TestInterfaces.cpp | 15 | ||||
-rw-r--r-- | content/shell/renderer/test_runner/TestRunner.cpp | 11 | ||||
-rw-r--r-- | content/shell/renderer/test_runner/TestRunner.h | 2 | ||||
-rw-r--r-- | content/shell/renderer/test_runner/WebTestDelegate.h | 2 | ||||
-rw-r--r-- | content/shell/renderer/webkit_test_runner.cc | 4 | ||||
-rw-r--r-- | content/shell/renderer/webkit_test_runner.h | 2 |
13 files changed, 70 insertions, 29 deletions
diff --git a/content/shell/browser/shell.cc b/content/shell/browser/shell.cc index 30d8b84..6549123 100644 --- a/content/shell/browser/shell.cc +++ b/content/shell/browser/shell.cc @@ -215,21 +215,18 @@ void Shell::UpdateNavigationControls() { } void Shell::ShowDevTools() { - if (!devtools_frontend_) { - devtools_frontend_ = ShellDevToolsFrontend::Show(web_contents()); - devtools_observer_.reset(new DevToolsWebContentsObserver( - this, devtools_frontend_->frontend_shell()->web_contents())); - } - - devtools_frontend_->Activate(); - devtools_frontend_->Focus(); + InnerShowDevTools(""); } void Shell::ShowDevToolsForElementAt(int x, int y) { - ShowDevTools(); + InnerShowDevTools(""); devtools_frontend_->InspectElementAt(x, y); } +void Shell::ShowDevToolsForTest(const std::string& settings) { + InnerShowDevTools(settings); +} + void Shell::CloseDevTools() { if (!devtools_frontend_) return; @@ -366,6 +363,17 @@ void Shell::TitleWasSet(NavigationEntry* entry, bool explicit_set) { PlatformSetTitle(entry->GetTitle()); } +void Shell::InnerShowDevTools(const std::string& settings) { + if (!devtools_frontend_) { + devtools_frontend_ = ShellDevToolsFrontend::Show(web_contents(), settings); + devtools_observer_.reset(new DevToolsWebContentsObserver( + this, devtools_frontend_->frontend_shell()->web_contents())); + } + + devtools_frontend_->Activate(); + devtools_frontend_->Focus(); +} + void Shell::OnDevToolsWebContentsDestroyed() { devtools_observer_.reset(); devtools_frontend_ = NULL; diff --git a/content/shell/browser/shell.h b/content/shell/browser/shell.h index 4599a96..3595556 100644 --- a/content/shell/browser/shell.h +++ b/content/shell/browser/shell.h @@ -69,6 +69,7 @@ class Shell : public WebContentsDelegate, void Close(); void ShowDevTools(); void ShowDevToolsForElementAt(int x, int y); + void ShowDevToolsForTest(const std::string& settings); void CloseDevTools(); #if defined(TOOLKIT_GTK) || defined(OS_MACOSX) // Resizes the main window to the given dimensions. @@ -212,6 +213,7 @@ class Shell : public WebContentsDelegate, // WebContentsObserver virtual void TitleWasSet(NavigationEntry* entry, bool explicit_set) OVERRIDE; + void InnerShowDevTools(const std::string& settings); void OnDevToolsWebContentsDestroyed(); #if defined(TOOLKIT_GTK) diff --git a/content/shell/browser/shell_devtools_frontend.cc b/content/shell/browser/shell_devtools_frontend.cc index b1f4e0c0..fa3d16d 100644 --- a/content/shell/browser/shell_devtools_frontend.cc +++ b/content/shell/browser/shell_devtools_frontend.cc @@ -6,6 +6,7 @@ #include "base/command_line.h" #include "base/path_service.h" +#include "base/strings/stringprintf.h" #include "base/strings/utf_string_conversions.h" #include "content/public/browser/devtools_http_handler.h" #include "content/public/browser/devtools_manager.h" @@ -24,7 +25,7 @@ namespace content { // DevTools frontend path for inspector LayoutTests. -GURL GetDevToolsPathAsURL() { +GURL GetDevToolsPathAsURL(const std::string& settings) { base::FilePath dir_exe; if (!PathService::Get(base::DIR_EXE, &dir_exe)) { NOTREACHED(); @@ -38,12 +39,25 @@ GURL GetDevToolsPathAsURL() { #endif base::FilePath dev_tools_path = dir_exe.AppendASCII( "resources/inspector/devtools.html"); - return net::FilePathToFileURL(dev_tools_path); + + GURL result = net::FilePathToFileURL(dev_tools_path); + if (!settings.empty()) + result = GURL(base::StringPrintf("%s?settings=%s", + result.spec().c_str(), + settings.c_str())); + return result; } // static ShellDevToolsFrontend* ShellDevToolsFrontend::Show( WebContents* inspected_contents) { + return ShellDevToolsFrontend::Show(inspected_contents, ""); +} + +// static +ShellDevToolsFrontend* ShellDevToolsFrontend::Show( + WebContents* inspected_contents, + const std::string& settings) { scoped_refptr<DevToolsAgentHost> agent( DevToolsAgentHost::GetOrCreateFor( inspected_contents->GetRenderViewHost())); @@ -59,7 +73,7 @@ ShellDevToolsFrontend* ShellDevToolsFrontend::Show( ShellDevToolsDelegate* delegate = ShellContentBrowserClient::Get()-> shell_browser_main_parts()->devtools_delegate(); if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kDumpRenderTree)) - shell->LoadURL(GetDevToolsPathAsURL()); + shell->LoadURL(GetDevToolsPathAsURL(settings)); else shell->LoadURL(delegate->devtools_http_handler()->GetFrontendURL()); diff --git a/content/shell/browser/shell_devtools_frontend.h b/content/shell/browser/shell_devtools_frontend.h index 0797156..62d0368 100644 --- a/content/shell/browser/shell_devtools_frontend.h +++ b/content/shell/browser/shell_devtools_frontend.h @@ -16,7 +16,7 @@ namespace content { -GURL GetDevToolsPathAsURL(); +GURL GetDevToolsPathAsURL(const std::string& settings); class RenderViewHost; class Shell; @@ -26,6 +26,8 @@ class ShellDevToolsFrontend : public WebContentsObserver, public DevToolsFrontendHostDelegate { public: static ShellDevToolsFrontend* Show(WebContents* inspected_contents); + static ShellDevToolsFrontend* Show(WebContents* inspected_contents, + const std::string& settings); void Activate(); void Focus(); void InspectElementAt(int x, int y); diff --git a/content/shell/browser/webkit_test_controller.cc b/content/shell/browser/webkit_test_controller.cc index 4d6153d..705819b 100644 --- a/content/shell/browser/webkit_test_controller.cc +++ b/content/shell/browser/webkit_test_controller.cc @@ -568,11 +568,11 @@ void WebKitTestController::OnClearDevToolsLocalStorage() { StoragePartition* storage_partition = BrowserContext::GetStoragePartition(browser_context, NULL); storage_partition->GetDOMStorageContext()->DeleteLocalStorage( - content::GetDevToolsPathAsURL().GetOrigin()); + content::GetDevToolsPathAsURL("").GetOrigin()); } -void WebKitTestController::OnShowDevTools() { - main_window_->ShowDevTools(); +void WebKitTestController::OnShowDevTools(const std::string& settings) { + main_window_->ShowDevToolsForTest(settings); } void WebKitTestController::OnCloseDevTools() { diff --git a/content/shell/browser/webkit_test_controller.h b/content/shell/browser/webkit_test_controller.h index c692cd3..60433aa 100644 --- a/content/shell/browser/webkit_test_controller.h +++ b/content/shell/browser/webkit_test_controller.h @@ -165,7 +165,7 @@ class WebKitTestController : public base::NonThreadSafe, void OnOverridePreferences(const WebPreferences& prefs); void OnTestFinished(); void OnClearDevToolsLocalStorage(); - void OnShowDevTools(); + void OnShowDevTools(const std::string& settings); void OnCloseDevTools(); void OnGoToOffset(int offset); void OnReload(); diff --git a/content/shell/common/shell_messages.h b/content/shell/common/shell_messages.h index ce563fe..46e43ae 100644 --- a/content/shell/common/shell_messages.h +++ b/content/shell/common/shell_messages.h @@ -84,7 +84,8 @@ IPC_SYNC_MESSAGE_ROUTED1_1(ShellViewHostMsg_ReadFileToString, IPC_MESSAGE_ROUTED1(ShellViewHostMsg_PrintMessage, std::string /* message */) IPC_MESSAGE_ROUTED0(ShellViewHostMsg_ClearDevToolsLocalStorage) -IPC_MESSAGE_ROUTED0(ShellViewHostMsg_ShowDevTools) +IPC_MESSAGE_ROUTED1(ShellViewHostMsg_ShowDevTools, + std::string /* settings */) IPC_MESSAGE_ROUTED0(ShellViewHostMsg_CloseDevTools) IPC_MESSAGE_ROUTED1(ShellViewHostMsg_GoToOffset, int /* offset */) diff --git a/content/shell/renderer/test_runner/TestInterfaces.cpp b/content/shell/renderer/test_runner/TestInterfaces.cpp index 919c117..7981f36 100644 --- a/content/shell/renderer/test_runner/TestInterfaces.cpp +++ b/content/shell/renderer/test_runner/TestInterfaces.cpp @@ -6,6 +6,7 @@ #include <string> +#include "base/strings/stringprintf.h" #include "content/shell/renderer/test_runner/AccessibilityController.h" #include "content/shell/renderer/test_runner/EventSender.h" #include "content/shell/renderer/test_runner/TestRunner.h" @@ -118,8 +119,18 @@ void TestInterfaces::configureForTestWithURL(const WebURL& testURL, bool generat if (spec.find("/inspector/") != string::npos || spec.find("/inspector-enabled/") != string::npos) m_testRunner->clearDevToolsLocalStorage(); - if (spec.find("/inspector/") != string::npos) - m_testRunner->showDevTools(); + if (spec.find("/inspector/") != string::npos) { + // Subfolder name determines default panel to open. + string settings = ""; + string test_path = spec.substr(spec.find("/inspector/") + 11); + size_t slash_index = test_path.find("/"); + if (slash_index != string::npos) { + settings = base::StringPrintf( + "{\"lastActivePanel\":\"\\\"%s\\\"\"}", + test_path.substr(0, slash_index).c_str()); + } + m_testRunner->showDevTools(settings); + } if (spec.find("/viewsource/") != string::npos) { m_testRunner->setShouldEnableViewSource(true); m_testRunner->setShouldGeneratePixelResults(false); diff --git a/content/shell/renderer/test_runner/TestRunner.cpp b/content/shell/renderer/test_runner/TestRunner.cpp index 99e2861..a25a06d 100644 --- a/content/shell/renderer/test_runner/TestRunner.cpp +++ b/content/shell/renderer/test_runner/TestRunner.cpp @@ -803,9 +803,9 @@ void TestRunner::clearDevToolsLocalStorage() m_delegate->clearDevToolsLocalStorage(); } -void TestRunner::showDevTools() +void TestRunner::showDevTools(const std::string& settings) { - m_delegate->showDevTools(); + m_delegate->showDevTools(settings); } void TestRunner::waitUntilDone(const CppArgumentList&, CppVariant* result) @@ -1714,9 +1714,12 @@ void TestRunner::setPluginsEnabled(const CppArgumentList& arguments, CppVariant* result->setNull(); } -void TestRunner::showWebInspector(const CppArgumentList&, CppVariant* result) +void TestRunner::showWebInspector(const CppArgumentList& args, CppVariant* result) { - showDevTools(); + if (args.size() == 1 && args[0].isString()) + showDevTools(args[0].toString()); + else + showDevTools(""); result->setNull(); } diff --git a/content/shell/renderer/test_runner/TestRunner.h b/content/shell/renderer/test_runner/TestRunner.h index f511f7d..0bb162b 100644 --- a/content/shell/renderer/test_runner/TestRunner.h +++ b/content/shell/renderer/test_runner/TestRunner.h @@ -103,7 +103,7 @@ public: bool shouldDumpAsMarkup(); bool shouldDumpChildFrameScrollPositions() const; bool shouldDumpChildFramesAsText() const; - void showDevTools(); + void showDevTools(const std::string& settings); void clearDevToolsLocalStorage(); void setShouldDumpAsText(bool); void setShouldDumpAsMarkup(bool); diff --git a/content/shell/renderer/test_runner/WebTestDelegate.h b/content/shell/renderer/test_runner/WebTestDelegate.h index 8574664..db62e72 100644 --- a/content/shell/renderer/test_runner/WebTestDelegate.h +++ b/content/shell/renderer/test_runner/WebTestDelegate.h @@ -89,7 +89,7 @@ public: virtual void clearDevToolsLocalStorage() = 0; // Opens and closes the inspector. - virtual void showDevTools() = 0; + virtual void showDevTools(const std::string& settings) = 0; virtual void closeDevTools() = 0; // Evaluate the given script in the DevTools agent. diff --git a/content/shell/renderer/webkit_test_runner.cc b/content/shell/renderer/webkit_test_runner.cc index 6663968..583f152 100644 --- a/content/shell/renderer/webkit_test_runner.cc +++ b/content/shell/renderer/webkit_test_runner.cc @@ -387,8 +387,8 @@ void WebKitTestRunner::clearDevToolsLocalStorage() { Send(new ShellViewHostMsg_ClearDevToolsLocalStorage(routing_id())); } -void WebKitTestRunner::showDevTools() { - Send(new ShellViewHostMsg_ShowDevTools(routing_id())); +void WebKitTestRunner::showDevTools(const std::string& settings) { + Send(new ShellViewHostMsg_ShowDevTools(routing_id(), settings)); } void WebKitTestRunner::closeDevTools() { diff --git a/content/shell/renderer/webkit_test_runner.h b/content/shell/renderer/webkit_test_runner.h index b6f9b02..83f6b7f 100644 --- a/content/shell/renderer/webkit_test_runner.h +++ b/content/shell/renderer/webkit_test_runner.h @@ -81,7 +81,7 @@ class WebKitTestRunner : public RenderViewObserver, const blink::WebSize& max_size) OVERRIDE; virtual void disableAutoResizeMode(const blink::WebSize& new_size) OVERRIDE; virtual void clearDevToolsLocalStorage() OVERRIDE; - virtual void showDevTools() OVERRIDE; + virtual void showDevTools(const std::string& settings) OVERRIDE; virtual void closeDevTools() OVERRIDE; virtual void evaluateInWebInspector(long call_id, const std::string& script) OVERRIDE; |