Diff
Modified: trunk/LayoutTests/ChangeLog (130137 => 130138)
--- trunk/LayoutTests/ChangeLog 2012-10-02 08:25:19 UTC (rev 130137)
+++ trunk/LayoutTests/ChangeLog 2012-10-02 08:28:02 UTC (rev 130138)
@@ -1,3 +1,13 @@
+2012-09-20 Vsevolod Vlasov <vse...@chromium.org>
+
+ Web Inspector: Provide a way to distinguish scripts having sourceURL from standalone scripts.
+ https://bugs.webkit.org/show_bug.cgi?id=97231
+
+ Reviewed by Pavel Feldman.
+
+ * inspector/debugger/source-url-comment-expected.txt:
+ * inspector/debugger/source-url-comment.html:
+
2012-10-02 Philip Rogers <p...@google.com>
Fix PerfTest standard deviation calculation.
Modified: trunk/LayoutTests/inspector/debugger/source-url-comment-expected.txt (130137 => 130138)
--- trunk/LayoutTests/inspector/debugger/source-url-comment-expected.txt 2012-10-02 08:25:19 UTC (rev 130137)
+++ trunk/LayoutTests/inspector/debugger/source-url-comment-expected.txt 2012-10-02 08:28:02 UTC (rev 130138)
@@ -2,8 +2,14 @@
Debugger was enabled.
+Running: testSourceURLCommentInInlineScript
+
Running: testSourceURLComment
function keepAlive() {}
//@ sourceURL=evalURL.js
+
+Running: testSourceURLCommentInDynamicScript
+function keepAliveInDynamicScript() {}
+//@ sourceURL=dynamicScriptURL.js
Debugger was disabled.
Modified: trunk/LayoutTests/inspector/debugger/source-url-comment.html (130137 => 130138)
--- trunk/LayoutTests/inspector/debugger/source-url-comment.html 2012-10-02 08:25:19 UTC (rev 130137)
+++ trunk/LayoutTests/inspector/debugger/source-url-comment.html 2012-10-02 08:28:02 UTC (rev 130138)
@@ -2,17 +2,57 @@
<head>
<script src=""
<script src=""
+<script>
+function keepAliveInInlineScript() { }
+//@ sourceURL=inlineScriptURL.js
+</script>
<script>
-
function doEval()
{
eval("function keepAlive() {}\n//@ sourceURL=evalURL.js");
}
+function doDynamicScript()
+{
+ var scriptElement = document.createElement("script");
+ scriptElement.textContent = "function keepAliveInDynamicScript() {}\n//@ sourceURL=dynamicScriptURL.js";
+ document.body.appendChild(scriptElement);
+}
+
function test()
+
{
+ function forEachScriptMatchingURL(url, handler)
+ {
+ var scripts = WebInspector.debuggerModel.scripts;
+ for (var i = 0; i < scripts.length; ++i) {
+ if (scripts[i].sourceURL.indexOf(url) !== -1)
+ handler(scripts[i]);
+ }
+ }
+
InspectorTest.runDebuggerTestSuite([
+ function testSourceURLCommentInInlineScript(next)
+ {
+ InspectorTest.showScriptSource("source-url-comment.html", didShowScriptSource);
+
+ function didShowScriptSource(sourceFrame)
+ {
+ function checkScriptDoesNotHaveSourceURL(script)
+ {
+ InspectorTest.assertTrue(!script.hasSourceURL, "hasSourceURL flag is set for inline script");
+ }
+
+ var panel = WebInspector.panel("scripts");
+ var uiSourceCodes = panel._workspace.uiSourceCodes();
+ for (var i = 0; i < uiSourceCodes.length; ++i)
+ InspectorTest.assertTrue(uiSourceCodes[i].url.indexOf("inlineScriptURL.js") === -1, "sourceURL comment in inline script was used as a script name");
+ forEachScriptMatchingURL("source-url-comment.html", checkScriptDoesNotHaveSourceURL)
+ next();
+ }
+ },
+
function testSourceURLComment(next)
{
InspectorTest.showScriptSource("evalURL.js", didShowScriptSource);
@@ -20,9 +60,33 @@
function didShowScriptSource(sourceFrame)
{
+ function checkScriptHasSourceURL(script)
+ {
+ InspectorTest.assertTrue(script.hasSourceURL, "hasSourceURL flag is not set for eval with sourceURL comment");
+ }
+
InspectorTest.addResult(sourceFrame.textEditor.text());
+ forEachScriptMatchingURL("evalURL.js", checkScriptHasSourceURL);
next();
}
+ },
+
+ function testSourceURLCommentInDynamicScript(next)
+ {
+ InspectorTest.showScriptSource("dynamicScriptURL.js", didShowScriptSource);
+ InspectorTest.evaluateInPage("setTimeout(doDynamicScript, 0)");
+
+ function didShowScriptSource(sourceFrame)
+ {
+ function checkScriptHasSourceURL(script)
+ {
+ InspectorTest.assertTrue(script.hasSourceURL, "hasSourceURL flag is not set for dynamic script with sourceURL comment");
+ }
+
+ InspectorTest.addResult(sourceFrame.textEditor.text());
+ forEachScriptMatchingURL("dynamicScriptURL.js", checkScriptHasSourceURL);
+ next();
+ }
}
]);
};
Modified: trunk/Source/WebCore/ChangeLog (130137 => 130138)
--- trunk/Source/WebCore/ChangeLog 2012-10-02 08:25:19 UTC (rev 130137)
+++ trunk/Source/WebCore/ChangeLog 2012-10-02 08:28:02 UTC (rev 130138)
@@ -1,3 +1,24 @@
+2012-09-20 Vsevolod Vlasov <vse...@chromium.org>
+
+ Web Inspector: Provide a way to distinguish scripts having sourceURL from standalone scripts.
+ https://bugs.webkit.org/show_bug.cgi?id=97231
+
+ Reviewed by Pavel Feldman.
+
+ DebuggerAgent now scans scripts for sourceURL comment and provides
+ hasSourceURL flag for each non-inline script with such a comment.
+
+ * bindings/js/ScriptDebugServer.cpp:
+ (WebCore::ScriptDebugServer::dispatchDidParseSource):
+ * inspector/Inspector.json:
+ * inspector/InspectorDebuggerAgent.cpp:
+ (WebCore::InspectorDebuggerAgent::didParseSource):
+ * inspector/front-end/DebuggerModel.js:
+ (WebInspector.DebuggerModel.prototype._parsedScriptSource):
+ (WebInspector.DebuggerDispatcher.prototype.scriptParsed):
+ * inspector/front-end/Script.js:
+ (WebInspector.Script):
+
2012-10-02 Sheriff Bot <webkit.review....@gmail.com>
Unreviewed, rolling out r130129.
Modified: trunk/Source/WebCore/bindings/js/ScriptDebugServer.cpp (130137 => 130138)
--- trunk/Source/WebCore/bindings/js/ScriptDebugServer.cpp 2012-10-02 08:25:19 UTC (rev 130137)
+++ trunk/Source/WebCore/bindings/js/ScriptDebugServer.cpp 2012-10-02 08:28:02 UTC (rev 130138)
@@ -326,8 +326,11 @@
script.isContentScript = isContentScript;
#if ENABLE(INSPECTOR)
- if (script.url.isEmpty())
- script.url = ""
+ if (!script.startLine && !script.startColumn) {
+ String sourceURL = ContentSearchUtils::findSourceURL(script.source);
+ if (!sourceURL.isEmpty())
+ script.url = ""
+ }
#endif
int sourceLength = script.source.length();
Modified: trunk/Source/WebCore/inspector/Inspector.json (130137 => 130138)
--- trunk/Source/WebCore/inspector/Inspector.json 2012-10-02 08:25:19 UTC (rev 130137)
+++ trunk/Source/WebCore/inspector/Inspector.json 2012-10-02 08:28:02 UTC (rev 130138)
@@ -2761,7 +2761,8 @@
{ "name": "endLine", "type": "integer", "description": "Last line of the script." },
{ "name": "endColumn", "type": "integer", "description": "Length of the last line of the script." },
{ "name": "isContentScript", "type": "boolean", "optional": true, "description": "Determines whether this script is a user extension script." },
- { "name": "sourceMapURL", "type": "string", "optional": true, "description": "URL of source map associated with script (if any)." }
+ { "name": "sourceMapURL", "type": "string", "optional": true, "description": "URL of source map associated with script (if any)." },
+ { "name": "hasSourceURL", "type": "boolean", "optional": true, "description": "True, if this script has sourceURL." }
],
"description": "Fired when virtual machine parses script. This event is also fired for all known and uncollected scripts upon enabling debugger."
},
Modified: trunk/Source/WebCore/inspector/InspectorDebuggerAgent.cpp (130137 => 130138)
--- trunk/Source/WebCore/inspector/InspectorDebuggerAgent.cpp 2012-10-02 08:25:19 UTC (rev 130137)
+++ trunk/Source/WebCore/inspector/InspectorDebuggerAgent.cpp 2012-10-02 08:28:02 UTC (rev 130138)
@@ -630,7 +630,12 @@
const bool* isContentScript = script.isContentScript ? &script.isContentScript : 0;
String sourceMapURL = sourceMapURLForScript(script);
String* sourceMapURLParam = sourceMapURL.isNull() ? 0 : &sourceMapURL;
- m_frontend->scriptParsed(scriptId, script.url, script.startLine, script.startColumn, script.endLine, script.endColumn, isContentScript, sourceMapURLParam);
+ String sourceURL;
+ if (!script.startLine && !script.startColumn)
+ sourceURL = ContentSearchUtils::findSourceURL(script.source);
+ bool hasSourceURL = !sourceURL.isEmpty() && sourceURL == script.url;
+ bool* hasSourceURLParam = hasSourceURL ? &hasSourceURL : 0;
+ m_frontend->scriptParsed(scriptId, script.url, script.startLine, script.startColumn, script.endLine, script.endColumn, isContentScript, sourceMapURLParam, hasSourceURLParam);
m_scripts.set(scriptId, script);
Modified: trunk/Source/WebCore/inspector/front-end/DebuggerModel.js (130137 => 130138)
--- trunk/Source/WebCore/inspector/front-end/DebuggerModel.js 2012-10-02 08:25:19 UTC (rev 130137)
+++ trunk/Source/WebCore/inspector/front-end/DebuggerModel.js 2012-10-02 08:28:02 UTC (rev 130138)
@@ -371,10 +371,12 @@
* @param {number} endLine
* @param {number} endColumn
* @param {boolean} isContentScript
+ * @param {string=} sourceMapURL
+ * @param {boolean=} hasSourceURL
*/
- _parsedScriptSource: function(scriptId, sourceURL, startLine, startColumn, endLine, endColumn, isContentScript, sourceMapURL)
+ _parsedScriptSource: function(scriptId, sourceURL, startLine, startColumn, endLine, endColumn, isContentScript, sourceMapURL, hasSourceURL)
{
- var script = new WebInspector.Script(scriptId, sourceURL, startLine, startColumn, endLine, endColumn, isContentScript, sourceMapURL);
+ var script = new WebInspector.Script(scriptId, sourceURL, startLine, startColumn, endLine, endColumn, isContentScript, sourceMapURL, hasSourceURL);
this._registerScript(script);
this.dispatchEventToListeners(WebInspector.DebuggerModel.Events.ParsedScriptSource, script);
},
@@ -637,10 +639,11 @@
* @param {number} endColumn
* @param {boolean=} isContentScript
* @param {string=} sourceMapURL
+ * @param {boolean=} hasSourceURL
*/
- scriptParsed: function(scriptId, sourceURL, startLine, startColumn, endLine, endColumn, isContentScript, sourceMapURL)
+ scriptParsed: function(scriptId, sourceURL, startLine, startColumn, endLine, endColumn, isContentScript, sourceMapURL, hasSourceURL)
{
- this._debuggerModel._parsedScriptSource(scriptId, sourceURL, startLine, startColumn, endLine, endColumn, !!isContentScript, sourceMapURL);
+ this._debuggerModel._parsedScriptSource(scriptId, sourceURL, startLine, startColumn, endLine, endColumn, !!isContentScript, sourceMapURL, hasSourceURL);
},
/**
Modified: trunk/Source/WebCore/inspector/front-end/Script.js (130137 => 130138)
--- trunk/Source/WebCore/inspector/front-end/Script.js 2012-10-02 08:25:19 UTC (rev 130137)
+++ trunk/Source/WebCore/inspector/front-end/Script.js 2012-10-02 08:28:02 UTC (rev 130138)
@@ -34,8 +34,9 @@
* @param {number} endColumn
* @param {boolean} isContentScript
* @param {string=} sourceMapURL
+ * @param {boolean=} hasSourceURL
*/
-WebInspector.Script = function(scriptId, sourceURL, startLine, startColumn, endLine, endColumn, isContentScript, sourceMapURL)
+WebInspector.Script = function(scriptId, sourceURL, startLine, startColumn, endLine, endColumn, isContentScript, sourceMapURL, hasSourceURL)
{
this.scriptId = scriptId;
this.sourceURL = sourceURL;
@@ -45,6 +46,7 @@
this.endColumn = endColumn;
this.isContentScript = isContentScript;
this.sourceMapURL = sourceMapURL;
+ this.hasSourceURL = hasSourceURL;
this._locations = [];
}