Title: [157939] trunk
Revision
157939
Author
[email protected]
Date
2013-10-24 11:22:21 -0700 (Thu, 24 Oct 2013)

Log Message

Web Inspector: Breakpoints in sourceURL named scripts do not work
https://bugs.webkit.org/show_bug.cgi?id=123231

Patch by Joseph Pecoraro <[email protected]> on 2013-10-24
Reviewed by Timothy Hatcher.

Source/WebCore:

Remember a Script's sourceURL and sourceMappingURL. When setting a
breakpoint by URL, check it against the sourceURL or original URL.
If a script had a sourceURL that would have been the only URL sent
to the frontend, so that receives priority.

Test: inspector-protocol/debugger/setBreakpointByUrl-sourceURL.html

* inspector/InspectorDebuggerAgent.cpp:
(WebCore::InspectorDebuggerAgent::setBreakpointByUrl):
(WebCore::InspectorDebuggerAgent::didParseSource):
* inspector/InspectorDebuggerAgent.h:
* inspector/ScriptDebugListener.h:

LayoutTests:

* inspector-protocol/debugger/setBreakpointByUrl-sourceURL-expected.txt: Added.
* inspector-protocol/debugger/setBreakpointByUrl-sourceURL.html: Added.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (157938 => 157939)


--- trunk/LayoutTests/ChangeLog	2013-10-24 17:08:23 UTC (rev 157938)
+++ trunk/LayoutTests/ChangeLog	2013-10-24 18:22:21 UTC (rev 157939)
@@ -1,3 +1,13 @@
+2013-10-24  Joseph Pecoraro  <[email protected]>
+
+        Web Inspector: Breakpoints in sourceURL named scripts do not work
+        https://bugs.webkit.org/show_bug.cgi?id=123231
+
+        Reviewed by Timothy Hatcher.
+
+        * inspector-protocol/debugger/setBreakpointByUrl-sourceURL-expected.txt: Added.
+        * inspector-protocol/debugger/setBreakpointByUrl-sourceURL.html: Added.
+
 2013-10-24  Alexandru Chiculita  <[email protected]>
 
         Web Inspector: Add a way to test the Manager and model classes

Added: trunk/LayoutTests/inspector-protocol/debugger/setBreakpointByUrl-sourceURL-expected.txt (0 => 157939)


--- trunk/LayoutTests/inspector-protocol/debugger/setBreakpointByUrl-sourceURL-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/inspector-protocol/debugger/setBreakpointByUrl-sourceURL-expected.txt	2013-10-24 18:22:21 UTC (rev 157939)
@@ -0,0 +1,9 @@
+Debugger.setBreakpointByUrl in Script named via sourceURL
+
+Breakpoints Enabled
+Found sourceURL-test.js
+Running sourceURLFunction
+Hit Breakpoint!
+Evaluted value of `a` (expecting number 1) was: {"type":"number","value":1,"description":"1"}
+Evaluted value of `c` (expecting undefined) was: {"type":"undefined"}
+

Added: trunk/LayoutTests/inspector-protocol/debugger/setBreakpointByUrl-sourceURL.html (0 => 157939)


