Title: [117966] trunk
Revision
117966
Author
[email protected]
Date
2012-05-22 06:55:10 -0700 (Tue, 22 May 2012)

Log Message

Web Inspector: [regression] dynamically created script tab is bound to the document resource.
https://bugs.webkit.org/show_bug.cgi?id=87119

Reviewed by Vsevolod Vlasov.

Source/WebCore:

Test: inspector/debugger/dynamic-script-tag.html

* inspector/front-end/BreakpointManager.js:
(WebInspector.BreakpointManager.Breakpoint.prototype._setInDebugger.didSetBreakpoint):
(WebInspector.BreakpointManager.Breakpoint.prototype._setInDebugger):
* inspector/front-end/DebuggerModel.js:
(WebInspector.DebuggerModel.prototype.rawLocationToUILocation):
* inspector/front-end/ResourceScriptMapping.js:
(WebInspector.ResourceScriptMapping.prototype.addScript):
(WebInspector.ResourceScriptMapping.prototype._shouldBindScriptToContentProvider):
* inspector/front-end/Script.js:
(WebInspector.Script.prototype.rawLocationToUILocation):
(WebInspector.Script.Location.prototype.update):

LayoutTests:

* inspector/debugger/dynamic-script-tag-expected.txt: Added.
* inspector/debugger/dynamic-script-tag.html: Added.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (117965 => 117966)


--- trunk/LayoutTests/ChangeLog	2012-05-22 13:50:35 UTC (rev 117965)
+++ trunk/LayoutTests/ChangeLog	2012-05-22 13:55:10 UTC (rev 117966)
@@ -1,3 +1,13 @@
+2012-05-22  Pavel Feldman  <[email protected]>
+
+        Web Inspector: [regression] dynamically created script tab is bound to the document resource.
+        https://bugs.webkit.org/show_bug.cgi?id=87119
+
+        Reviewed by Vsevolod Vlasov.
+
+        * inspector/debugger/dynamic-script-tag-expected.txt: Added.
+        * inspector/debugger/dynamic-script-tag.html: Added.
+
 2012-05-22  Mikhail Pozdnyakov  <[email protected]>
 
         [EFL][DRT] Gardening of fast/spatial-navigation tests.

Added: trunk/LayoutTests/inspector/debugger/dynamic-script-tag-expected.txt (0 => 117966)


--- trunk/LayoutTests/inspector/debugger/dynamic-script-tag-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/inspector/debugger/dynamic-script-tag-expected.txt	2012-05-22 13:55:10 UTC (rev 117966)
@@ -0,0 +1,12 @@
+CONSOLE MESSAGE: line 1: 123
+Tests that dynamically added script tag gets its own _javascript_Source and is not bound to the resource. Bug 87119
+
+Debugger was enabled.
+Is anonymous:false
+Is inline script:false
+dynamic-script-tag.html
+UI name: dynamic-script-tag.html
+UI resource: null
+UI content: console.log(123)
+Debugger was disabled.
+
Property changes on: trunk/LayoutTests/inspector/debugger/dynamic-script-tag-expected.txt
___________________________________________________________________

Added: svn:eol-style

Added: trunk/LayoutTests/inspector/debugger/dynamic-script-tag.html (0 => 117966)


