Title: [104831] trunk
Revision
104831
Author
podivi...@chromium.org
Date
2012-01-12 09:06:51 -0800 (Thu, 12 Jan 2012)

Log Message

Web Inspector: [JSC] //@ sourceURL is not respected.
https://bugs.webkit.org/show_bug.cgi?id=65532

Reviewed by Pavel Feldman.

Source/WebCore:

Test: inspector/debugger/source-url-comment.html

* bindings/js/ScriptDebugServer.cpp:
(WebCore::ScriptDebugServer::dispatchDidParseSource):
* inspector/ContentSearchUtils.cpp:
(WebCore::ContentSearchUtils::findMagicComment):
(WebCore::ContentSearchUtils::findSourceURL):
(WebCore::ContentSearchUtils::findSourceMapURL):
* inspector/ContentSearchUtils.h:

LayoutTests:

* inspector/debugger/source-url-comment-expected.txt: Added.
* inspector/debugger/source-url-comment.html: Added.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (104830 => 104831)


--- trunk/LayoutTests/ChangeLog	2012-01-12 16:42:38 UTC (rev 104830)
+++ trunk/LayoutTests/ChangeLog	2012-01-12 17:06:51 UTC (rev 104831)
@@ -1,3 +1,13 @@
+2012-01-12  Pavel Podivilov  <podivi...@chromium.org>
+
+        Web Inspector: [JSC] //@ sourceURL is not respected.
+        https://bugs.webkit.org/show_bug.cgi?id=65532
+
+        Reviewed by Pavel Feldman.
+
+        * inspector/debugger/source-url-comment-expected.txt: Added.
+        * inspector/debugger/source-url-comment.html: Added.
+
 2012-01-12  Sheriff Bot  <webkit.review....@gmail.com>
 
         Unreviewed, rolling out r104805.

Added: trunk/LayoutTests/inspector/debugger/source-url-comment-expected.txt (0 => 104831)


--- trunk/LayoutTests/inspector/debugger/source-url-comment-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/inspector/debugger/source-url-comment-expected.txt	2012-01-12 17:06:51 UTC (rev 104831)
@@ -0,0 +1,9 @@
+Tests that evals with sourceURL comment are shown in scripts panel.
+
+Debugger was enabled.
+
+Running: testSourceURLComment
+function keepAlive() {}
+//@ sourceURL=evalURL.js
+Debugger was disabled.
+
Property changes on: trunk/LayoutTests/inspector/debugger/source-url-comment-expected.txt
___________________________________________________________________

Added: svn:eol-style

Added: trunk/LayoutTests/inspector/debugger/source-url-comment.html (0 => 104831)


--- trunk/LayoutTests/inspector/debugger/source-url-comment.html	                        (rev 0)
+++ trunk/LayoutTests/inspector/debugger/source-url-comment.html	2012-01-12 17:06:51 UTC (rev 104831)
@@ -0,0 +1,37 @@
+<html>
+<head>
+<script src=""
+<script src=""
+
+<script>
+
+function doEval()
+{
+    eval("function keepAlive() {}\n//@ sourceURL=evalURL.js");
+}
+
+function test()
+{
+    InspectorTest.runDebuggerTestSuite([
+        function testSourceURLComment(next)
+        {
+            InspectorTest.showScriptSource("evalURL.js", didShowScriptSource);
+            InspectorTest.evaluateInPage("setTimeout(doEval, 0)");
+
+            function didShowScriptSource(sourceFrame)
+            {
+                InspectorTest.addResult(sourceFrame.textModel.text);
+                next();
+            }
+        }
+    ]);
+};
+
+</script>
+
+</head>
+
+<body _onload_="runTest()">
+<p>Tests that evals with sourceURL comment are shown in scripts panel.</p>
+</body>
+</html>
Property changes on: trunk/LayoutTests/inspector/debugger/source-url-comment.html
___________________________________________________________________

Added: svn:eol-style

Modified: trunk/Source/WebCore/ChangeLog (104830 => 104831)