--- trunk/LayoutTests/inspector-protocol/debugger/setBreakpointByUrl-sourceURL.html	                        (rev 0)
+++ trunk/LayoutTests/inspector-protocol/debugger/setBreakpointByUrl-sourceURL.html	2013-10-24 18:22:21 UTC (rev 157939)
@@ -0,0 +1,47 @@
+<html>
+<head>
+<script src=""
+<script src=""
+<script>
+// sourceURL-test.js:
+eval("function sourceURLFunction() {\n    var a = 1;\n    var b = 2;\n    var c = a+b;\n    alert(c);\n}\n//# sourceURL=sourceURL-test.js")
+
+function test()
+{
+    InspectorTest.sendCommand("Debugger.enable", {});
+    InspectorTest.sendCommand("Debugger.setBreakpointsActive", {active: true}, function() {
+        InspectorTest.log("Breakpoints Enabled");
+    });
+
+    InspectorTest.eventHandler["Debugger.scriptParsed"] = function(messageObject)
+    {
+        if (/sourceURL-test\.js$/.test(messageObject.params.url)) {
+            InspectorTest.log("Found sourceURL-test.js");
+            var params = {url: messageObject.params.url, lineNumber: 3, columnNumber: 0};
+            InspectorTest.sendCommand("Debugger.setBreakpointByUrl", params, function(responseObject) {
+                InspectorTest.checkForError(responseObject);
+                InspectorTest.log("Running sourceURLFunction");
+                InspectorTest.sendCommand("Runtime.evaluate", {_expression_: "sourceURLFunction()"});
+            });
+        }
+    }
+
+    InspectorTest.eventHandler["Debugger.paused"] = function(messageObject)
+    {
+        InspectorTest.log("Hit Breakpoint!");
+        var callFrameIdentifier = messageObject.params.callFrames[0].callFrameId;
+        InspectorTest.sendCommand("Debugger.evaluateOnCallFrame", {callFrameId: callFrameIdentifier, _expression_: "a"}, function(messageObject) {
+            InspectorTest.log("Evaluted value of `a` (expecting number 1) was: " + JSON.stringify(messageObject.result.result));
+            InspectorTest.sendCommand("Debugger.evaluateOnCallFrame", {callFrameId: callFrameIdentifier, _expression_: "c"}, function(messageObject) {
+                InspectorTest.log("Evaluted value of `c` (expecting undefined) was: " + JSON.stringify(messageObject.result.result));
+                InspectorTest.completeTest();
+            });
+        });
+    }
+}
+</script>
+</head>
+<body _onload_="runTest()">
+<p>Debugger.setBreakpointByUrl in Script named via sourceURL</p>
+</body>
+</html>

Modified: trunk/Source/WebCore/ChangeLog (157938 => 157939)


--- trunk/Source/WebCore/ChangeLog	2013-10-24 17:08:23 UTC (rev 157938)
+++ trunk/Source/WebCore/ChangeLog	2013-10-24 18:22:21 UTC (rev 157939)
@@ -1,3 +1,23 @@
+2013-10-24  Joseph Pecoraro  <[email protected]>
+
+        Web Inspector: Breakpoints in sourceURL named scripts do not work
+        https://bugs.webkit.org/show_bug.cgi?id=123231
+
+        Reviewed by Timothy Hatcher.
+
+        Remember a Script's sourceURL and sourceMappingURL. When setting a
+        breakpoint by URL, check it against the sourceURL or original URL.
+        If a script had a sourceURL that would have been the only URL sent
+        to the frontend, so that receives priority.
+
+        Test: inspector-protocol/debugger/setBreakpointByUrl-sourceURL.html
+
+        * inspector/InspectorDebuggerAgent.cpp:
+        (WebCore::InspectorDebuggerAgent::setBreakpointByUrl):
+        (WebCore::InspectorDebuggerAgent::didParseSource):
+        * inspector/InspectorDebuggerAgent.h:
+        * inspector/ScriptDebugListener.h:
+
 2013-10-23  Alexey Proskuryakov  <[email protected]>
 
         Add CryptoKey base class and bindings

Modified: trunk/Source/WebCore/inspector/InspectorDebuggerAgent.cpp (157938 => 157939)


