Title: [104808] trunk
Revision
104808
Author
podivi...@chromium.org
Date
2012-01-12 03:54:41 -0800 (Thu, 12 Jan 2012)

Log Message

Web Inspector: make source urls relative to source map url.
https://bugs.webkit.org/show_bug.cgi?id=75968

Reviewed by Yury Semikhatsky.

Source/WebCore:

* inspector/front-end/CompilerSourceMapping.js:
(WebInspector.ClosureCompilerSourceMapping):
(WebInspector.ClosureCompilerSourceMapping.prototype._parseMap):
(WebInspector.ClosureCompilerSourceMapping.prototype._canonicalizeURL):

LayoutTests:

* http/tests/inspector/compiler-source-mapping.html:
* http/tests/inspector/resources/source-map.json:

Modified Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (104807 => 104808)


--- trunk/LayoutTests/ChangeLog	2012-01-12 11:52:19 UTC (rev 104807)
+++ trunk/LayoutTests/ChangeLog	2012-01-12 11:54:41 UTC (rev 104808)
@@ -1,3 +1,13 @@
+2012-01-10  Pavel Podivilov  <podivi...@chromium.org>
+
+        Web Inspector: make source urls relative to source map url.
+        https://bugs.webkit.org/show_bug.cgi?id=75968
+
+        Reviewed by Yury Semikhatsky.
+
+        * http/tests/inspector/compiler-source-mapping.html:
+        * http/tests/inspector/resources/source-map.json:
+
 2012-01-12  Shinya Kawanaka  <shin...@google.com>
 
         ShadowContentElement should be able to use query.

Modified: trunk/LayoutTests/http/tests/inspector/compiler-source-mapping.html (104807 => 104808)


--- trunk/LayoutTests/http/tests/inspector/compiler-source-mapping.html	2012-01-12 11:52:19 UTC (rev 104807)
+++ trunk/LayoutTests/http/tests/inspector/compiler-source-mapping.html	2012-01-12 11:54:41 UTC (rev 104808)
@@ -119,7 +119,7 @@
 
         function testResolveSourceMappingURL(next)
         {
-            var func = WebInspector.ClosureCompilerSourceMapping.prototype._resolveSourceMapURL;
+            var func = WebInspector.ClosureCompilerSourceMapping.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"));

Modified: trunk/LayoutTests/http/tests/inspector/resources/source-map.json (104807 => 104808)


--- trunk/LayoutTests/http/tests/inspector/resources/source-map.json	2012-01-12 11:52:19 UTC (rev 104807)
+++ trunk/LayoutTests/http/tests/inspector/resources/source-map.json	2012-01-12 11:54:41 UTC (rev 104808)
@@ -1,7 +1,7 @@
 {
 "version":3,
 "file":"compiled.js",
-"sourceRoot": "http://localhost:8000/inspector/resources",
+"sourceRoot": "",
 "lineCount":2,
 "mappings":"AACAA,MAAAC,iBAAuB,CAAC,MAAD,CAAS,QAAQ,EACxC,CACI,IAAIC,EAASC,QAAAC,cAAsB,CAAC,QAAD,CACnCF,EAAAG,GAAA,CAAY,MACZH,EAAAD,iBAAuB,CAAC,OAAD,CAAUK,WAAV,CAAuB,CAAA,CAAvB,CACvBH,SAAAI,KAAAC,YAAyB,CAACN,CAAD,CAErBO,EAAAA,CAAMN,QAAAC,cAAsB,CAAC,KAAD,CAChCK,EAAAJ,GAAA,CAAS,ocACTF;QAAAI,KAAAC,YAAyB,CAACC,CAAD,CAR7B,CADuB,CAYvBH,SAASA,YAAW,CAACI,CAAD,CACpB,CAEIC,CAD8BC,IAAZC,YAClBF,QAAc,CAACD,CAAD,CAFlB,C,CCbAG,QAASA,aAAY,EACrB,EAGAA,YAAAC,UAAAH,OAAA,CAAgCI,QAAQ,EACxC,CACIC,OAAAC,IAAW,CAAC,iBAAD,CADf;",
 "sources":["source1.js","source2.js"],

Modified: trunk/Source/WebCore/ChangeLog (104807 => 104808)


--- trunk/Source/WebCore/ChangeLog	2012-01-12 11:52:19 UTC (rev 104807)
+++ trunk/Source/WebCore/ChangeLog	2012-01-12 11:54:41 UTC (rev 104808)
@@ -1,3 +1,15 @@
+2012-01-10  Pavel Podivilov  <podivi...@chromium.org>
+
+        Web Inspector: make source urls relative to source map url.
+        https://bugs.webkit.org/show_bug.cgi?id=75968
+
+        Reviewed by Yury Semikhatsky.
+
+        * inspector/front-end/CompilerSourceMapping.js:
+        (WebInspector.ClosureCompilerSourceMapping):
+        (WebInspector.ClosureCompilerSourceMapping.prototype._parseMap):
+        (WebInspector.ClosureCompilerSourceMapping.prototype._canonicalizeURL):
+
 2012-01-12  Nikolas Zimmermann  <nzimmerm...@rim.com>
 
         Not reviewed. Fix WebKit build after r104803, by setting ScriptCallStack.h role to private.

Modified: trunk/Source/WebCore/inspector/front-end/CompilerSourceMapping.js (104807 => 104808)


--- trunk/Source/WebCore/inspector/front-end/CompilerSourceMapping.js	2012-01-12 11:52:19 UTC (rev 104807)
+++ trunk/Source/WebCore/inspector/front-end/CompilerSourceMapping.js	2012-01-12 11:54:41 UTC (rev 104808)
@@ -83,7 +83,7 @@
             WebInspector.ClosureCompilerSourceMapping.prototype._base64Map[base64Digits.charAt(i)] = i;
     }
 
-    this._sourceMappingURL = this._resolveSourceMapURL(sourceMappingURL, scriptSourceOrigin);
+    this._sourceMappingURL = this._canonicalizeURL(sourceMappingURL, scriptSourceOrigin);
     this._mappings = [];
     this._reverseMappingsBySourceURL = {};
 }
