Diff
Modified: trunk/LayoutTests/ChangeLog (131301 => 131302)
--- trunk/LayoutTests/ChangeLog 2012-10-15 14:47:12 UTC (rev 131301)
+++ trunk/LayoutTests/ChangeLog 2012-10-15 15:06:12 UTC (rev 131302)
@@ -1,3 +1,19 @@
+2012-10-15 Vsevolod Vlasov <[email protected]>
+
+ Web Inspector: Scripts for dynamically added script elements are not shown in sources panel.
+ https://bugs.webkit.org/show_bug.cgi?id=99324
+
+ Reviewed by Pavel Feldman.
+
+ * http/tests/inspector-enabled/dynamic-scripts-expected.txt: Added.
+ * http/tests/inspector-enabled/dynamic-scripts.html: Added.
+ * http/tests/inspector-enabled/resources/dynamic-script.js: Added.
+ (fooDynamicScript):
+ * inspector/debugger/dynamic-scripts-expected.txt: Added.
+ * inspector/debugger/dynamic-scripts.html: Added.
+ * inspector/debugger/resources/dynamic-script.js: Added.
+ (fooDynamicScript):
+
2012-10-15 Tullio Lucena <[email protected]>
[Qt] Unskip and rebase now passing tests.
Added: trunk/LayoutTests/http/tests/inspector-enabled/dynamic-scripts-expected.txt (0 => 131302)
--- trunk/LayoutTests/http/tests/inspector-enabled/dynamic-scripts-expected.txt (rev 0)
+++ trunk/LayoutTests/http/tests/inspector-enabled/dynamic-scripts-expected.txt 2012-10-15 15:06:12 UTC (rev 131302)
@@ -0,0 +1,12 @@
+Tests that scripts for dynamically added script elements are shown in sources panel if inspector is opened after the scripts were loaded.
+
+Bug 99324
+UISourceCodes:
+ dynamic-script.js
+ dynamic-scripts.html
+ dynamic-scripts.html (1)
+ dynamic-scripts.html (2)
+ evalSourceURL.js
+ inspector-test.js
+ scriptElementContentSourceURL.js
+
Property changes on: trunk/LayoutTests/http/tests/inspector-enabled/dynamic-scripts-expected.txt
___________________________________________________________________
Added: svn:eol-style
Added: trunk/LayoutTests/http/tests/inspector-enabled/dynamic-scripts.html (0 => 131302)
--- trunk/LayoutTests/http/tests/inspector-enabled/dynamic-scripts.html (rev 0)
+++ trunk/LayoutTests/http/tests/inspector-enabled/dynamic-scripts.html 2012-10-15 15:06:12 UTC (rev 131302)
@@ -0,0 +1,63 @@
+<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
+<html>
+<head>
+<script src=""
+<script>
+function appendDynamicScriptElement(src, content)
+{
+ var scriptElement = document.createElement("script");
+ if (src)
+ scriptElement.src = ""
+ else
+ scriptElement.textContent = content;
+ document.head.appendChild(scriptElement);
+}
+
+function loadScripts()
+{
+ var sourceURLComment = "\n //@ sourceURL=";
+ window.eval("function fooEval() {}");
+ window.eval("function fooEvalSourceURL() {}" + sourceURLComment + "evalSourceURL.js");
+ appendDynamicScriptElement("", "function fooScriptElementContent1() {}");
+ appendDynamicScriptElement("", "function fooScriptElementContent2() {}");
+ appendDynamicScriptElement("", "function fooScriptElementContentSourceURL() {}" + sourceURLComment + "scriptElementContentSourceURL.js");
+ appendDynamicScriptElement("resources/dynamic-script.js");
+}
+
+function onload()
+{
+ if (window.testRunner)
+ testRunner.waitUntilDone();
+ loadScripts();
+}
+
+function scriptLoaded()
+{
+ if (window.testRunner)
+ testRunner.showWebInspector();
+ runTest();
+}
+
+function test()
+{
+ InspectorTest.runAfterPendingDispatches(step1);
+
+ function step1()
+ {
+ var panel = WebInspector.showPanel("scripts");
+ var uiSourceCodes = WebInspector.workspace.uiSourceCodes();
+ var urls = uiSourceCodes.map(function(uiSourceCode) { return uiSourceCode.parsedURL.lastPathComponent; });
+ var urls = urls.sort();
+ InspectorTest.addResult("UISourceCodes:");
+ for (var i = 0; i < urls.length; ++i)
+ InspectorTest.addResult(" " + urls[i]);
+ InspectorTest.completeTest();
+ }
+}
+</script>
+</head>
+<body _onload_="onload()">
+<p>Tests that scripts for dynamically added script elements are shown in sources panel if inspector is opened after the scripts were loaded.</p>
+<a href="" 99324</a>
+</body>
+</html>
Property changes on: trunk/LayoutTests/http/tests/inspector-enabled/dynamic-scripts.html
___________________________________________________________________
Added: svn:eol-style
Added: trunk/LayoutTests/http/tests/inspector-enabled/resources/dynamic-script.js (0 => 131302)
--- trunk/LayoutTests/http/tests/inspector-enabled/resources/dynamic-script.js (rev 0)
+++ trunk/LayoutTests/http/tests/inspector-enabled/resources/dynamic-script.js 2012-10-15 15:06:12 UTC (rev 131302)
@@ -0,0 +1,5 @@
+function fooDynamicScript()
+{
+}
+
+scriptLoaded();
Property changes on: trunk/LayoutTests/http/tests/inspector-enabled/resources/dynamic-script.js
___________________________________________________________________
Added: svn:eol-style
Added: trunk/LayoutTests/inspector/debugger/dynamic-scripts-expected.txt (0 => 131302)
--- trunk/LayoutTests/inspector/debugger/dynamic-scripts-expected.txt (rev 0)
+++ trunk/LayoutTests/inspector/debugger/dynamic-scripts-expected.txt 2012-10-15 15:06:12 UTC (rev 131302)
@@ -0,0 +1,13 @@
+CONSOLE MESSAGE: line 29: Done.
+Tests that scripts for dynamically added script elements are shown in sources panel if loaded with inspector open.
+
+Bug 99324
+UISourceCodes:
+ dynamic-script.js
+ dynamic-scripts.html
+ dynamic-scripts.html (1)
+ dynamic-scripts.html (2)
+ evalSourceURL.js
+ inspector-test.js
+ scriptElementContentSourceURL.js
+
Property changes on: trunk/LayoutTests/inspector/debugger/dynamic-scripts-expected.txt
___________________________________________________________________
Added: svn:eol-style
Added: trunk/LayoutTests/inspector/debugger/dynamic-scripts.html (0 => 131302)
--- trunk/LayoutTests/inspector/debugger/dynamic-scripts.html (rev 0)
+++ trunk/LayoutTests/inspector/debugger/dynamic-scripts.html 2012-10-15 15:06:12 UTC (rev 131302)
@@ -0,0 +1,60 @@
+<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
+<html>
+<head>
+<script src=""
+<script>
+function appendDynamicScriptElement(src, content)
+{
+ var scriptElement = document.createElement("script");
+ if (src)
+ scriptElement.src = ""
+ else
+ scriptElement.textContent = content;
+ document.head.appendChild(scriptElement);
+}
+
+function loadScripts()
+{
+ var sourceURLComment = "\n //@ sourceURL=";
+ window.eval("function fooEval() {}");
+ window.eval("function fooEvalSourceURL() {}" + sourceURLComment + "evalSourceURL.js");
+ appendDynamicScriptElement("", "function fooScriptElementContent1() {}");
+ appendDynamicScriptElement("", "function fooScriptElementContent2() {}");
+ appendDynamicScriptElement("", "function fooScriptElementContentSourceURL() {}" + sourceURLComment + "scriptElementContentSourceURL.js");
+ appendDynamicScriptElement("resources/dynamic-script.js");
+}
+
+function scriptLoaded()
+{
+ console.log("Done.");
+}
+
+function test()
+{
+ InspectorTest.addConsoleSniffer(step1);
+ InspectorTest.evaluateInPage("loadScripts()", function() { })
+
+ function step1()
+ {
+ InspectorTest.runAfterPendingDispatches(step2);
+ }
+
+ function step2()
+ {
+ var panel = WebInspector.showPanel("scripts");
+ var uiSourceCodes = WebInspector.workspace.uiSourceCodes();
+ var urls = uiSourceCodes.map(function(uiSourceCode) { return uiSourceCode.parsedURL.lastPathComponent; });
+ urls.sort();
+ InspectorTest.addResult("UISourceCodes:");
+ for (var i = 0; i < urls.length; ++i)
+ InspectorTest.addResult(" " + urls[i]);
+ InspectorTest.completeTest();
+ }
+}
+</script>
+</head>
+<body _onload_="runTest()">
+<p>Tests that scripts for dynamically added script elements are shown in sources panel if loaded with inspector open.</p>
+<a href="" 99324</a>
+</body>
+</html>
Property changes on: trunk/LayoutTests/inspector/debugger/dynamic-scripts.html
___________________________________________________________________
Added: svn:eol-style
Added: trunk/LayoutTests/inspector/debugger/resources/dynamic-script.js (0 => 131302)
--- trunk/LayoutTests/inspector/debugger/resources/dynamic-script.js (rev 0)
+++ trunk/LayoutTests/inspector/debugger/resources/dynamic-script.js 2012-10-15 15:06:12 UTC (rev 131302)
@@ -0,0 +1,5 @@
+function fooDynamicScript()
+{
+}
+
+scriptLoaded();
Property changes on: trunk/LayoutTests/inspector/debugger/resources/dynamic-script.js
___________________________________________________________________
Added: svn:eol-style
Modified: trunk/Source/WebCore/ChangeLog (131301 => 131302)
--- trunk/Source/WebCore/ChangeLog 2012-10-15 14:47:12 UTC (rev 131301)
+++ trunk/Source/WebCore/ChangeLog 2012-10-15 15:06:12 UTC (rev 131302)
@@ -1,3 +1,23 @@
+2012-10-15 Vsevolod Vlasov <[email protected]>
+
+ Web Inspector: Scripts for dynamically added script elements are not shown in sources panel.
+ https://bugs.webkit.org/show_bug.cgi?id=99324
+
+ Reviewed by Pavel Feldman.
+
+ NetworkUISourceCodeProvider now adds uiSourceCodes for dynamic anonymous scripts
+ and dynamic scripts loaded before inspector was opened.
+
+ Tests: http/tests/inspector-enabled/dynamic-scripts.html
+ inspector/debugger/dynamic-scripts.html
+
+ * inspector/front-end/NetworkLog.js:
+ (WebInspector.NetworkLog.prototype.requestForURL):
+ * inspector/front-end/NetworkUISourceCodeProvider.js:
+ (WebInspector.NetworkUISourceCodeProvider):
+ (WebInspector.NetworkUISourceCodeProvider.prototype._parsedScriptSource):
+ (WebInspector.NetworkUISourceCodeProvider.prototype._projectWillReset):
+
2012-10-15 Dominik Röttsches <[email protected]>
REGRESSION(130613): Reintroduces crashes when using soup's timeout functionality
Modified: trunk/Source/WebCore/inspector/front-end/NetworkLog.js (131301 => 131302)
--- trunk/Source/WebCore/inspector/front-end/NetworkLog.js 2012-10-15 14:47:12 UTC (rev 131301)
+++ trunk/Source/WebCore/inspector/front-end/NetworkLog.js 2012-10-15 15:06:12 UTC (rev 131302)
@@ -51,6 +51,19 @@
},
/**
+ * @param {string} url
+ * @return {WebInspector.NetworkRequest}
+ */
+ requestForURL: function(url)
+ {
+ for (var i = 0; i < this._requests.length; ++i) {
+ if (this._requests[i].url ="" url)
+ return this._requests[i];
+ }
+ return null;
+ },
+
+ /**
* @param {WebInspector.NetworkRequest} request
* @return {WebInspector.PageLoad}
*/
Modified: trunk/Source/WebCore/inspector/front-end/NetworkUISourceCodeProvider.js (131301 => 131302)
--- trunk/Source/WebCore/inspector/front-end/NetworkUISourceCodeProvider.js 2012-10-15 14:47:12 UTC (rev 131301)
+++ trunk/Source/WebCore/inspector/front-end/NetworkUISourceCodeProvider.js 2012-10-15 15:06:12 UTC (rev 131302)
@@ -41,6 +41,7 @@
WebInspector.debuggerModel.addEventListener(WebInspector.DebuggerModel.Events.ParsedScriptSource, this._parsedScriptSource, this);
this._uiSourceCodeForResource = {};
+ this._lastDynamicAnonymousScriptIndexForURL = {};
}
WebInspector.NetworkUISourceCodeProvider.prototype = {
@@ -65,19 +66,36 @@
_parsedScriptSource: function(event)
{
var script = /** @type {WebInspector.Script} */ event.data;
- if (!script.hasSourceURL && !script.isContentScript)
+ if (!script.sourceURL || script.isInlineScript())
return;
- if (!script.sourceURL)
- return;
+ var isDynamicAnonymousScript;
+ // Only add uiSourceCodes for
+ // - content scripts;
+ // - scripts with explicit sourceURL comment;
+ // - dynamic anonymous scripts (script elements without src attribute);
+ // - dynamic scripts (script elements with src attribute) when inspector is opened after the script was loaded.
+ if (!script.hasSourceURL && !script.isContentScript) {
+ var resource = WebInspector.resourceForURL(script.sourceURL);
+ if (resource && resource.contentType() === WebInspector.resourceTypes.Document)
+ isDynamicAnonymousScript = true;
+ else if (resource || WebInspector.networkLog.requestForURL(script.sourceURL))
+ return;
+ }
// Filter out embedder injected content scripts.
if (script.isContentScript && !script.hasSourceURL) {
var parsedURL = new WebInspector.ParsedURL(script.sourceURL);
if (!parsedURL.host)
return;
}
- if (this._uiSourceCodeForResource[script.sourceURL])
+ if (this._uiSourceCodeForResource[script.sourceURL] && !isDynamicAnonymousScript)
return;
- var uiSourceCode = new WebInspector._javascript_Source(script.sourceURL, script, true);
+ var url = ""
+ if (isDynamicAnonymousScript) {
+ var dynamicAnonymousScriptIndex = (this._lastDynamicAnonymousScriptIndexForURL[url] || 0) + 1;
+ this._lastDynamicAnonymousScriptIndexForURL[url] = dynamicAnonymousScriptIndex;
+ url += " (" + dynamicAnonymousScriptIndex + ")";
+ }
+ var uiSourceCode = new WebInspector._javascript_Source(url, script, true);
this._uiSourceCodeForResource[script.sourceURL] = uiSourceCode;
this._workspace.project().addUISourceCode(uiSourceCode);
},
@@ -111,6 +129,7 @@
_projectWillReset: function()
{
this._uiSourceCodeForResource = {};
+ this._lastDynamicAnonymousScriptIndexForURL = {};
},
_projectDidReset: function()