Title: [91461] trunk
Revision
91461
Author
[email protected]
Date
2011-07-21 05:19:56 -0700 (Thu, 21 Jul 2011)

Log Message

Web Inspector: [protocol] extend setBreakpointByUrl request to accept incomplete URL (predicates)
https://bugs.webkit.org/show_bug.cgi?id=60762

Reviewed by Yury Semikhatsky.

Source/WebCore:

Test: inspector/debugger/debugger-set-breakpoint-regex.html

* inspector/Inspector.json:
* inspector/InspectorDebuggerAgent.cpp:
(WebCore::buildObjectForBreakpointCookie):
(WebCore::matches):
(WebCore::InspectorDebuggerAgent::setBreakpointByUrl):
(WebCore::InspectorDebuggerAgent::didParseSource):
* inspector/InspectorDebuggerAgent.h:

LayoutTests:

* inspector/debugger/debugger-set-breakpoint-regex-expected.txt: Added.
* inspector/debugger/debugger-set-breakpoint-regex.html: Added.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (91460 => 91461)


--- trunk/LayoutTests/ChangeLog	2011-07-21 11:21:40 UTC (rev 91460)
+++ trunk/LayoutTests/ChangeLog	2011-07-21 12:19:56 UTC (rev 91461)
@@ -1,3 +1,13 @@
+2011-07-21  Pavel Feldman  <[email protected]>
+
+        Web Inspector: [protocol] extend setBreakpointByUrl request to accept incomplete URL (predicates)
+        https://bugs.webkit.org/show_bug.cgi?id=60762
+
+        Reviewed by Yury Semikhatsky.
+
+        * inspector/debugger/debugger-set-breakpoint-regex-expected.txt: Added.
+        * inspector/debugger/debugger-set-breakpoint-regex.html: Added.
+
 2011-07-21  Kent Tamura  <[email protected]>
 
         REGRESSION(r88757): input[type=range] renders incorrectly in RTL context.

Added: trunk/LayoutTests/inspector/debugger/debugger-set-breakpoint-regex-expected.txt (0 => 91461)


--- trunk/LayoutTests/inspector/debugger/debugger-set-breakpoint-regex-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/inspector/debugger/debugger-set-breakpoint-regex-expected.txt	2011-07-21 12:19:56 UTC (rev 91461)
@@ -0,0 +1,10 @@
+Tests Debugger.setBreakpointByUrl with isRegex set to true.
+
+Debugger was enabled.
+Set timer for test function.
+Script execution paused.
+Call stack:
+    0) testFunction (debugger-set-breakpoint-regex.html:9)
+Script execution resumed.
+Debugger was disabled.
+
Property changes on: trunk/LayoutTests/inspector/debugger/debugger-set-breakpoint-regex-expected.txt
___________________________________________________________________

Added: svn:eol-style

Added: trunk/LayoutTests/inspector/debugger/debugger-set-breakpoint-regex.html (0 => 91461)


--- trunk/LayoutTests/inspector/debugger/debugger-set-breakpoint-regex.html	                        (rev 0)
+++ trunk/LayoutTests/inspector/debugger/debugger-set-breakpoint-regex.html	2011-07-21 12:19:56 UTC (rev 91461)
@@ -0,0 +1,48 @@
+<html>
+<head>
+<script src=""
+<script src=""
+<script>
+
+function testFunction()
+{
+    foo();
+}
+
+function foo()
+{
+}
+
+function test()
+{
+    InspectorTest.startDebuggerTest(step1);
+
+    function step1()
+    {
+        var columnNumber = undefined;
+        var condition = undefined;
+        var isRegex = true;
+        DebuggerAgent.setBreakpointByUrl("debugger-set-breakpoint.*", 8, columnNumber, condition, isRegex, step2);
+    }
+
+    function step2()
+    {
+        InspectorTest.runTestFunctionAndWaitUntilPaused(step3);
+    }
+
+    function step3(callFrames)
+    {
+        InspectorTest.captureStackTrace(callFrames);
+        InspectorTest.completeDebuggerTest();
+    }
+}
+
+</script>
+</head>
+
+<body _onload_="runTest()">
+<p>
+Tests Debugger.setBreakpointByUrl with isRegex set to true.
+</p>
+</body>
+</html>
Property changes on: trunk/LayoutTests/inspector/debugger/debugger-set-breakpoint-regex.html
___________________________________________________________________

