- Revision
- 158976
- Author
- [email protected]
- Date
- 2013-11-08 16:39:31 -0800 (Fri, 08 Nov 2013)
Log Message
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.
Modified Paths
Added Paths
Diff
Modified: trunk/LayoutTests/ChangeLog (158975 => 158976)
--- trunk/LayoutTests/ChangeLog 2013-11-09 00:39:03 UTC (rev 158975)
+++ trunk/LayoutTests/ChangeLog 2013-11-09 00:39:31 UTC (rev 158976)
@@ -1,3 +1,15 @@
+2013-11-08 Alexandru Chiculita <[email protected]>
+
+ 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 <[email protected]>
[CSS Shapes] Image valued shape-outside that extends vertically into the margin-box is top-clipped
Added: trunk/LayoutTests/inspector-protocol/debugger/nested-inspectors-expected.txt (0 => 158976)
--- trunk/LayoutTests/inspector-protocol/debugger/nested-inspectors-expected.txt (rev 0)
+++ trunk/LayoutTests/inspector-protocol/debugger/nested-inspectors-expected.txt 2013-11-09 00:39:31 UTC (rev 158976)
@@ -0,0 +1,8 @@
+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!
+
Added: trunk/LayoutTests/inspector-protocol/debugger/nested-inspectors.html (0 => 158976)
--- trunk/LayoutTests/inspector-protocol/debugger/nested-inspectors.html (rev 0)
+++ trunk/LayoutTests/inspector-protocol/debugger/nested-inspectors.html 2013-11-09 00:39:31 UTC (rev 158976)
@@ -0,0 +1,57 @@
+<html>
+<head>
+<script src=""
+<script src=""
+<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>
Modified: trunk/Source/WebKit2/ChangeLog (158975 => 158976)
--- trunk/Source/WebKit2/ChangeLog 2013-11-09 00:39:03 UTC (rev 158975)
+++ trunk/Source/WebKit2/ChangeLog 2013-11-09 00:39:31 UTC (rev 158976)
@@ -1,3 +1,32 @@
+2013-11-08 Alexandru Chiculita <[email protected]>
+
+ 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 <[email protected]>
Begin stubbing out a KeyedEncoder class in WebCore
Modified: trunk/Source/WebKit2/UIProcess/WebInspectorProxy.cpp (158975 => 158976)
--- trunk/Source/WebKit2/UIProcess/WebInspectorProxy.cpp 2013-11-09 00:39:03 UTC (rev 158975)
+++ trunk/Source/WebKit2/UIProcess/WebInspectorProxy.cpp 2013-11-09 00:39:31 UTC (rev 158976)
@@ -58,27 +58,68 @@
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)
, m_isVisible(false)
@@ -98,6 +139,7 @@
, 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 @@
{
}
+WebPageGroup* WebInspectorProxy::inspectorPageGroup() const
+{
+ return WebInspectorPageGroups::shared().inspectorPageGroupForLevel(m_level);
+}
+
void WebInspectorProxy::invalidate()
{
#if ENABLE(INSPECTOR_SERVER)
@@ -311,7 +358,7 @@
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 @@
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.
Modified: trunk/Source/WebKit2/UIProcess/WebInspectorProxy.h (158975 => 158976)
--- trunk/Source/WebKit2/UIProcess/WebInspectorProxy.h 2013-11-09 00:39:03 UTC (rev 158975)
+++ trunk/Source/WebKit2/UIProcess/WebInspectorProxy.h 2013-11-09 00:39:31 UTC (rev 158976)
@@ -190,7 +190,7 @@
void open();
- static WebPageGroup* inspectorPageGroup();
+ WebPageGroup* inspectorPageGroup() const;
#if PLATFORM(GTK) || PLATFORM(EFL)
void createInspectorWindow();
@@ -217,6 +217,11 @@
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)