Commit fee9eca0 authored by pfeldman@chromium.org's avatar pfeldman@chromium.org

DevTools: by default, open devtools panel matching the layout test folder.

BUG=335790

Review URL: https://codereview.chromium.org/163633002

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@251387 0039d316-1c4b-4281-b951-d872f2087c98
parent fb1a9cc0
...@@ -215,21 +215,18 @@ void Shell::UpdateNavigationControls() { ...@@ -215,21 +215,18 @@ void Shell::UpdateNavigationControls() {
} }
void Shell::ShowDevTools() { void Shell::ShowDevTools() {
if (!devtools_frontend_) { InnerShowDevTools("");
devtools_frontend_ = ShellDevToolsFrontend::Show(web_contents());
devtools_observer_.reset(new DevToolsWebContentsObserver(
this, devtools_frontend_->frontend_shell()->web_contents()));
}
devtools_frontend_->Activate();
devtools_frontend_->Focus();
} }
void Shell::ShowDevToolsForElementAt(int x, int y) { void Shell::ShowDevToolsForElementAt(int x, int y) {
ShowDevTools(); InnerShowDevTools("");
devtools_frontend_->InspectElementAt(x, y); devtools_frontend_->InspectElementAt(x, y);
} }
void Shell::ShowDevToolsForTest(const std::string& settings) {
InnerShowDevTools(settings);
}
void Shell::CloseDevTools() { void Shell::CloseDevTools() {
if (!devtools_frontend_) if (!devtools_frontend_)
return; return;
...@@ -366,6 +363,17 @@ void Shell::TitleWasSet(NavigationEntry* entry, bool explicit_set) { ...@@ -366,6 +363,17 @@ void Shell::TitleWasSet(NavigationEntry* entry, bool explicit_set) {
PlatformSetTitle(entry->GetTitle()); 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() { void Shell::OnDevToolsWebContentsDestroyed() {
devtools_observer_.reset(); devtools_observer_.reset();
devtools_frontend_ = NULL; devtools_frontend_ = NULL;
......
...@@ -69,6 +69,7 @@ class Shell : public WebContentsDelegate, ...@@ -69,6 +69,7 @@ class Shell : public WebContentsDelegate,
void Close(); void Close();
void ShowDevTools(); void ShowDevTools();
void ShowDevToolsForElementAt(int x, int y); void ShowDevToolsForElementAt(int x, int y);
void ShowDevToolsForTest(const std::string& settings);
void CloseDevTools(); void CloseDevTools();
#if defined(TOOLKIT_GTK) || defined(OS_MACOSX) #if defined(TOOLKIT_GTK) || defined(OS_MACOSX)
// Resizes the main window to the given dimensions. // Resizes the main window to the given dimensions.
...@@ -212,6 +213,7 @@ class Shell : public WebContentsDelegate, ...@@ -212,6 +213,7 @@ class Shell : public WebContentsDelegate,
// WebContentsObserver // WebContentsObserver
virtual void TitleWasSet(NavigationEntry* entry, bool explicit_set) OVERRIDE; virtual void TitleWasSet(NavigationEntry* entry, bool explicit_set) OVERRIDE;
void InnerShowDevTools(const std::string& settings);
void OnDevToolsWebContentsDestroyed(); void OnDevToolsWebContentsDestroyed();
#if defined(TOOLKIT_GTK) #if defined(TOOLKIT_GTK)
......
...@@ -6,6 +6,7 @@ ...@@ -6,6 +6,7 @@
#include "base/command_line.h" #include "base/command_line.h"
#include "base/path_service.h" #include "base/path_service.h"
#include "base/strings/stringprintf.h"
#include "base/strings/utf_string_conversions.h" #include "base/strings/utf_string_conversions.h"
#include "content/public/browser/devtools_http_handler.h" #include "content/public/browser/devtools_http_handler.h"
#include "content/public/browser/devtools_manager.h" #include "content/public/browser/devtools_manager.h"
...@@ -24,7 +25,7 @@ ...@@ -24,7 +25,7 @@
namespace content { namespace content {
// DevTools frontend path for inspector LayoutTests. // DevTools frontend path for inspector LayoutTests.
GURL GetDevToolsPathAsURL() { GURL GetDevToolsPathAsURL(const std::string& settings) {
base::FilePath dir_exe; base::FilePath dir_exe;
if (!PathService::Get(base::DIR_EXE, &dir_exe)) { if (!PathService::Get(base::DIR_EXE, &dir_exe)) {
NOTREACHED(); NOTREACHED();
...@@ -38,12 +39,25 @@ GURL GetDevToolsPathAsURL() { ...@@ -38,12 +39,25 @@ GURL GetDevToolsPathAsURL() {
#endif #endif
base::FilePath dev_tools_path = dir_exe.AppendASCII( base::FilePath dev_tools_path = dir_exe.AppendASCII(
"resources/inspector/devtools.html"); "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 // static
ShellDevToolsFrontend* ShellDevToolsFrontend::Show( ShellDevToolsFrontend* ShellDevToolsFrontend::Show(
WebContents* inspected_contents) { WebContents* inspected_contents) {
return ShellDevToolsFrontend::Show(inspected_contents, "");
}
// static
ShellDevToolsFrontend* ShellDevToolsFrontend::Show(
WebContents* inspected_contents,
const std::string& settings) {
scoped_refptr<DevToolsAgentHost> agent( scoped_refptr<DevToolsAgentHost> agent(
DevToolsAgentHost::GetOrCreateFor( DevToolsAgentHost::GetOrCreateFor(
inspected_contents->GetRenderViewHost())); inspected_contents->GetRenderViewHost()));
...@@ -59,7 +73,7 @@ ShellDevToolsFrontend* ShellDevToolsFrontend::Show( ...@@ -59,7 +73,7 @@ ShellDevToolsFrontend* ShellDevToolsFrontend::Show(
ShellDevToolsDelegate* delegate = ShellContentBrowserClient::Get()-> ShellDevToolsDelegate* delegate = ShellContentBrowserClient::Get()->
shell_browser_main_parts()->devtools_delegate(); shell_browser_main_parts()->devtools_delegate();
if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kDumpRenderTree)) if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kDumpRenderTree))
shell->LoadURL(GetDevToolsPathAsURL()); shell->LoadURL(GetDevToolsPathAsURL(settings));
else else
shell->LoadURL(delegate->devtools_http_handler()->GetFrontendURL()); shell->LoadURL(delegate->devtools_http_handler()->GetFrontendURL());
......
...@@ -16,7 +16,7 @@ ...@@ -16,7 +16,7 @@
namespace content { namespace content {
GURL GetDevToolsPathAsURL(); GURL GetDevToolsPathAsURL(const std::string& settings);
class RenderViewHost; class RenderViewHost;
class Shell; class Shell;
...@@ -26,6 +26,8 @@ class ShellDevToolsFrontend : public WebContentsObserver, ...@@ -26,6 +26,8 @@ class ShellDevToolsFrontend : public WebContentsObserver,
public DevToolsFrontendHostDelegate { public DevToolsFrontendHostDelegate {
public: public:
static ShellDevToolsFrontend* Show(WebContents* inspected_contents); static ShellDevToolsFrontend* Show(WebContents* inspected_contents);
static ShellDevToolsFrontend* Show(WebContents* inspected_contents,
const std::string& settings);
void Activate(); void Activate();
void Focus(); void Focus();
void InspectElementAt(int x, int y); void InspectElementAt(int x, int y);
......
...@@ -568,11 +568,11 @@ void WebKitTestController::OnClearDevToolsLocalStorage() { ...@@ -568,11 +568,11 @@ void WebKitTestController::OnClearDevToolsLocalStorage() {
StoragePartition* storage_partition = StoragePartition* storage_partition =
BrowserContext::GetStoragePartition(browser_context, NULL); BrowserContext::GetStoragePartition(browser_context, NULL);
storage_partition->GetDOMStorageContext()->DeleteLocalStorage( storage_partition->GetDOMStorageContext()->DeleteLocalStorage(
content::GetDevToolsPathAsURL().GetOrigin()); content::GetDevToolsPathAsURL("").GetOrigin());
} }
void WebKitTestController::OnShowDevTools() { void WebKitTestController::OnShowDevTools(const std::string& settings) {
main_window_->ShowDevTools(); main_window_->ShowDevToolsForTest(settings);
} }
void WebKitTestController::OnCloseDevTools() { void WebKitTestController::OnCloseDevTools() {
......
...@@ -165,7 +165,7 @@ class WebKitTestController : public base::NonThreadSafe, ...@@ -165,7 +165,7 @@ class WebKitTestController : public base::NonThreadSafe,
void OnOverridePreferences(const WebPreferences& prefs); void OnOverridePreferences(const WebPreferences& prefs);
void OnTestFinished(); void OnTestFinished();
void OnClearDevToolsLocalStorage(); void OnClearDevToolsLocalStorage();
void OnShowDevTools(); void OnShowDevTools(const std::string& settings);
void OnCloseDevTools(); void OnCloseDevTools();
void OnGoToOffset(int offset); void OnGoToOffset(int offset);
void OnReload(); void OnReload();
......
...@@ -84,7 +84,8 @@ IPC_SYNC_MESSAGE_ROUTED1_1(ShellViewHostMsg_ReadFileToString, ...@@ -84,7 +84,8 @@ IPC_SYNC_MESSAGE_ROUTED1_1(ShellViewHostMsg_ReadFileToString,
IPC_MESSAGE_ROUTED1(ShellViewHostMsg_PrintMessage, IPC_MESSAGE_ROUTED1(ShellViewHostMsg_PrintMessage,
std::string /* message */) std::string /* message */)
IPC_MESSAGE_ROUTED0(ShellViewHostMsg_ClearDevToolsLocalStorage) 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_ROUTED0(ShellViewHostMsg_CloseDevTools)
IPC_MESSAGE_ROUTED1(ShellViewHostMsg_GoToOffset, IPC_MESSAGE_ROUTED1(ShellViewHostMsg_GoToOffset,
int /* offset */) int /* offset */)
......
...@@ -6,6 +6,7 @@ ...@@ -6,6 +6,7 @@
#include <string> #include <string>
#include "base/strings/stringprintf.h"
#include "content/shell/renderer/test_runner/AccessibilityController.h" #include "content/shell/renderer/test_runner/AccessibilityController.h"
#include "content/shell/renderer/test_runner/EventSender.h" #include "content/shell/renderer/test_runner/EventSender.h"
#include "content/shell/renderer/test_runner/TestRunner.h" #include "content/shell/renderer/test_runner/TestRunner.h"
...@@ -118,8 +119,18 @@ void TestInterfaces::configureForTestWithURL(const WebURL& testURL, bool generat ...@@ -118,8 +119,18 @@ void TestInterfaces::configureForTestWithURL(const WebURL& testURL, bool generat
if (spec.find("/inspector/") != string::npos if (spec.find("/inspector/") != string::npos
|| spec.find("/inspector-enabled/") != string::npos) || spec.find("/inspector-enabled/") != string::npos)
m_testRunner->clearDevToolsLocalStorage(); m_testRunner->clearDevToolsLocalStorage();
if (spec.find("/inspector/") != string::npos) if (spec.find("/inspector/") != string::npos) {
m_testRunner->showDevTools(); // 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) { if (spec.find("/viewsource/") != string::npos) {
m_testRunner->setShouldEnableViewSource(true); m_testRunner->setShouldEnableViewSource(true);
m_testRunner->setShouldGeneratePixelResults(false); m_testRunner->setShouldGeneratePixelResults(false);
......
...@@ -803,9 +803,9 @@ void TestRunner::clearDevToolsLocalStorage() ...@@ -803,9 +803,9 @@ void TestRunner::clearDevToolsLocalStorage()
m_delegate->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) void TestRunner::waitUntilDone(const CppArgumentList&, CppVariant* result)
...@@ -1714,9 +1714,12 @@ void TestRunner::setPluginsEnabled(const CppArgumentList& arguments, CppVariant* ...@@ -1714,9 +1714,12 @@ void TestRunner::setPluginsEnabled(const CppArgumentList& arguments, CppVariant*
result->setNull(); 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(); result->setNull();
} }
......
...@@ -103,7 +103,7 @@ public: ...@@ -103,7 +103,7 @@ public:
bool shouldDumpAsMarkup(); bool shouldDumpAsMarkup();
bool shouldDumpChildFrameScrollPositions() const; bool shouldDumpChildFrameScrollPositions() const;
bool shouldDumpChildFramesAsText() const; bool shouldDumpChildFramesAsText() const;
void showDevTools(); void showDevTools(const std::string& settings);
void clearDevToolsLocalStorage(); void clearDevToolsLocalStorage();
void setShouldDumpAsText(bool); void setShouldDumpAsText(bool);
void setShouldDumpAsMarkup(bool); void setShouldDumpAsMarkup(bool);
......
...@@ -89,7 +89,7 @@ public: ...@@ -89,7 +89,7 @@ public:
virtual void clearDevToolsLocalStorage() = 0; virtual void clearDevToolsLocalStorage() = 0;
// Opens and closes the inspector. // Opens and closes the inspector.
virtual void showDevTools() = 0; virtual void showDevTools(const std::string& settings) = 0;
virtual void closeDevTools() = 0; virtual void closeDevTools() = 0;
// Evaluate the given script in the DevTools agent. // Evaluate the given script in the DevTools agent.
......
...@@ -387,8 +387,8 @@ void WebKitTestRunner::clearDevToolsLocalStorage() { ...@@ -387,8 +387,8 @@ void WebKitTestRunner::clearDevToolsLocalStorage() {
Send(new ShellViewHostMsg_ClearDevToolsLocalStorage(routing_id())); Send(new ShellViewHostMsg_ClearDevToolsLocalStorage(routing_id()));
} }
void WebKitTestRunner::showDevTools() { void WebKitTestRunner::showDevTools(const std::string& settings) {
Send(new ShellViewHostMsg_ShowDevTools(routing_id())); Send(new ShellViewHostMsg_ShowDevTools(routing_id(), settings));
} }
void WebKitTestRunner::closeDevTools() { void WebKitTestRunner::closeDevTools() {
......
...@@ -81,7 +81,7 @@ class WebKitTestRunner : public RenderViewObserver, ...@@ -81,7 +81,7 @@ class WebKitTestRunner : public RenderViewObserver,
const blink::WebSize& max_size) OVERRIDE; const blink::WebSize& max_size) OVERRIDE;
virtual void disableAutoResizeMode(const blink::WebSize& new_size) OVERRIDE; virtual void disableAutoResizeMode(const blink::WebSize& new_size) OVERRIDE;
virtual void clearDevToolsLocalStorage() OVERRIDE; virtual void clearDevToolsLocalStorage() OVERRIDE;
virtual void showDevTools() OVERRIDE; virtual void showDevTools(const std::string& settings) OVERRIDE;
virtual void closeDevTools() OVERRIDE; virtual void closeDevTools() OVERRIDE;
virtual void evaluateInWebInspector(long call_id, virtual void evaluateInWebInspector(long call_id,
const std::string& script) OVERRIDE; const std::string& script) OVERRIDE;
......
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