--- trunk/LayoutTests/inspector/debugger/dynamic-script-tag.html	                        (rev 0)
+++ trunk/LayoutTests/inspector/debugger/dynamic-script-tag.html	2012-05-22 13:55:10 UTC (rev 117966)
@@ -0,0 +1,63 @@
+<html>
+<head>
+<script src=""
+<script src=""
+
+<script>
+
+function createScriptTag()
+{
+    var script = document.createElement("script");
+    script.innerHTML = "console.log(123)";
+    document.head.appendChild(script);
+}
+
+function test()
+{
+    InspectorTest.startDebuggerTest(step1);
+
+    function step1()
+    {
+        InspectorTest.evaluateInPage("createScriptTag()");
+        WebInspector.debuggerModel.addEventListener(WebInspector.DebuggerModel.Events.ParsedScriptSource, step2);
+    }
+
+    function step2(event)
+    {
+        var script = event.data;
+        script.requestContent(callback);
+        function callback(content)
+        {
+            if (content !== "console.log(123)")
+                return;
+            InspectorTest.addResult("Is anonymous:" + script.isAnonymousScript());
+            InspectorTest.addResult("Is inline script:" + script.isInlineScript());
+            InspectorTest.addResult(new WebInspector.ParsedURL(script.sourceURL).displayName);
+            // Invoke post source map install.
+            setTimeout(step3.bind(this, script), 0);
+        }
+    }
+
+    function step3(script)
+    {
+        var uiLocation = script.rawLocationToUILocation(0, 0);
+        InspectorTest.addResult("UI name: " + uiLocation.uiSourceCode.parsedURL.displayName);
+        InspectorTest.addResult("UI resource: " + uiLocation.uiSourceCode.resource());
+        uiLocation.uiSourceCode.requestContent(callback);
+        function callback(content)
+        {
+            InspectorTest.addResult("UI content: " + content);
+            InspectorTest.completeDebuggerTest();
+        }
+    }
+}
+</script>
+</head>
+<body _onload_="runTest()">
+<p>
+Tests that dynamically added script tag gets its own _javascript_Source and is not bound to the resource.
+<a href="" 87119</a>
+</p>
+</body>
+
+</html>
Property changes on: trunk/LayoutTests/inspector/debugger/dynamic-script-tag.html
___________________________________________________________________

Added: svn:eol-style

Modified: trunk/Source/WebCore/ChangeLog (117965 => 117966)


--- trunk/Source/WebCore/ChangeLog	2012-05-22 13:50:35 UTC (rev 117965)
+++ trunk/Source/WebCore/ChangeLog	2012-05-22 13:55:10 UTC (rev 117966)
@@ -1,3 +1,24 @@
+2012-05-22  Pavel Feldman  <[email protected]>
+
+        Web Inspector: [regression] dynamically created script tab is bound to the document resource.
+        https://bugs.webkit.org/show_bug.cgi?id=87119
+
+        Reviewed by Vsevolod Vlasov.
+
+        Test: inspector/debugger/dynamic-script-tag.html
+
+        * inspector/front-end/BreakpointManager.js:
+        (WebInspector.BreakpointManager.Breakpoint.prototype._setInDebugger.didSetBreakpoint):
+        (WebInspector.BreakpointManager.Breakpoint.prototype._setInDebugger):
+        * inspector/front-end/DebuggerModel.js:
+        (WebInspector.DebuggerModel.prototype.rawLocationToUILocation):
+        * inspector/front-end/ResourceScriptMapping.js:
+        (WebInspector.ResourceScriptMapping.prototype.addScript):
+        (WebInspector.ResourceScriptMapping.prototype._shouldBindScriptToContentProvider):
+        * inspector/front-end/Script.js:
+        (WebInspector.Script.prototype.rawLocationToUILocation):
+        (WebInspector.Script.Location.prototype.update):
+
 2012-05-22  Vsevolod Vlasov  <[email protected]>
 
         Web Inspector: _javascript_ breakpoints disappear when Ctrl+S is pressed for the script without changes.

Modified: trunk/Source/WebCore/inspector/front-end/BreakpointManager.js (117965 => 117966)


--- trunk/Source/WebCore/inspector/front-end/BreakpointManager.js	2012-05-22 13:50:35 UTC (rev 117965)
+++ trunk/Source/WebCore/inspector/front-end/BreakpointManager.js	2012-05-22 13:55:10 UTC (rev 117966)
@@ -381,7 +381,7 @@
             this._resetLocations();
             for (var i = 0; i < locations.length; ++i) {
                 var script = this._breakpointManager._debuggerModel.scriptForId(locations[i].scriptId);
-                var uiLocation = script.rawLocationToUILocation(locations[i]);
+                var uiLocation = script.rawLocationToUILocation(locations[i].lineNumber, locations[i].columnNumber);
                 if (this._breakpointManager.findBreakpoint(uiLocation.uiSourceCode, uiLocation.lineNumber)) {
                     // location clash
                     this.remove();

Modified: trunk/Source/WebCore/inspector/front-end/DebuggerModel.js (117965 => 117966)


--- trunk/Source/WebCore/inspector/front-end/DebuggerModel.js	2012-05-22 13:50:35 UTC (rev 117965)
+++ trunk/Source/WebCore/inspector/front-end/DebuggerModel.js	2012-05-22 13:55:10 UTC (rev 117966)
@@ -535,7 +535,7 @@
         var script = this._scripts[rawLocation.scriptId];
         if (!script)
             return null;
-        return script.rawLocationToUILocation(rawLocation);
+        return script.rawLocationToUILocation(rawLocation.lineNumber, rawLocation.columnNumber);
     }
 }
 