Added: svn:eol-style

Modified: trunk/Source/WebCore/ChangeLog (91460 => 91461)


--- trunk/Source/WebCore/ChangeLog	2011-07-21 11:21:40 UTC (rev 91460)
+++ trunk/Source/WebCore/ChangeLog	2011-07-21 12:19:56 UTC (rev 91461)
@@ -1,3 +1,20 @@
+2011-07-21  Pavel Feldman  <[email protected]>
+
+        Web Inspector: [protocol] extend setBreakpointByUrl request to accept incomplete URL (predicates)
+        https://bugs.webkit.org/show_bug.cgi?id=60762
+
+        Reviewed by Yury Semikhatsky.
+
+        Test: inspector/debugger/debugger-set-breakpoint-regex.html
+
+        * inspector/Inspector.json:
+        * inspector/InspectorDebuggerAgent.cpp:
+        (WebCore::buildObjectForBreakpointCookie):
+        (WebCore::matches):
+        (WebCore::InspectorDebuggerAgent::setBreakpointByUrl):
+        (WebCore::InspectorDebuggerAgent::didParseSource):
+        * inspector/InspectorDebuggerAgent.h:
+
 2011-07-21  Kent Tamura  <[email protected]>
 
         REGRESSION(r88757): input[type=range] renders incorrectly in RTL context.

Modified: trunk/Source/WebCore/inspector/Inspector.json (91460 => 91461)


--- trunk/Source/WebCore/inspector/Inspector.json	2011-07-21 11:21:40 UTC (rev 91460)
+++ trunk/Source/WebCore/inspector/Inspector.json	2011-07-21 12:19:56 UTC (rev 91461)
@@ -1475,7 +1475,8 @@
                     { "name": "url", "type": "string", "description": "URL of the resource to set breakpoint on." },
                     { "name": "lineNumber", "type": "integer", "description": "Line number to set breakpoint at." },
                     { "name": "columnNumber", "type": "integer", "optional": true, "description": "Offset in the line to set breakpoint at." },
-                    { "name": "condition", "type": "string", "optional": true, "description": "_expression_ to use as a breakpoint condition. When specified, debugger will only stop on the breakpoint if this _expression_ evaluates to true." }
+                    { "name": "condition", "type": "string", "optional": true, "description": "_expression_ to use as a breakpoint condition. When specified, debugger will only stop on the breakpoint if this _expression_ evaluates to true." },
+                    { "name": "isRegex", "type": "boolean", "optional": true, "description": "If true, given <code>url</code> is considered to be a regular _expression_." }
                 ],
                 "returns": [
                     { "name": "breakpointId", "type": "string", "description": "Id of the created breakpoint for further manipulations." },

Modified: trunk/Source/WebCore/inspector/InspectorDebuggerAgent.cpp (91460 => 91461)


--- trunk/Source/WebCore/inspector/InspectorDebuggerAgent.cpp	2011-07-21 11:21:40 UTC (rev 91460)
+++ trunk/Source/WebCore/inspector/InspectorDebuggerAgent.cpp	2011-07-21 12:19:56 UTC (rev 91461)
@@ -37,6 +37,7 @@
 #include "InspectorState.h"
 #include "InspectorValues.h"
 #include "InstrumentingAgents.h"
+#include "RegularExpression.h"
 #include "ScriptDebugServer.h"
 #include "ScriptObject.h"
 #include <wtf/text/WTFString.h>
@@ -160,31 +161,42 @@
     m_breakpointIdToDebugServerBreakpointIds.clear();
 }
 
-static PassRefPtr<InspectorObject> buildObjectForBreakpointCookie(const String& url, int lineNumber, int columnNumber, const String& condition)
+static PassRefPtr<InspectorObject> buildObjectForBreakpointCookie(const String& url, int lineNumber, int columnNumber, const String& condition, bool isRegex)
 {
     RefPtr<InspectorObject> breakpointObject = InspectorObject::create();
     breakpointObject->setString("url", url);
     breakpointObject->setNumber("lineNumber", lineNumber);
     breakpointObject->setNumber("columnNumber", columnNumber);
     breakpointObject->setString("condition", condition);
+    breakpointObject->setBoolean("isRegex", isRegex);
     return breakpointObject;
 }
 
