Title: [140965] trunk
Revision
140965
Author
[email protected]
Date
2013-01-28 04:45:24 -0800 (Mon, 28 Jan 2013)

Log Message

Web Inspector: SourceURL and SourceMappingURL together in evalled code
https://bugs.webkit.org/show_bug.cgi?id=107939

Reviewed by Vsevolod Vlasov.

Source/WebCore:

Resolve map's sources URLs wrt script URL in case sourceMap is defined as data:.

* inspector/front-end/CompilerScriptMapping.js:
(WebInspector.CompilerScriptMapping.prototype.loadSourceMapForScript):
* inspector/front-end/ParsedURL.js:
(WebInspector.ParsedURL.completeURL):
* inspector/front-end/SourceMap.js:
(WebInspector.SourceMap.prototype._parseMap):

LayoutTests:

* http/tests/inspector/compiler-script-mapping-expected.txt:
* http/tests/inspector/compiler-script-mapping.html:

Modified Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (140964 => 140965)


--- trunk/LayoutTests/ChangeLog	2013-01-28 12:22:14 UTC (rev 140964)
+++ trunk/LayoutTests/ChangeLog	2013-01-28 12:45:24 UTC (rev 140965)
@@ -1,3 +1,13 @@
+2013-01-28  Pavel Feldman  <[email protected]>
+
+        Web Inspector: SourceURL and SourceMappingURL together in evalled code
+        https://bugs.webkit.org/show_bug.cgi?id=107939
+
+        Reviewed by Vsevolod Vlasov.
+
+        * http/tests/inspector/compiler-script-mapping-expected.txt:
+        * http/tests/inspector/compiler-script-mapping.html:
+
 2013-01-28  Zoltan Arvai  <[email protected]>
 
         [Qt] Unreviewed rebaseline after r140821.

Modified: trunk/LayoutTests/http/tests/inspector/compiler-script-mapping-expected.txt (140964 => 140965)


--- trunk/LayoutTests/http/tests/inspector/compiler-script-mapping-expected.txt	2013-01-28 12:22:14 UTC (rev 140964)
+++ trunk/LayoutTests/http/tests/inspector/compiler-script-mapping-expected.txt	2013-01-28 12:45:24 UTC (rev 140965)
@@ -2,20 +2,75 @@
 
 
 Running: testSimpleMap
+example.js === example.js
+0 === 0
+9 === 9
+example.js === example.js
+0 === 0
+13 === 13
+example.js === example.js
+0 === 0
+25 === 25
+example.js === example.js
+2 === 2
+4 === 4
+example.js === example.js
+2 === 2
+11 === 11
+example.js === example.js
+2 === 2
+24 === 24
+0 === 0
+0 === 0
+0 === 0
+17 === 17
+0 === 0
+18 === 18
+0 === 0
+29 === 29
+0 === 0
+29 === 29
 
 Running: testNoMappingEntry
+example.js === example.js
+0 === 0
+0 === 0
+example.js === example.js
+0 === 0
+2 === 2
 
 Running: testEmptyLine
+example.js === example.js
+0 === 0
+0 === 0
+3 === 3
+1 === 1
 
 Running: testSections
+source1.js === source1.js
+0 === 0
+0 === 0
+source1.js === source1.js
+2 === 2
+1 === 1
+source2.js === source2.js
+0 === 0
+0 === 0
+source2.js === source2.js
+2 === 2
+1 === 1
 
 Running: testResolveSourceMapURL
+http://example.com/map.json === http://example.com/map.json
+http://example.com/map.json === http://example.com/map.json
+http://example.com/scripts/../maps/map.json === http://example.com/scripts/../maps/map.json
 
 Running: testCompilerScriptMapping
 
 Running: testCompilerScriptMappingWhenResourceWasLoadedAfterSource
 
 Running: testInlinedSourceMap
+<source content> === <source content>
 
 Running: testSourceMapCouldNotBeLoaded
 compiled.js

Modified: trunk/LayoutTests/http/tests/inspector/compiler-script-mapping.html (140964 => 140965)