Modified: trunk/Source/WebCore/inspector/front-end/ResourceScriptMapping.js (117965 => 117966)


--- trunk/Source/WebCore/inspector/front-end/ResourceScriptMapping.js	2012-05-22 13:50:35 UTC (rev 117965)
+++ trunk/Source/WebCore/inspector/front-end/ResourceScriptMapping.js	2012-05-22 13:55:10 UTC (rev 117966)
@@ -93,9 +93,15 @@
             // Ignore resource in case it has not yet finished loading.
             if (resource && resource.request && !resource.request.finished)
                 resource = null;
+            // Only bind inline and standalone scripts.
+            if (resource && !this._shouldBindScriptToContentProvider(script, resource))
+                resource = null;
             if (!resource) {
                 // When there is no resource, lookup in-flight requests.
                 request = WebInspector.networkManager.inflightRequestForURL(script.sourceURL);
+                // Only bind inline and standalone scripts.
+                if (request && !this._shouldBindScriptToContentProvider(script, request))
+                  request = null;
             }
         }
         console.assert(!resource || !request);
@@ -123,6 +129,18 @@
     },
 
     /**
+     * @param {WebInspector.Script} script
+     * @param {WebInspector.ContentProvider} contentProvider
+     * @return {boolean}
+     */
+    _shouldBindScriptToContentProvider: function(script, contentProvider)
+    {
+        if (script.isInlineScript())
+            return contentProvider.contentType() === WebInspector.resourceTypes.Document;
+        return contentProvider.contentType() === WebInspector.resourceTypes.Script;
+    },
+
+    /**
      * @param {WebInspector.Event} event
      */
     _handleUISourceCodeChanged: function(event)

Modified: trunk/Source/WebCore/inspector/front-end/Script.js (117965 => 117966)


--- trunk/Source/WebCore/inspector/front-end/Script.js	2012-05-22 13:50:35 UTC (rev 117965)
+++ trunk/Source/WebCore/inspector/front-end/Script.js	2012-05-22 13:55:10 UTC (rev 117966)
@@ -167,13 +167,13 @@
     },
 
     /**
-     * @param {DebuggerAgent.Location} rawLocation
+     * @param {number} lineNumber
+     * @param {number=} columnNumber
      * @return {WebInspector.UILocation}
      */
-    rawLocationToUILocation: function(rawLocation)
+    rawLocationToUILocation: function(lineNumber, columnNumber)
     {
-        console.assert(rawLocation.scriptId === this.scriptId);
-        var uiLocation = this._sourceMapping.rawLocationToUILocation(rawLocation);
+        var uiLocation = this._sourceMapping.rawLocationToUILocation(new WebInspector.DebuggerModel.Location(this, lineNumber, columnNumber || 0));
         return uiLocation.uiSourceCode.overrideLocation(uiLocation);
     },
 
@@ -219,7 +219,7 @@
 WebInspector.Script.Location.prototype = {
     update: function()
     {
-        var uiLocation = this._script.rawLocationToUILocation(this._rawLocation);
+        var uiLocation = this._script.rawLocationToUILocation(this._rawLocation.lineNumber, this._rawLocation.columnNumber);
         if (uiLocation) {
             var uiSourceCode = uiLocation.uiSourceCode;
             if (this._uiSourceCodes.indexOf(uiSourceCode) === -1) {
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to