--- trunk/Source/WebCore/ChangeLog	2012-01-12 16:42:38 UTC (rev 104830)
+++ trunk/Source/WebCore/ChangeLog	2012-01-12 17:06:51 UTC (rev 104831)
@@ -1,3 +1,20 @@
+2012-01-12  Pavel Podivilov  <podivi...@chromium.org>
+
+        Web Inspector: [JSC] //@ sourceURL is not respected.
+        https://bugs.webkit.org/show_bug.cgi?id=65532
+
+        Reviewed by Pavel Feldman.
+
+        Test: inspector/debugger/source-url-comment.html
+
+        * bindings/js/ScriptDebugServer.cpp:
+        (WebCore::ScriptDebugServer::dispatchDidParseSource):
+        * inspector/ContentSearchUtils.cpp:
+        (WebCore::ContentSearchUtils::findMagicComment):
+        (WebCore::ContentSearchUtils::findSourceURL):
+        (WebCore::ContentSearchUtils::findSourceMapURL):
+        * inspector/ContentSearchUtils.h:
+
 2012-01-12  Csaba Osztrogonác  <o...@webkit.org>
 
         [Qt] Unreviewed trivial buildfix after r104828.

Modified: trunk/Source/WebCore/bindings/js/ScriptDebugServer.cpp (104830 => 104831)


--- trunk/Source/WebCore/bindings/js/ScriptDebugServer.cpp	2012-01-12 16:42:38 UTC (rev 104830)
+++ trunk/Source/WebCore/bindings/js/ScriptDebugServer.cpp	2012-01-12 17:06:51 UTC (rev 104831)
@@ -33,6 +33,7 @@
 
 #include "ScriptDebugServer.h"
 
+#include "ContentSearchUtils.h"
 #include "EventLoop.h"
 #include "Frame.h"
 #include "JSJavaScriptCallFrame.h"
@@ -235,6 +236,9 @@
     script.startColumn = sourceProvider->startPosition().m_column.zeroBasedInt();
     script.isContentScript = isContentScript;
 
+    if (script.url.isEmpty())
+        script.url = ""
+
     int sourceLength = script.source.length();
     int lineCount = 1;
     int lastLineStart = 0;

Modified: trunk/Source/WebCore/inspector/ContentSearchUtils.cpp (104830 => 104831)


--- trunk/Source/WebCore/inspector/ContentSearchUtils.cpp	2012-01-12 16:42:38 UTC (rev 104830)
+++ trunk/Source/WebCore/inspector/ContentSearchUtils.cpp	2012-01-12 17:06:51 UTC (rev 104831)
@@ -140,11 +140,11 @@
     return result;
 }
 
-String findSourceMapURL(const String& content)
+static String findMagicComment(const String& content, const String& name)
 {
-    DEFINE_STATIC_LOCAL(String, patternString, ("//@[\040\t]sourceMappingURL=[\040\t]*([^\\s\'\"]*)"));
-    const char* error;
-    JSC::Yarr::YarrPattern pattern(JSC::UString(patternString.impl()), false, false, &error);
+    String patternString = "//@[\040\t]" + name + "=[\040\t]*([^\\s\'\"]*)[\040\t]*$";
+    const char* error = 0;
+    JSC::Yarr::YarrPattern pattern(JSC::UString(patternString.impl()), false, true, &error);
     ASSERT(!error);
     BumpPointerAllocator regexAllocator;
     OwnPtr<JSC::Yarr::BytecodePattern> bytecodePattern = JSC::Yarr::byteCompile(pattern, &regexAllocator);
@@ -157,9 +157,19 @@
     if (result < 0)
         return String();
     ASSERT(matches[2] > 0 && matches[3] > 0);
-    return content.substring(matches[2], matches[3]);
+    return content.substring(matches[2], matches[3] - matches[2]);
 }
 
+String findSourceURL(const String& content)
+{
+    return findMagicComment(content, "sourceURL");
+}
+
+String findSourceMapURL(const String& content)
+{
+    return findMagicComment(content, "sourceMappingURL");
+}
+
 } // namespace ContentSearchUtils
 } // namespace WebCore
 

Modified: trunk/Source/WebCore/inspector/ContentSearchUtils.h (104830 => 104831)


--- trunk/Source/WebCore/inspector/ContentSearchUtils.h	2012-01-12 16:42:38 UTC (rev 104830)
+++ trunk/Source/WebCore/inspector/ContentSearchUtils.h	2012-01-12 17:06:51 UTC (rev 104831)
@@ -44,6 +44,7 @@
 int countRegularExpressionMatches(const RegularExpression&, const String&);
 PassRefPtr<InspectorArray> searchInTextByLines(const String& text, const String& query, const bool caseSensitive, const bool isRegex);
 
+String findSourceURL(const String& content);
 String findSourceMapURL(const String& content);
 
 } // namespace ContentSearchUtils
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to