@@ -197,7 +197,10 @@
 
         var sources = [];
         for (var i = 0; i < map.sources.length; ++i) {
-            var url = "" map.sources[i]);
+            var sourceURL = map.sources[i];
+            if (map.sourceRoot)
+                sourceURL = map.sourceRoot + "/" + sourceURL;
+            var url = "" this._sourceMappingURL);
             sources.push(url);
             if (!this._reverseMappingsBySourceURL[url])
                 this._reverseMappingsBySourceURL[url] = [];
@@ -262,24 +265,19 @@
         return negative ? -result : result;
     },
 
-    _canonicalizeURL: function(sourceRoot, sourceURL)
+    _canonicalizeURL: function(url, baseURL)
     {
-        return sourceRoot ? sourceRoot + "/" + sourceURL : sourceURL;
-    },
+        if (!url || !baseURL || url.asParsedURL())
+            return url;
 
-    _resolveSourceMapURL: function(sourceMappingURL, scriptSourceOrigin)
-    {
-        if (!sourceMappingURL || !scriptSourceOrigin)
-            return sourceMappingURL;
+        var base = baseURL.asParsedURL();
+        if (!base)
+            return url;
 
-        if (sourceMappingURL.asParsedURL())
-            return sourceMappingURL;
-
-        var origin = scriptSourceOrigin.asParsedURL();
-        var baseURL = origin.scheme + "://" + origin.host + (origin.port ? ":" + origin.port : "");
-        if (sourceMappingURL[0] === "/")
-            return baseURL + sourceMappingURL;
-        return baseURL + origin.firstPathComponents + sourceMappingURL;
+        var baseHost = base.scheme + "://" + base.host + (base.port ? ":" + base.port : "");
+        if (url[0] === "/")
+            return baseHost + url;
+        return baseHost + base.firstPathComponents + url;
     },
 
     _VLQ_BASE_SHIFT: 5,
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to