Commit 6fc29267 authored by achicu@adobe.com's avatar achicu@adobe.com

Web Inspector: It should be possible to debug the Inspector code

https://bugs.webkit.org/show_bug.cgi?id=124065

Reviewed by Timothy Hatcher.

Source/WebKit2:

When the script is paused, the debugger will pause all the pages in the same PageGroup.
All the Inspector windows were created in the same PageGroup, so pausing one debugger
would stop the other too.

Added WebInspectorPageGroups to manage the PageGroups created for the Inspectors.
The WebInspectors will now use the inspection "level" to figure out which PageGroup to use.
The inspector that debugs the main page will use "__WebInspectorPageGroupLevel1__",
the second inspector (that debugs the first inspector) will use "__WebInspectorPageGroupLevel2__" ...

* UIProcess/WebInspectorProxy.cpp:
(WebKit::WebInspectorPageGroups::shared):
(WebKit::WebInspectorPageGroups::inspectorLevel):
(WebKit::WebInspectorPageGroups::isInspectorPageGroup):
(WebKit::WebInspectorPageGroups::inspectorPageGroupLevel):
(WebKit::WebInspectorPageGroups::inspectorPageGroupForLevel):
(WebKit::WebInspectorPageGroups::createInspectorPageGroup):
(WebKit::WebInspectorProxy::WebInspectorProxy):
(WebKit::WebInspectorProxy::inspectorPageGroup):
(WebKit::WebInspectorProxy::isInspectorPage):
(WebKit::WebInspectorProxy::canAttach):
* UIProcess/WebInspectorProxy.h:

LayoutTests:

Added test to check that a second inspector window can be used to debug the first one.