--- trunk/Source/WebCore/inspector/InspectorDebuggerAgent.cpp	2013-10-24 17:08:23 UTC (rev 157938)
+++ trunk/Source/WebCore/inspector/InspectorDebuggerAgent.cpp	2013-10-24 18:22:21 UTC (rev 157939)
@@ -320,8 +320,10 @@
 
     ScriptBreakpoint breakpoint(lineNumber, columnNumber, condition, breakpointActions, autoContinue);
     for (ScriptsMap::iterator it = m_scripts.begin(); it != m_scripts.end(); ++it) {
-        if (!matches(it->value.url, url, isRegex))
+        String scriptURL = !it->value.sourceURL.isEmpty() ? it->value.sourceURL : it->value.url;
+        if (!matches(scriptURL, url, isRegex))
             continue;
+
         RefPtr<TypeBuilder::Debugger::Location> location = resolveBreakpoint(breakpointId, it->key, breakpoint);
         if (location)
             locations->addItem(location);
@@ -701,18 +703,18 @@
 
 // _javascript_DebugListener functions
 
-void InspectorDebuggerAgent::didParseSource(const String& scriptId, const Script& script)
+void InspectorDebuggerAgent::didParseSource(const String& scriptId, const Script& inScript)
 {
-    // Don't send script content to the front end until it's really needed.
-    const bool* isContentScript = script.isContentScript ? &script.isContentScript : 0;
-    String sourceMapURL = sourceMapURLForScript(script);
-    String* sourceMapURLParam = sourceMapURL.isNull() ? 0 : &sourceMapURL;
-    String sourceURL;
+    Script script = inScript;
     if (!script.startLine && !script.startColumn)
-        sourceURL = ContentSearchUtils::findScriptSourceURL(script.source);
-    bool hasSourceURL = !sourceURL.isEmpty();
-    String scriptURL = hasSourceURL ? sourceURL : script.url;
+        script.sourceURL = ContentSearchUtils::findScriptSourceURL(script.source);
+    script.sourceMappingURL = sourceMapURLForScript(script);
+
+    bool hasSourceURL = !script.sourceURL.isEmpty();
+    String scriptURL = hasSourceURL ? script.sourceURL : script.url;
     bool* hasSourceURLParam = hasSourceURL ? &hasSourceURL : 0;
+    String* sourceMapURLParam = script.sourceMappingURL.isNull() ? 0 : &script.sourceMappingURL;
+    const bool* isContentScript = script.isContentScript ? &script.isContentScript : 0;
     m_frontend->scriptParsed(scriptId, scriptURL, script.startLine, script.startColumn, script.endLine, script.endColumn, isContentScript, sourceMapURLParam, hasSourceURLParam);
 
     m_scripts.set(scriptId, script);

Modified: trunk/Source/WebCore/inspector/InspectorDebuggerAgent.h (157938 => 157939)


--- trunk/Source/WebCore/inspector/InspectorDebuggerAgent.h	2013-10-24 17:08:23 UTC (rev 157938)
+++ trunk/Source/WebCore/inspector/InspectorDebuggerAgent.h	2013-10-24 18:22:21 UTC (rev 157939)
@@ -151,8 +151,8 @@
 
     PassRefPtr<TypeBuilder::Array<TypeBuilder::Debugger::CallFrame>> currentCallFrames();
 
-    virtual void didParseSource(const String& scriptId, const Script&);
-    virtual void failedToParseSource(const String& url, const String& data, int firstLine, int errorLine, const String& errorMessage);
+    virtual void didParseSource(const String& scriptId, const Script&) OVERRIDE FINAL;
+    virtual void failedToParseSource(const String& url, const String& data, int firstLine, int errorLine, const String& errorMessage) OVERRIDE FINAL;
 
     void setPauseOnExceptionsImpl(ErrorString*, int);
 

Modified: trunk/Source/WebCore/inspector/ScriptDebugListener.h (157938 => 157939)


--- trunk/Source/WebCore/inspector/ScriptDebugListener.h	2013-10-24 17:08:23 UTC (rev 157938)
+++ trunk/Source/WebCore/inspector/ScriptDebugListener.h	2013-10-24 18:22:21 UTC (rev 157939)
@@ -54,6 +54,7 @@
 
         String url;
         String source;
+        String sourceURL;
         String sourceMappingURL;
         int startLine;
         int startColumn;
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to