--- trunk/LayoutTests/http/tests/inspector/compiler-script-mapping.html	2013-01-28 12:22:14 UTC (rev 140964)
+++ trunk/LayoutTests/http/tests/inspector/compiler-script-mapping.html	2013-01-28 12:45:24 UTC (rev 140965)
@@ -23,16 +23,16 @@
     function checkMapping(compiledLineNumber, compiledColumnNumber, sourceURL, sourceLineNumber, sourceColumnNumber, mapping)
     {
         var entry = mapping.findEntry(compiledLineNumber, compiledColumnNumber);
-        InspectorTest.assertEquals(sourceURL, entry[2]);
-        InspectorTest.assertEquals(sourceLineNumber, entry[3]);
-        InspectorTest.assertEquals(sourceColumnNumber, entry[4]);
+        InspectorTest.addResult(sourceURL + " === " + entry[2]);
+        InspectorTest.addResult(sourceLineNumber + " === " + entry[3]);
+        InspectorTest.addResult(sourceColumnNumber + " === " + entry[4]);
     }
 
     function checkReverseMapping(compiledLineNumber, compiledColumnNumber, sourceURL, sourceLineNumber, mapping)
     {
         var entry = mapping.findEntryReversed(sourceURL, sourceLineNumber);
-        InspectorTest.assertEquals(compiledLineNumber, entry[0]);
-        InspectorTest.assertEquals(compiledColumnNumber, entry[1]);
+        InspectorTest.addResult(compiledLineNumber + " === " + entry[0]);
+        InspectorTest.addResult(compiledColumnNumber + " === " + entry[1]);
     }
 
     InspectorTest.runTestSuite([
@@ -130,10 +130,10 @@
 
         function testResolveSourceMapURL(next)
         {
-            var func = WebInspector.PositionBasedSourceMap.prototype._canonicalizeURL;
-            InspectorTest.assertEquals("http://example.com/map.json", func("http://example.com/map.json", "http://example.com/script.js"));
-            InspectorTest.assertEquals("http://example.com/map.json", func("/map.json", "http://example.com/script.js"));
-            InspectorTest.assertEquals("http://example.com/scripts/../maps/map.json", func("../maps/map.json", "http://example.com/scripts/script.js"));
+            var func = WebInspector.ParsedURL.completeURL;
+            InspectorTest.addResult("http://example.com/map.json === " + func("http://example.com/script.js", "http://example.com/map.json"));
+            InspectorTest.addResult("http://example.com/map.json === " + func("http://example.com/script.js", "/map.json"));
+            InspectorTest.addResult("http://example.com/scripts/../maps/map.json === " + func("http://example.com/scripts/script.js", "../maps/map.json"));
             next();
         },
 
@@ -291,7 +291,7 @@
             resourceScriptMapping.addScript(script);
             mapping.addScript(script);
 
-            var uiSourceCode = InspectorTest.testWorkspace.uiSourceCodeForOriginURL("source.js");
+            var uiSourceCode = InspectorTest.testWorkspace.uiSourceCodeForOriginURL("http://example.com/source.js");
 
             InspectorTest.checkUILocation(uiSourceCode, 2, 4, mapping.rawLocationToUILocation(WebInspector.debuggerModel.createRawLocation(script, 0, 18)));
             InspectorTest.checkRawLocation(script, 0, 18, mapping.uiLocationToRawLocation(uiSourceCode, 2, 4));
@@ -300,7 +300,7 @@
 
             function didRequestContent(content, contentEncoded, mimeType)
             {
-                InspectorTest.assertEquals("<source content>", content);
+                InspectorTest.addResult("<source content> === " + content);
                 next();
             }
         },

Modified: trunk/Source/WebCore/ChangeLog (140964 => 140965)


--- trunk/Source/WebCore/ChangeLog	2013-01-28 12:22:14 UTC (rev 140964)
+++ trunk/Source/WebCore/ChangeLog	2013-01-28 12:45:24 UTC (rev 140965)
@@ -1,3 +1,19 @@
+2013-01-28  Pavel Feldman  <[email protected]>
+
+        Web Inspector: SourceURL and SourceMappingURL together in evalled code
+        https://bugs.webkit.org/show_bug.cgi?id=107939
+
+        Reviewed by Vsevolod Vlasov.
+
+        Resolve map's sources URLs wrt script URL in case sourceMap is defined as data:.
+
+        * inspector/front-end/CompilerScriptMapping.js:
+        (WebInspector.CompilerScriptMapping.prototype.loadSourceMapForScript):
+        * inspector/front-end/ParsedURL.js:
+        (WebInspector.ParsedURL.completeURL):
+        * inspector/front-end/SourceMap.js:
+        (WebInspector.SourceMap.prototype._parseMap):
+
 2013-01-28  Andrey Adaikin  <[email protected]>
 
         Web Inspector: [Canvas] refactoring in CanvasAgent to reduce code dups

Modified: trunk/Source/WebCore/inspector/front-end/CompilerScriptMapping.js (140964 => 140965)


--- trunk/Source/WebCore/inspector/front-end/CompilerScriptMapping.js	2013-01-28 12:22:14 UTC (rev 140964)
+++ trunk/Source/WebCore/inspector/front-end/CompilerScriptMapping.js	2013-01-28 12:45:24 UTC (rev 140965)
@@ -94,6 +94,8 @@
     addScript: function(script)
     {
         var sourceMap = this.loadSourceMapForScript(script);
+        if (!sourceMap)
+            return;
 
         if (this._scriptForSourceMap.get(sourceMap)) {
             this._sourceMapForScriptId[script.scriptId] = sourceMap;
@@ -150,11 +152,21 @@
 
     /**
      * @param {WebInspector.Script} script
-     * @return {WebInspector.PositionBasedSourceMap}
+     * @return {?WebInspector.PositionBasedSourceMap}
      */
     loadSourceMapForScript: function(script)
     {
-        var sourceMapURL = WebInspector.PositionBasedSourceMap.prototype._canonicalizeURL(script.sourceMapURL, script.sourceURL);
+        // script.sourceURL can be a random string, but is generally an absolute path -> complete it to inspected page url for
+        // relative links.
+        if (!script.sourceMapURL)
+            return null;
+        var scriptURL = WebInspector.ParsedURL.completeURL(WebInspector.inspectedPageURL, script.sourceURL);
+        if (!scriptURL)
+            return null;
+        var sourceMapURL = WebInspector.ParsedURL.completeURL(scriptURL, script.sourceMapURL);
+        if (!sourceMapURL)
+            return null;
+
         var sourceMap = this._sourceMapForSourceMapURL[sourceMapURL];
         if (sourceMap)
             return sourceMap;
@@ -165,7 +177,8 @@
             if (response.slice(0, 3) === ")]}")
                 response = response.substring(response.indexOf('\n'));
             var payload = /** @type {SourceMapV3} */ (JSON.parse(response));
-            sourceMap = new WebInspector.PositionBasedSourceMap(sourceMapURL, payload);
+            var baseURL = sourceMapURL.startsWith("data:") ? scriptURL : sourceMapURL;
+            sourceMap = new WebInspector.PositionBasedSourceMap(baseURL, payload);
         } catch(e) {
             console.error(e.message);
             return null;

Modified: trunk/Source/WebCore/inspector/front-end/DebuggerScriptMapping.js (140964 => 140965)


--- trunk/Source/WebCore/inspector/front-end/DebuggerScriptMapping.js	2013-01-28 12:22:14 UTC (rev 140964)
+++ trunk/Source/WebCore/inspector/front-end/DebuggerScriptMapping.js	2013-01-28 12:45:24 UTC (rev 140965)
@@ -60,9 +60,7 @@
 
         this._resourceMapping.addScript(script);
 
-        if (WebInspector.settings.sourceMapsEnabled.get() && script.sourceMapURL) {
-            if (this._compilerMapping.loadSourceMapForScript(script))
-                this._compilerMapping.addScript(script);
-        }
+        if (WebInspector.settings.sourceMapsEnabled.get())
+            this._compilerMapping.addScript(script);
     }
 }

Modified: trunk/Source/WebCore/inspector/front-end/ParsedURL.js (140964 => 140965)


--- trunk/Source/WebCore/inspector/front-end/ParsedURL.js	2013-01-28 12:22:14 UTC (rev 140964)
+++ trunk/Source/WebCore/inspector/front-end/ParsedURL.js	2013-01-28 12:45:24 UTC (rev 140965)
@@ -108,6 +108,8 @@
 
     var parsedURL = baseURL.asParsedURL();
     if (parsedURL) {
+        if (parsedURL.isDataURL())
+            return href;
         var path = href;
         if (path.charAt(0) !== "/") {
             var basePath = parsedURL.path;

Modified: trunk/Source/WebCore/inspector/front-end/SourceMap.js (140964 => 140965)


--- trunk/Source/WebCore/inspector/front-end/SourceMap.js	2013-01-28 12:22:14 UTC (rev 140964)
+++ trunk/Source/WebCore/inspector/front-end/SourceMap.js	2013-01-28 12:45:24 UTC (rev 140965)
@@ -107,7 +107,8 @@
         var originalToCanonicalURLMap = {};
         for (var i = 0; i < map.sources.length; ++i) {
             var originalSourceURL = map.sources[i];
-            var url = "" ? map.sourceRoot + "/" : "") + originalSourceURL, this._sourceMappingURL);
+            var href = "" ? map.sourceRoot + "/" : "") + originalSourceURL;
+            var url = "" href) || href;
             originalToCanonicalURLMap[originalSourceURL] = url;
             sources.push(url);
             this._sources[url] = true;
@@ -182,25 +183,6 @@
         return negative ? -result : result;
     },
 
-    /**
-     * @param {string} url
-     * @param {string} baseURL
-     */
-    _canonicalizeURL: function(url, baseURL)
-    {
-        if (!url || !baseURL || url.asParsedURL() || url.substring(0, 5) === "data:")
-            return url;
-
-        var base = baseURL.asParsedURL();
-        if (!base)
-            return url;
-
-        var baseHost = base.scheme + "://" + base.host + (base.port ? ":" + base.port : "");
-        if (url[0] === "/")
-            return baseHost + url;
-        return baseHost + base.folderPathComponents + "/" + url;
-    },
-
     _VLQ_BASE_SHIFT: 5,
     _VLQ_BASE_MASK: (1 << 5) - 1,
     _VLQ_CONTINUATION_MASK: 1 << 5
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to