* inspector-protocol/debugger/nested-inspectors-expected.txt: Added.
* inspector-protocol/debugger/nested-inspectors.html: Added.


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@158976 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 0cd24621
2013-11-08 Alexandru Chiculita <achicu@adobe.com>
Web Inspector: It should be possible to debug the Inspector code
https://bugs.webkit.org/show_bug.cgi?id=124065
Reviewed by Timothy Hatcher.
Added test to check that a second inspector window can be used to debug the first one.
* inspector-protocol/debugger/nested-inspectors-expected.txt: Added.
* inspector-protocol/debugger/nested-inspectors.html: Added.
2013-11-08 Hans Muller <hmuller@adobe.com>
[CSS Shapes] Image valued shape-outside that extends vertically into the margin-box is top-clipped
......
CONSOLE MESSAGE: line 1: Error: PASS: Expected exception
Checking that the inspector code can be debugged using a second inspector window.
Breakpoints Enabled
Debugger.setPauseOnExceptions - all
PASS: Paused!
PASS: Resumed!
<html>
<head>
<script src="../../http/tests/inspector-protocol/resources/protocol-test.js"></script>
<script src="resources/exception.js"></script>
<script>
function test()
{
function testFunction() {
// This function runs in the second inspector window. We can use this one to debug the first inspector.
InspectorTest.sendCommand("Debugger.enable", {});
InspectorTest.sendCommand("Debugger.setBreakpointsActive", {active: true}, function() {
InspectorTest.log("Breakpoints Enabled");
InspectorTest.sendCommand("Debugger.setPauseOnExceptions", {state: "all"}, function(responseObject) {
InspectorTest.checkForError(responseObject);
InspectorTest.log("Debugger.setPauseOnExceptions - all");
// Trigger an exception in the main inspector.
InspectorTest.sendCommand("Runtime.evaluate", {expression: "setTimeout(function() { throw new Error('PASS: Expected exception') }, 0);"});
});
});
InspectorTest.eventHandler["Debugger.paused"] = function(messageObject)
{
InspectorTest.log("PASS: Paused!");
InspectorTest.sendCommand("Debugger.resume", {});
}
InspectorTest.eventHandler["Debugger.resumed"] = function(messageObject)
{
InspectorTest.log("PASS: Resumed!");
// Revert Debugger.setPauseOnExceptions as it can have an impact on the following tests.
InspectorTest.sendCommand("Debugger.setPauseOnExceptions", {state: "none"}, function(responseObject) {
InspectorTest.completeTest();
});
}
};
window.log = InspectorTest.log.bind(InspectorTest);
window.closeTest = function()
{
window.internals.closeDummyInspectorFrontend();
InspectorTest.completeTest();
}
var secondInspectorFrontend = window.internals.openDummyInspectorFrontend("protocol-test.html");
secondInspectorFrontend.addEventListener("load", function(event) {
secondInspectorFrontend.postMessage("(" + testFunction.toString() +")();", "*");
});
}
</script>
</head>
<body onload="runTest()">
<p>Checking that the inspector code can be debugged using a second inspector window.</p>
</body>
</html>
2013-11-08 Alexandru Chiculita <achicu@adobe.com>
Web Inspector: It should be possible to debug the Inspector code
https://bugs.webkit.org/show_bug.cgi?id=124065
Reviewed by Timothy Hatcher.
When the script is paused, the debugger will pause all the pages in the same PageGroup.
All the Inspector windows were created in the same PageGroup, so pausing one debugger
would stop the other too.
Added WebInspectorPageGroups to manage the PageGroups created for the Inspectors.
The WebInspectors will now use the inspection "level" to figure out which PageGroup to use.
The inspector that debugs the main page will use "__WebInspectorPageGroupLevel1__",
the second inspector (that debugs the first inspector) will use "__WebInspectorPageGroupLevel2__" ...
* UIProcess/WebInspectorProxy.cpp:
(WebKit::WebInspectorPageGroups::shared):
(WebKit::WebInspectorPageGroups::inspectorLevel):
(WebKit::WebInspectorPageGroups::isInspectorPageGroup):
(WebKit::WebInspectorPageGroups::inspectorPageGroupLevel):
(WebKit::WebInspectorPageGroups::inspectorPageGroupForLevel):
(WebKit::WebInspectorPageGroups::createInspectorPageGroup):
(WebKit::WebInspectorProxy::WebInspectorProxy):
(WebKit::WebInspectorProxy::inspectorPageGroup):
(WebKit::WebInspectorProxy::isInspectorPage):
(WebKit::WebInspectorProxy::canAttach):
* UIProcess/WebInspectorProxy.h:
2013-11-08 Anders Carlsson <andersca@apple.com>
Begin stubbing out a KeyedEncoder class in WebCore
......
......@@ -58,26 +58,67 @@ const unsigned WebInspectorProxy::initialWindowHeight = 650;
const unsigned WebInspectorProxy::minimumAttachedWidth = 750;
const unsigned WebInspectorProxy::minimumAttachedHeight = 250;
static PassRefPtr<WebPageGroup> createInspectorPageGroup()
{
RefPtr<WebPageGroup> pageGroup = WebPageGroup::create("__WebInspectorPageGroup__", false, false);
class WebInspectorPageGroups {
public:
static WebInspectorPageGroups& shared()
{
DEFINE_STATIC_LOCAL(WebInspectorPageGroups, instance, ());
return instance;
}
unsigned inspectorLevel(WebPageGroup* inspectedPageGroup)
{
return isInspectorPageGroup(inspectedPageGroup) ? inspectorPageGroupLevel(inspectedPageGroup) + 1 : 1;
}
bool isInspectorPageGroup(WebPageGroup* group)
{
return m_pageGroupLevel.contains(group);
}
unsigned inspectorPageGroupLevel(WebPageGroup* group)
{
ASSERT(isInspectorPageGroup(group));
return m_pageGroupLevel.get(group);
}
WebPageGroup* inspectorPageGroupForLevel(unsigned level)
{
// The level is the key of the HashMap, so it cannot be 0.
ASSERT(level);
auto iterator = m_pageGroupByLevel.find(level);
if (iterator != m_pageGroupByLevel.end())
return iterator->value.get();
RefPtr<WebPageGroup> group = createInspectorPageGroup(level);
m_pageGroupByLevel.set(level, group.get());
m_pageGroupLevel.set(group.get(), level);
return group.get();
}
private:
static PassRefPtr<WebPageGroup> createInspectorPageGroup(unsigned level)
{
RefPtr<WebPageGroup> pageGroup = WebPageGroup::create(String::format("__WebInspectorPageGroupLevel%u__", level), false, false);
#ifndef NDEBUG
// Allow developers to inspect the Web Inspector in debug builds.
pageGroup->preferences()->setDeveloperExtrasEnabled(true);
pageGroup->preferences()->setLogsPageMessagesToSystemConsoleEnabled(true);
// Allow developers to inspect the Web Inspector in debug builds.
pageGroup->preferences()->setDeveloperExtrasEnabled(true);
pageGroup->preferences()->setLogsPageMessagesToSystemConsoleEnabled(true);
#endif
pageGroup->preferences()->setApplicationChromeModeEnabled(true);
pageGroup->preferences()->setApplicationChromeModeEnabled(true);
return pageGroup.release();
}
return pageGroup.release();
}
WebPageGroup* WebInspectorProxy::inspectorPageGroup()
{
static WebPageGroup* pageGroup = createInspectorPageGroup().leakRef();
return pageGroup;
}
typedef HashMap<unsigned, RefPtr<WebPageGroup> > PageGroupByLevelMap;
typedef HashMap<WebPageGroup*, unsigned> PageGroupLevelMap;
PageGroupByLevelMap m_pageGroupByLevel;
PageGroupLevelMap m_pageGroupLevel;
};
WebInspectorProxy::WebInspectorProxy(WebPageProxy* page)
: m_page(page)
......@@ -98,6 +139,7 @@ WebInspectorProxy::WebInspectorProxy(WebPageProxy* page)
, m_remoteInspectionPageId(0)
#endif
{
m_level = WebInspectorPageGroups::shared().inspectorLevel(m_page->pageGroup());
m_page->process()->addMessageReceiver(Messages::WebInspectorProxy::messageReceiverName(), m_page->pageID(), this);
}
......@@ -105,6 +147,11 @@ WebInspectorProxy::~WebInspectorProxy()
{
}
WebPageGroup* WebInspectorProxy::inspectorPageGroup() const
{
return WebInspectorPageGroups::shared().inspectorPageGroupForLevel(m_level);
}
void WebInspectorProxy::invalidate()
{
#if ENABLE(INSPECTOR_SERVER)
......@@ -311,7 +358,7 @@ void WebInspectorProxy::togglePageProfiling()
bool WebInspectorProxy::isInspectorPage(WebPageProxy* page)
{
return page->pageGroup() == inspectorPageGroup();
return WebInspectorPageGroups::shared().isInspectorPageGroup(page->pageGroup());
}
static bool isMainInspectorPage(const WebInspectorProxy* webInspectorProxy, WKURLRequestRef requestRef)
......@@ -502,8 +549,7 @@ bool WebInspectorProxy::canAttach()
return true;
// Don't allow attaching to another inspector -- two inspectors in one window is too much!
bool isInspectorPage = m_page->pageGroup() == inspectorPageGroup();
if (isInspectorPage)
if (m_level > 0)
return false;
// Don't allow the attach if the window would be too small to accommodate the minimum inspector height.
......
......@@ -190,7 +190,7 @@ private:
void open();
static WebPageGroup* inspectorPageGroup();
WebPageGroup* inspectorPageGroup() const;
#if PLATFORM(GTK) || PLATFORM(EFL)
void createInspectorWindow();
......@@ -217,6 +217,11 @@ private:
bool m_createdInspectorPage;
bool m_ignoreFirstBringToFront;
// The debugger stops all the pages in the same PageGroup. Having
// all the inspectors in the same group will make it impossible to debug
// the inspector code, so we use the level to make different page groups.
unsigned m_level;
AttachmentSide m_attachmentSide;
#if PLATFORM(MAC)
......
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