-void InspectorDebuggerAgent::setBreakpointByUrl(ErrorString*, const String& url, int lineNumber, const int* const optionalColumnNumber, const String* const optionalCondition, String* outBreakpointId, RefPtr<InspectorArray>* locations)
+static bool matches(const String& url, const String& pattern, bool isRegex)
 {
+    if (isRegex) {
+        RegularExpression regex(pattern, TextCaseSensitive);
+        return regex.match(url) != -1;
+    }
+    return url == pattern;
+}
+
+void InspectorDebuggerAgent::setBreakpointByUrl(ErrorString*, const String& url, int lineNumber, const int* const optionalColumnNumber, const String* const optionalCondition, const bool* const optionalIsRegex, String* outBreakpointId, RefPtr<InspectorArray>* locations)
+{
     int columnNumber = optionalColumnNumber ? *optionalColumnNumber : 0;
     String condition = optionalCondition ? *optionalCondition : "";
+    bool isRegex = optionalIsRegex ? *optionalIsRegex : false;
 
-    String breakpointId = url + ':' + String::number(lineNumber) + ':' + String::number(columnNumber);
+    String breakpointId = (isRegex ? "/" + url + "/" : url) + ':' + String::number(lineNumber) + ':' + String::number(columnNumber);
     RefPtr<InspectorObject> breakpointsCookie = m_inspectorState->getObject(DebuggerAgentState::_javascript_Breakpoints);
     if (breakpointsCookie->find(breakpointId) != breakpointsCookie->end())
         return;
-    breakpointsCookie->setObject(breakpointId, buildObjectForBreakpointCookie(url, lineNumber, columnNumber, condition));
+    breakpointsCookie->setObject(breakpointId, buildObjectForBreakpointCookie(url, lineNumber, columnNumber, condition, isRegex));
     m_inspectorState->setObject(DebuggerAgentState::_javascript_Breakpoints, breakpointsCookie);
 
     ScriptBreakpoint breakpoint(lineNumber, columnNumber, condition);
     for (ScriptsMap::iterator it = m_scripts.begin(); it != m_scripts.end(); ++it) {
-        if (it->second.url != url)
+        if (!matches(it->second.url, url, isRegex))
             continue;
         RefPtr<InspectorObject> location = resolveBreakpoint(breakpointId, it->first, breakpoint);
         if (location)
@@ -414,9 +426,11 @@
     RefPtr<InspectorObject> breakpointsCookie = m_inspectorState->getObject(DebuggerAgentState::_javascript_Breakpoints);
     for (InspectorObject::iterator it = breakpointsCookie->begin(); it != breakpointsCookie->end(); ++it) {
         RefPtr<InspectorObject> breakpointObject = it->second->asObject();
-        String breakpointURL;
-        breakpointObject->getString("url", &breakpointURL);
-        if (breakpointURL != script.url)
+        bool isRegex;
+        breakpointObject->getBoolean("isRegex", &isRegex);
+        String url;
+        breakpointObject->getString("url", &url);
+        if (!matches(script.url, url, isRegex))
             continue;
         ScriptBreakpoint breakpoint;
         breakpointObject->getNumber("lineNumber", &breakpoint.lineNumber);

Modified: trunk/Source/WebCore/inspector/InspectorDebuggerAgent.h (91460 => 91461)


--- trunk/Source/WebCore/inspector/InspectorDebuggerAgent.h	2011-07-21 11:21:40 UTC (rev 91460)
+++ trunk/Source/WebCore/inspector/InspectorDebuggerAgent.h	2011-07-21 12:19:56 UTC (rev 91461)
@@ -82,7 +82,7 @@
     // Part of the protocol.
     void setBreakpointsActive(ErrorString*, bool active);
 
-    void setBreakpointByUrl(ErrorString*, const String& url, int lineNumber, const int* const optionalColumnNumber, const String* const optionalCondition, String* breakpointId, RefPtr<InspectorArray>* locations);
+    void setBreakpointByUrl(ErrorString*, const String& url, int lineNumber, const int* const optionalColumnNumber, const String* const optionalCondition, const bool* const optionalIsRegex, String* breakpointId, RefPtr<InspectorArray>* locations);
     void setBreakpoint(ErrorString*, PassRefPtr<InspectorObject> location, const String* const optionalCondition, String* breakpointId, RefPtr<InspectorObject>* actualLocation);
     void removeBreakpoint(ErrorString*, const String& breakpointId);
     void continueToLocation(ErrorString*, PassRefPtr<InspectorObject> location);
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to