Web Inspector: load source maps via front-end host.
authorpodivilov@chromium.org <podivilov@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 10 Nov 2011 09:19:35 +0000 (09:19 +0000)
committerpodivilov@chromium.org <podivilov@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 10 Nov 2011 09:19:35 +0000 (09:19 +0000)
https://bugs.webkit.org/show_bug.cgi?id=71301

Reviewed by Yury Semikhatsky.

Source/WebCore:

Currently we use an auxiliary iframe hack to load source map files from inspector page. This approach has several drawbacks:
 - in addition to source map url we need to know auxiliary iframe url
 - we need a protocol to communicate with iframe
 - source map provider needs to provide auxiliary document to make our hack work
Loading source maps from front-end host solves all problems.

* WebCore.gypi:
* WebCore.vcproj/WebCore.vcproj:
* inspector/InspectorFrontendHost.cpp:
(WebCore::InspectorFrontendHost::loadResourceSynchronously):
* inspector/InspectorFrontendHost.h:
* inspector/InspectorFrontendHost.idl:
* inspector/front-end/CompilerSourceMapping.js:
(WebInspector.ClosureCompilerSourceMapping):
(WebInspector.ClosureCompilerSourceMapping.prototype.load):
(WebInspector.ClosureCompilerSourceMapping.prototype.loadSourceCode):
(WebInspector.ClosureCompilerSourceMapping.prototype._parseMappingPayload):
* inspector/front-end/CompilerSourceMappingProvider.js: Removed.
* inspector/front-end/ContentProviders.js:
(WebInspector.CompilerSourceMappingContentProvider):
(WebInspector.CompilerSourceMappingContentProvider.prototype.requestContent):
* inspector/front-end/RawSourceCode.js:
(WebInspector.RawSourceCode.prototype.setCompilerSourceMapping):
(WebInspector.RawSourceCode.prototype._resourceFinished):
(WebInspector.RawSourceCode.prototype._createSourceMapping.didLoadSourceMapping):
* inspector/front-end/WebKit.qrc:
* inspector/front-end/inspector.html:
* inspector/front-end/inspector.js:
(WebInspector.installSourceMappingForTest):

LayoutTests:

* http/tests/inspector/compiler-source-mapping-provider-expected.txt: Removed.
* http/tests/inspector/compiler-source-mapping-provider.html: Removed.
* http/tests/inspector/resources/compiler-source-mapping-provider/app-map.html: Removed.
* http/tests/inspector/resources/source-map.json: Renamed from LayoutTests/http/tests/inspector/resources/compiler-source-mapping-provider/app-map.
* http/tests/inspector/resources/source1.js: Renamed from LayoutTests/http/tests/inspector/resources/compiler-source-mapping-provider/app.js.
(window.onload):
(handleClick):
* http/tests/inspector/resources/source2.js: Renamed from LayoutTests/http/tests/inspector/resources/compiler-source-mapping-provider/foo.js.
(ClickHandler):
(ClickHandler.prototype.handle):
* inspector/debugger/compiler-source-mapping.html: Removed.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@99823 268f45cc-cd09-0410-ab3c-d52691b4dbfc

24 files changed:
LayoutTests/ChangeLog
LayoutTests/http/tests/inspector/compiler-source-mapping-provider-expected.txt [deleted file]
LayoutTests/http/tests/inspector/compiler-source-mapping-provider.html [deleted file]
LayoutTests/http/tests/inspector/resources/compiler-source-mapping-provider/app-map.html [deleted file]
LayoutTests/http/tests/inspector/resources/source-map.json [moved from LayoutTests/http/tests/inspector/resources/compiler-source-mapping-provider/app-map with 94% similarity]
LayoutTests/http/tests/inspector/resources/source1.js [moved from LayoutTests/http/tests/inspector/resources/compiler-source-mapping-provider/app.js with 100% similarity]
LayoutTests/http/tests/inspector/resources/source2.js [moved from LayoutTests/http/tests/inspector/resources/compiler-source-mapping-provider/foo.js with 100% similarity]
LayoutTests/inspector/debugger/compiler-source-mapping.html [deleted file]
LayoutTests/inspector/debugger/raw-source-code.html
Source/WebCore/ChangeLog
Source/WebCore/WebCore.gypi
Source/WebCore/WebCore.vcproj/WebCore.vcproj
Source/WebCore/inspector/InspectorFrontendHost.cpp
Source/WebCore/inspector/InspectorFrontendHost.h
Source/WebCore/inspector/InspectorFrontendHost.idl
Source/WebCore/inspector/compile-front-end.sh
Source/WebCore/inspector/front-end/CompilerSourceMapping.js
Source/WebCore/inspector/front-end/CompilerSourceMappingProvider.js [deleted file]
Source/WebCore/inspector/front-end/ContentProviders.js
Source/WebCore/inspector/front-end/InspectorFrontendHostStub.js
Source/WebCore/inspector/front-end/RawSourceCode.js
Source/WebCore/inspector/front-end/WebKit.qrc
Source/WebCore/inspector/front-end/inspector.html
Source/WebCore/inspector/front-end/inspector.js

index 86039c9..e3a3ccf 100644 (file)
@@ -1,3 +1,22 @@
+2011-11-01  Pavel Podivilov  <podivilov@chromium.org>
+
+        Web Inspector: load source maps via front-end host.
+        https://bugs.webkit.org/show_bug.cgi?id=71301
+
+        Reviewed by Yury Semikhatsky.
+
+        * http/tests/inspector/compiler-source-mapping-provider-expected.txt: Removed.
+        * http/tests/inspector/compiler-source-mapping-provider.html: Removed.
+        * http/tests/inspector/resources/compiler-source-mapping-provider/app-map.html: Removed.
+        * http/tests/inspector/resources/source-map.json: Renamed from LayoutTests/http/tests/inspector/resources/compiler-source-mapping-provider/app-map.
+        * http/tests/inspector/resources/source1.js: Renamed from LayoutTests/http/tests/inspector/resources/compiler-source-mapping-provider/app.js.
+        (window.onload):
+        (handleClick):
+        * http/tests/inspector/resources/source2.js: Renamed from LayoutTests/http/tests/inspector/resources/compiler-source-mapping-provider/foo.js.
+        (ClickHandler):
+        (ClickHandler.prototype.handle):
+        * inspector/debugger/compiler-source-mapping.html: Removed.
+
 2011-11-10  Yuta Kitamura  <yutak@chromium.org>
 
         [Chromium] Unreviewed, rebaseline SVG test results changed after r99539. (part 2)
diff --git a/LayoutTests/http/tests/inspector/compiler-source-mapping-provider-expected.txt b/LayoutTests/http/tests/inspector/compiler-source-mapping-provider-expected.txt
deleted file mode 100644 (file)
index 6b47168..0000000
+++ /dev/null
@@ -1,8 +0,0 @@
-Tests CompilerSourceMappingProvider class.
-
-
-Running: testLoad
-
-Running: testTimeout
-log: Request timed out.
-
diff --git a/LayoutTests/http/tests/inspector/compiler-source-mapping-provider.html b/LayoutTests/http/tests/inspector/compiler-source-mapping-provider.html
deleted file mode 100644 (file)
index 9486985..0000000
+++ /dev/null
@@ -1,58 +0,0 @@
-<html>
-<head>
-<script src="inspector-test.js"></script>
-
-<script>
-
-function test()
-{
-    InspectorTest.runTestSuite([
-        function testLoad(next)
-        {
-            var provider = new WebInspector.CompilerSourceMappingProvider("http://localhost:8000/inspector/resources/compiler-source-mapping-provider/app-map.html?sourceMap=app-map");
-            var sourceMapping;
-            provider.loadSourceMapping(didLoadSourceMapping);
-            function didLoadSourceMapping(sourceMappingArg)
-            {
-                sourceMapping = sourceMappingArg;
-                var sources = sourceMapping.sources();
-                InspectorTest.assertEquals(2, sources.length);
-                InspectorTest.assertEquals("app.js", sources[0]);
-                InspectorTest.assertEquals("foo.js", sources[1]);
-                provider.loadSourceCode(sourceMapping.sources()[0], didLoadSourceCode);
-            }
-
-            function didLoadSourceCode(content)
-            {
-                InspectorTest.assertEquals(0, content.indexOf("window.onload = function()"));
-                provider.loadSourceCode(sourceMapping.sources()[1], didLoadSourceCode2);
-            }
-
-            function didLoadSourceCode2(content)
-            {
-                InspectorTest.assertEquals(0, content.indexOf("function ClickHandler()"));
-                next();
-            }
-        },
-
-        function testTimeout(next)
-        {
-            var provider = new WebInspector.CompilerSourceMappingProvider("http://localhost:8000/does-not-exist");
-            provider.loadSourceMapping(didLoadSourceMapping);
-            function didLoadSourceMapping(sourceMapping)
-            {
-                InspectorTest.assertEquals(null, sourceMapping);
-                next();
-            }
-        }
-    ]);
-};
-
-</script>
-
-</head>
-
-<body onload="runTest()">
-<p>Tests CompilerSourceMappingProvider class.</p>
-</body>
-</html>
diff --git a/LayoutTests/http/tests/inspector/resources/compiler-source-mapping-provider/app-map.html b/LayoutTests/http/tests/inspector/resources/compiler-source-mapping-provider/app-map.html
deleted file mode 100644 (file)
index 3b8ddbd..0000000
+++ /dev/null
@@ -1,44 +0,0 @@
-<script>
-window.addEventListener("message", handleMessage, false);
-
-function handleMessage(event)
-{
-    var requestId = event.data.id;
-    var method = event.data.method;
-    if (method === "loadSourceMap") {
-        var queryParameters = parseQueryString(window.location.toString());
-        sendRequest(event, queryParameters.sourceMap);
-    } else if (method === "loadSourceCode") {
-        var sourceCodeURL = event.data.params[0];
-        sendRequest(event, sourceCodeURL);
-    }
-}
-
-function sendRequest(event, url)
-{
-    var request = new XMLHttpRequest();
-    request.open("GET", url, true);
-    request.onreadystatechange = function()
-    {
-        if (request.readyState !== 4)
-            return;
-        if (request.status === 200)
-            event.source.postMessage({ id: event.data.id, result: request.responseText }, event.origin);
-        else
-            event.source.postMessage({ id: event.data.id, error: request.statusText }, event.origin);
-    }
-    request.send();
-}
-
-function parseQueryString(url)
-{
-    var query = url.split("?")[1];
-    var parameters = query.split("&");
-    var result = {};
-    for (var i = 0; i < parameters.length; ++i) {
-        var parameter = parameters[i].split("=");
-        result[parameter[0]] = parameter[1];
-    }
-    return result;
-}
-</script>
@@ -1,8 +1,7 @@
 {
 "version":3,
-"file":"./app-map",
 "lineCount":2,
 "mappings":"AACAA,MAAAC,OAAA,CAAwBC,QAAA,EACxB,CACI,IAAIC,EAAMC,QAAAC,cAAsB,CAAC,KAAD,CAChCF,EAAAG,YAAA,CAAkB,KAClBH,EAAAI,iBAAoB,CAAC,OAAD,CAAUC,WAAV,CAAuB,CAAA,CAAvB,CACpBJ,SAAAK,KAAAC,YAAyB,CAACP,CAAD,CAErBQ,EAAAA,CAAMP,QAAAC,cAAsB,CAAC,KAAD,CAChCM,EAAAL,YAAA,CAAkB,ocAClBF;QAAAK,KAAAC,YAAyB,CAACC,CAAD,CAR7B,CAWSH,SAAAA,YAAW,CAACI,CAAD,CACpB,CAEIC,CAD8BC,IAAZC,YAClBF,QAAc,CAACD,CAAD,CAFlB,CCbSG,QAAAA,aAAY,EACrB,EAGAA,YAAAC,UAAAH,OAAA,CAAwCI,QAAA,CAACL,CAAD,CACxC,CACI,IAAIM,EAAUd,QAAAC,cAAsB,CAAC,KAAD,CACpCa,EAAAZ,YAAA,CAAsBM,CAAAO,UACtBf,SAAAK,KAAAC,YAAyB,CAACQ,CAAD,CAH7B;",
-"sources":["app.js","foo.js"],
+"sources":["source1.js","source2.js"],
 "names":["window","onload","window.onload","foo","document","createElement","textContent","addEventListener","handleClick","body","appendChild","bar","event","handle","handler","ClickHandler","prototype","ClickHandler.prototype.handle","element","timeStamp"]
 }
diff --git a/LayoutTests/inspector/debugger/compiler-source-mapping.html b/LayoutTests/inspector/debugger/compiler-source-mapping.html
deleted file mode 100644 (file)
index 50777e4..0000000
+++ /dev/null
@@ -1,99 +0,0 @@
-<html>
-<head>
-<script src="../../http/tests/inspector/inspector-test.js"></script>
-
-<script>
-
-function test()
-{
-    function checkMapping(compiledLineNumber, compiledColumnNumber, sourceURL, sourceLineNumber, sourceColumnNumber, mapping)
-    {
-        var sourceLocation = mapping.compiledLocationToSourceLocation(compiledLineNumber, compiledColumnNumber);
-        InspectorTest.assertEquals(sourceURL, sourceLocation.sourceURL);
-        InspectorTest.assertEquals(sourceLineNumber, sourceLocation.lineNumber);
-        InspectorTest.assertEquals(sourceColumnNumber, sourceLocation.columnNumber);
-    }
-
-    function checkReverseMapping(compiledLineNumber, compiledColumnNumber, sourceURL, sourceLineNumber, mapping)
-    {
-        var compiledLocation = mapping.sourceLocationToCompiledLocation(sourceURL, sourceLineNumber);
-        InspectorTest.assertEquals(compiledLineNumber, compiledLocation.lineNumber);
-        InspectorTest.assertEquals(compiledColumnNumber, compiledLocation.columnNumber);
-    }
-
-    InspectorTest.runTestSuite([
-        function testSimpleMapping(next)
-        {
-            /*
-                example.js:
-                0         1         2         3
-                012345678901234567890123456789012345
-                function add(variable_x, variable_y)
-                {
-                    return variable_x + variable_y;
-                }
-
-                var global = "foo";
-                ----------------------------------------
-                example-compiled.js:
-                0         1         2         3
-                012345678901234567890123456789012345
-                function add(a,b){return a+b}var global="foo";
-            */
-            var mappingPayload = {
-                "mappings":"AAASA,QAAAA,IAAG,CAACC,CAAD,CAAaC,CAAb,CACZ,CACI,MAAOD,EAAP,CAAoBC,CADxB,CAIA,IAAIC,OAAS;",
-                "sources":["example.js"]
-            };
-            var mapping = new WebInspector.ClosureCompilerSourceMapping(mappingPayload);
-
-            checkMapping(0, 9, "example.js", 0, 9, mapping);
-            checkMapping(0, 13, "example.js", 0, 13, mapping);
-            checkMapping(0, 15, "example.js", 0, 25, mapping);
-            checkMapping(0, 18, "example.js", 2, 4, mapping);
-            checkMapping(0, 25, "example.js", 2, 11, mapping);
-            checkMapping(0, 27, "example.js", 2, 24, mapping);
-
-            checkReverseMapping(0, 0, "example.js", 0, mapping);
-            checkReverseMapping(0, 17, "example.js", 1, mapping);
-            checkReverseMapping(0, 18, "example.js", 2, mapping);
-            checkReverseMapping(0, 29, "example.js", 4, mapping);
-            checkReverseMapping(0, 29, "example.js", 5, mapping);
-            InspectorTest.assertTrue(!mapping.sourceLocationToCompiledLocation("example.js", 6));
-
-            next();
-        },
-
-        function testNoMappingEntry(next)
-        {
-            var mappingPayload = {
-                "mappings":"AAAA,C,CAAE;",
-                "sources":["example.js"]
-            };
-            var mapping = new WebInspector.ClosureCompilerSourceMapping(mappingPayload);
-            checkMapping(0, 0, "example.js", 0, 0, mapping);
-            checkMapping(0, 2, "example.js", 0, 2, mapping);
-            next();
-        },
-
-        function testEmptyLine(next)
-        {
-            var mappingPayload = {
-                "mappings":"AAAA;;;CACA",
-                "sources":["example.js"]
-            };
-            var mapping = new WebInspector.ClosureCompilerSourceMapping(mappingPayload);
-            checkMapping(0, 0, "example.js", 0, 0, mapping);
-            checkReverseMapping(3, 1, "example.js", 1, mapping);
-            next();
-        }
-    ]);
-};
-
-</script>
-
-</head>
-
-<body onload="runTest()">
-<p>Tests ClosureCompilerSourceMapping.</p>
-</body>
-</html>
index 5673a0c..4f2138d 100644 (file)
@@ -339,31 +339,23 @@ function test()
 
         function testCompilerSourceMapping(next)
         {
-            function createCompilerSourceMappingMock()
-            {
-                return {
-                    compiledLocationToSourceLocation: function(lineNumber, columnNumber)
-                    {
-                        if (lineNumber < 10)
-                            return { sourceURL: "source1.js", lineNumber: lineNumber * 2, columnNumber: columnNumber * 2 };
-                        return { sourceURL: "source2.js", lineNumber: (lineNumber - 10) * 2, columnNumber: columnNumber * 2 };
-                    },
-                    sourceLocationToCompiledLocation: function(sourceURL, lineNumber)
-                    {
-                        if (sourceURL === "source1.js")
-                            return { lineNumber: Math.floor(lineNumber / 2), columnNumber: 0 };
-                        return { lineNumber: Math.floor(lineNumber / 2) + 10, columnNumber: 0 };
-                    },
-                    sources: function() { return ["source1.js", "source2.js"]; }
-                };
-            }
-            function createCompilerSourceMappingProviderMock()
-            {
-                return {
-                    loadSourceMapping: function(callback) { callback(createCompilerSourceMappingMock()); },
-                    loadSourceCode: function(url, callback) { callback("<content of " + url + ">"); }
-                }
-            }
+            var compilerSourceMappingMock = {
+                compiledLocationToSourceLocation: function(lineNumber, columnNumber)
+                {
+                    if (lineNumber < 10)
+                        return { sourceURL: "source1.js", lineNumber: lineNumber * 2, columnNumber: columnNumber * 2 };
+                    return { sourceURL: "source2.js", lineNumber: (lineNumber - 10) * 2, columnNumber: columnNumber * 2 };
+                },
+                sourceLocationToCompiledLocation: function(sourceURL, lineNumber)
+                {
+                    if (sourceURL === "source1.js")
+                        return { lineNumber: Math.floor(lineNumber / 2), columnNumber: 0 };
+                    return { lineNumber: Math.floor(lineNumber / 2) + 10, columnNumber: 0 };
+                },
+                sources: function() { return ["source1.js", "source2.js"]; },
+                load: function() { return true; },
+                loadSourceCode: function(url) { return "<content of " + url + ">"; }
+            };
 
             var script = createScriptMock("compiled.js", 0, 0, true, "<script source>");
             var resource = createPendingResourceMock("script", "<resource content>");
@@ -371,7 +363,7 @@ function test()
             var uiSourceCodeList;
 
             waitForSourceMappingEvent(rawSourceCode, checkMapping);
-            rawSourceCode.setCompilerSourceMappingProvider(createCompilerSourceMappingProviderMock());
+            rawSourceCode.setCompilerSourceMapping(compilerSourceMappingMock);
             function checkMapping()
             {
                 var sourceMapping = rawSourceCode.sourceMapping;
@@ -404,14 +396,14 @@ function test()
 
         function testCompilerSourceMappingCouldNotBeLoaded(next)
         {
-            var compilerSourceMappingProviderMock = { loadSourceMapping: function(callback) { callback(null); } };
+            var compilerSourceMappingMock = { load: function() { return false; } };
 
             var script = createScriptMock("compiled.js", 0, 0, true, "<script source>");
             var rawSourceCode = createRawSourceCode(script, null);
             var uiSourceCodeList;
 
             waitForSourceMappingEvent(rawSourceCode, checkMapping);
-            rawSourceCode.setCompilerSourceMappingProvider(compilerSourceMappingProviderMock);
+            rawSourceCode.setCompilerSourceMapping(compilerSourceMappingMock);
 
             function checkMapping()
             {
index ee52a56..a57bcd7 100755 (executable)
@@ -1,3 +1,40 @@
+2011-11-01  Pavel Podivilov  <podivilov@chromium.org>
+
+        Web Inspector: load source maps via front-end host.
+        https://bugs.webkit.org/show_bug.cgi?id=71301
+
+        Reviewed by Yury Semikhatsky.
+
+        Currently we use an auxiliary iframe hack to load source map files from inspector page. This approach has several drawbacks:
+         - in addition to source map url we need to know auxiliary iframe url
+         - we need a protocol to communicate with iframe
+         - source map provider needs to provide auxiliary document to make our hack work
+        Loading source maps from front-end host solves all problems.
+
+        * WebCore.gypi:
+        * WebCore.vcproj/WebCore.vcproj:
+        * inspector/InspectorFrontendHost.cpp:
+        (WebCore::InspectorFrontendHost::loadResourceSynchronously):
+        * inspector/InspectorFrontendHost.h:
+        * inspector/InspectorFrontendHost.idl:
+        * inspector/front-end/CompilerSourceMapping.js:
+        (WebInspector.ClosureCompilerSourceMapping):
+        (WebInspector.ClosureCompilerSourceMapping.prototype.load):
+        (WebInspector.ClosureCompilerSourceMapping.prototype.loadSourceCode):
+        (WebInspector.ClosureCompilerSourceMapping.prototype._parseMappingPayload):
+        * inspector/front-end/CompilerSourceMappingProvider.js: Removed.
+        * inspector/front-end/ContentProviders.js:
+        (WebInspector.CompilerSourceMappingContentProvider):
+        (WebInspector.CompilerSourceMappingContentProvider.prototype.requestContent):
+        * inspector/front-end/RawSourceCode.js:
+        (WebInspector.RawSourceCode.prototype.setCompilerSourceMapping):
+        (WebInspector.RawSourceCode.prototype._resourceFinished):
+        (WebInspector.RawSourceCode.prototype._createSourceMapping.didLoadSourceMapping):
+        * inspector/front-end/WebKit.qrc:
+        * inspector/front-end/inspector.html:
+        * inspector/front-end/inspector.js:
+        (WebInspector.installSourceMappingForTest):
+
 2011-11-10  Sheriff Bot  <webkit.review.bot@gmail.com>
 
         Unreviewed, rolling out r99816.
index f6a8636..3bbc1b5 100644 (file)
             'inspector/front-end/Checkbox.js',
             'inspector/front-end/Color.js',
             'inspector/front-end/CompilerSourceMapping.js',
-            'inspector/front-end/CompilerSourceMappingProvider.js',
             'inspector/front-end/ConsoleMessage.js',
             'inspector/front-end/ConsoleModel.js',
             'inspector/front-end/ConsolePanel.js',
index addfa24..30c4814 100755 (executable)
                                        >
                                </File>
                                <File
-                                       RelativePath="..\inspector\front-end\CompilerSourceMappingProvider.js"
-                                       >
-                               </File>
-                               <File
                                        RelativePath="..\inspector\front-end\ConsoleMessage.js"
                                        >
                                </File>
index d2a7033..9f49b4d 100644 (file)
@@ -251,6 +251,18 @@ void InspectorFrontendHost::showContextMenu(Event* event, const Vector<ContextMe
 }
 #endif
 
+String InspectorFrontendHost::loadResourceSynchronously(const String& url)
+{
+    ResourceRequest request(url);
+    request.setHTTPMethod("GET");
+
+    Vector<char> data;
+    ResourceError error;
+    ResourceResponse response;
+    m_frontendPage->mainFrame()->loader()->loadResourceSynchronously(request, DoNotAllowStoredCredentials, error, response, data);
+    return String(data.data(), data.size());
+}
+
 } // namespace WebCore
 
 #endif // ENABLE(INSPECTOR)
index decfe9a..97b558c 100644 (file)
@@ -79,6 +79,8 @@ public:
     void showContextMenu(Event*, const Vector<ContextMenuItem*>& items);
     void sendMessageToBackend(const String& message);
 
+    String loadResourceSynchronously(const String& url);
+
 private:
 #if ENABLE(CONTEXT_MENUS)
     friend class FrontendMenuProvider;
index cbb0bac..db9436b 100644 (file)
@@ -60,5 +60,7 @@ module core {
         [Custom] void recordActionTaken(in unsigned long actionCode);
         [Custom] void recordPanelShown(in unsigned long panelCode);
         [Custom] void recordSettingChanged(in unsigned long settingChanged);
+        
+        DOMString loadResourceSynchronously(in DOMString url);
     };
 }
index 1e1d7e2..33369eb 100755 (executable)
@@ -45,10 +45,9 @@ java -jar ~/closure/compiler.jar --summary_detail_level 3 --compilation_level SI
         --js Source/WebCore/inspector/front-end/UserMetrics.js \
         --js Source/WebCore/inspector/front-end/HandlerRegistry.js \
         --js Source/WebCore/inspector/front-end/InspectorFrontendHostStub.js \
-    --module jsmodule_sdk:26:jsmodule_common \
+    --module jsmodule_sdk:25:jsmodule_common \
         --js Source/WebCore/inspector/front-end/ApplicationCacheModel.js \
         --js Source/WebCore/inspector/front-end/CompilerSourceMapping.js \
-        --js Source/WebCore/inspector/front-end/CompilerSourceMappingProvider.js \
         --js Source/WebCore/inspector/front-end/ConsoleModel.js \
         --js Source/WebCore/inspector/front-end/ContentProviders.js \
         --js Source/WebCore/inspector/front-end/CookieParser.js \
index 74cd16b..8e252b4 100644 (file)
@@ -70,9 +70,9 @@ WebInspector.ClosureCompilerSourceMappingPayload = function()
  * for format description.
  * @implements {WebInspector.CompilerSourceMapping}
  * @constructor
- * @param {WebInspector.ClosureCompilerSourceMappingPayload} mappingPayload
+ * @param {string} sourceMappingURL
  */
-WebInspector.ClosureCompilerSourceMapping = function(mappingPayload)
+WebInspector.ClosureCompilerSourceMapping = function(sourceMappingURL)
 {
     if (!WebInspector.ClosureCompilerSourceMapping.prototype._base64Map) {
         const base64Digits = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
@@ -81,16 +81,27 @@ WebInspector.ClosureCompilerSourceMapping = function(mappingPayload)
             WebInspector.ClosureCompilerSourceMapping.prototype._base64Map[base64Digits.charAt(i)] = i;
     }
 
-    this._sources = mappingPayload.sources;
-    this._mappings = [];
-    this._reverseMappingsBySourceURL = {};
-    for (var i = 0; i < this._sources.length; ++i)
-        this._reverseMappingsBySourceURL[this._sources[i]] = [];
-    this._parseMappings(mappingPayload);
+    this._sourceMappingURL = sourceMappingURL;
 }
 
 WebInspector.ClosureCompilerSourceMapping.prototype = {
     /**
+     * @return {boolean}
+     */
+    load: function()
+    {
+        try {
+            // FIXME: make sendRequest async.
+            var response = InspectorFrontendHost.loadResourceSynchronously(this._sourceMappingURL);
+            this._parseMappingPayload(JSON.parse(response));
+            return true
+        } catch(e) {
+            console.error(e.message);
+            return false;
+        }
+    },
+
+    /**
      * @param {number} lineNumber
      * @param {number} columnNumber
      * @return {Object}
@@ -119,6 +130,24 @@ WebInspector.ClosureCompilerSourceMapping.prototype = {
         return this._sources;
     },
 
+    /**
+     * @param {string} sourceURL
+     * @return {string}
+     */
+    loadSourceCode: function(sourceURL)
+    {
+        try {
+            var rootURL = this._sourceMappingURL.substring(0, this._sourceMappingURL.lastIndexOf("/") + 1);
+            if (this._sourceRoot)
+                rootURL += this._sourceRoot + "/";
+            // FIXME: make sendRequest async.
+            return InspectorFrontendHost.loadResourceSynchronously(rootURL + sourceURL);
+        } catch(e) {
+            console.error(e.message);
+            return "";
+        }
+    },
+
     _findMapping: function(lineNumber, columnNumber)
     {
         var first = 0;
@@ -137,8 +166,16 @@ WebInspector.ClosureCompilerSourceMapping.prototype = {
         return this._mappings[first];
     },
 
-    _parseMappings: function(mappingPayload)
+    _parseMappingPayload: function(mappingPayload)
     {
+        this._sourceRoot = mappingPayload.sourceRoot;
+        this._sources = mappingPayload.sources;
+
+        this._mappings = [];
+        this._reverseMappingsBySourceURL = {};
+        for (var i = 0; i < this._sources.length; ++i)
+            this._reverseMappingsBySourceURL[this._sources[i]] = [];
+
         var stringCharIterator = new WebInspector.ClosureCompilerSourceMapping.StringCharIterator(mappingPayload.mappings);
 
         var lineNumber = 0;
diff --git a/Source/WebCore/inspector/front-end/CompilerSourceMappingProvider.js b/Source/WebCore/inspector/front-end/CompilerSourceMappingProvider.js
deleted file mode 100644 (file)
index 9b77002..0000000
+++ /dev/null
@@ -1,130 +0,0 @@
-/*
- * Copyright (C) 2011 Google Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are
- * met:
- *
- *     * Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- *     * Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following disclaimer
- * in the documentation and/or other materials provided with the
- * distribution.
- *     * Neither the name of Google Inc. nor the names of its
- * contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-/**
- * @constructor
- * @param {string} sourceMappingPageURL
- */
-WebInspector.CompilerSourceMappingProvider = function(sourceMappingPageURL)
-{
-    if (!this._initialized) {
-        window.addEventListener("message", this._onMessage, true);
-        WebInspector.CompilerSourceMappingProvider.prototype._initialized = true;
-    }
-    this._sourceMappingPageURL = sourceMappingPageURL;
-}
-
-WebInspector.CompilerSourceMappingProvider.prototype = {
-    /**
-     * @param {function(WebInspector.CompilerSourceMapping)} callback
-     */
-    loadSourceMapping: function(callback)
-    {
-        this._frame = document.createElement("iframe");
-        this._frame.src = this._sourceMappingPageURL;
-        function frameLoaded()
-        {
-            function didLoadData(error, result)
-            {
-                if (error) {
-                    console.log(error);
-                    callback(null);
-                    return;
-                }
-
-                var payload;
-                try {
-                    payload = JSON.parse(result);
-                } catch (e) {
-                    console.log("Failed to parse JSON.");
-                }
-
-                if (payload)
-                    callback(new WebInspector.ClosureCompilerSourceMapping(payload));
-                else
-                    callback(null);
-            }
-            this._sendRequest("loadSourceMap", [], didLoadData);
-        }
-        this._frame.addEventListener("load", frameLoaded.bind(this), true);
-        // FIXME: remove iframe from the document when it is not needed anymore.
-        document.body.appendChild(this._frame);
-    },
-
-    /**
-     * @param {string} sourceURL
-     * @param {function(string)} callback
-     * @param {number} timeout
-     */
-    loadSourceCode: function(sourceURL, callback, timeout)
-    {
-        function didSendRequest(error, result)
-        {
-            if (error) {
-                console.log(error);
-                callback("");
-                return;
-            }
-            callback(result);
-        }
-        this._sendRequest("loadSourceCode", [sourceURL], didSendRequest, timeout);
-    },
-
-    _sendRequest: function(method, parameters, callback, timeout)
-    {
-        var requestId = this._requestId++;
-        var timerId = setTimeout(this._cancelRequest.bind(this, requestId), timeout || 5000);
-        this._requests[requestId] = { callback: callback, timerId: timerId };
-        var requestData = { id: requestId, method: method, params: parameters };
-        this._frame.contentWindow.postMessage(requestData, this._sourceMappingPageURL);
-    },
-
-    _onMessage: function(event)
-    {
-        var requestId = event.data.id;
-        var requests = WebInspector.CompilerSourceMappingProvider.prototype._requests;
-        var request = requests[requestId];
-        if (!request)
-            return;
-        delete requests[requestId];
-        clearTimeout(request.timerId);
-        request.callback(event.data.error, event.data.result);
-    },
-
-    _cancelRequest: function(requestId)
-    {
-        var request = this._requests[requestId];
-        delete this._requests[requestId];
-        request.callback("Request timed out.", null);
-    },
-
-    _requestId: 0,
-    _requests: {}
-}
index 011b903..8ef622d 100644 (file)
@@ -243,11 +243,11 @@ WebInspector.ResourceContentProvider.prototype.__proto__ = WebInspector.ContentP
  * @constructor
  * @implements {WebInspector.ContentProvider}
  */
-WebInspector.CompilerSourceMappingContentProvider = function(sourceURL, compilerSourceMappingProvider)
+WebInspector.CompilerSourceMappingContentProvider = function(sourceURL, compilerSourceMapping)
 {
     this._mimeType = "text/javascript";
     this._sourceURL = sourceURL;
-    this._compilerSourceMappingProvider = compilerSourceMappingProvider;
+    this._compilerSourceMapping = compilerSourceMapping;
 };
 
 WebInspector.CompilerSourceMappingContentProvider.prototype = {
@@ -256,11 +256,8 @@ WebInspector.CompilerSourceMappingContentProvider.prototype = {
      */
     requestContent: function(callback)
     {
-        function didLoadSourceCode(sourceCode)
-        {
-            callback(this._mimeType, sourceCode);
-        }
-        this._compilerSourceMappingProvider.loadSourceCode(this._sourceURL, didLoadSourceCode.bind(this));
+        var sourceCode = this._compilerSourceMapping.loadSourceCode(this._sourceURL);
+        callback(this._mimeType, sourceCode);
     },
 
     /**
index 0ee4b7b..4f97abb 100644 (file)
@@ -149,6 +149,11 @@ WebInspector.InspectorFrontendHostStub.prototype = {
 
     recordSettingChanged: function(settingCode)
     {
+    },
+
+    loadResourceSynchronously: function(url)
+    {
+        return "";
     }
 }
 
index 02e5df0..1a06ae7 100644 (file)
@@ -93,19 +93,19 @@ WebInspector.RawSourceCode.prototype = {
     },
 
     /**
-     * @param {number} provider Should assign proper type upon first use
+     * @param {WebInspector.CompilerSourceMapping} compilerSourceMapping
      */
-    setCompilerSourceMappingProvider: function(provider)
+    setCompilerSourceMapping: function(compilerSourceMapping)
     {
-        if (provider)
+        if (compilerSourceMapping)
             this._useTemporaryContent = false;
-        this._compilerSourceMappingProvider = provider;
+        this._compilerSourceMapping = compilerSourceMapping;
         this._updateSourceMapping();
     },
 
     _resourceFinished: function()
     {
-        if (this._compilerSourceMappingProvider)
+        if (this._compilerSourceMapping)
             return;
         this._useTemporaryContent = false;
         this._updateSourceMapping();
@@ -182,30 +182,23 @@ WebInspector.RawSourceCode.prototype = {
      */
     _createSourceMapping: function(callback)
     {
-        if (this._compilerSourceMappingProvider) {
-            /**
-             * @this {WebInspector.RawSourceCode}
-             * @param {WebInspector.CompilerSourceMapping} compilerSourceMapping
-             */
-            function didLoadSourceMapping(compilerSourceMapping)
-            {
-                if (!compilerSourceMapping) {
-                    delete this._compilerSourceMappingProvider;
-                    callback(null);
-                    return;
-                }
-                var uiSourceCodeList = [];
-                var sourceURLs = compilerSourceMapping.sources();
-                for (var i = 0; i < sourceURLs.length; ++i) {
-                    var sourceURL = sourceURLs[i];
-                    var contentProvider = new WebInspector.CompilerSourceMappingContentProvider(sourceURL, this._compilerSourceMappingProvider);
-                    var uiSourceCode = new WebInspector.UISourceCode(sourceURL, sourceURL, this.isContentScript, this, contentProvider);
-                    uiSourceCodeList.push(uiSourceCode);
-                }
-                var sourceMapping = new WebInspector.RawSourceCode.CompilerSourceMapping(this, uiSourceCodeList, compilerSourceMapping);
-                callback(sourceMapping);
+        if (this._compilerSourceMapping) {
+            var success = this._compilerSourceMapping.load();
+            if (!success) {
+                delete this._compilerSourceMapping;
+                callback(null);
+                return;
             }
-            this._compilerSourceMappingProvider.loadSourceMapping(didLoadSourceMapping.bind(this));
+            var uiSourceCodeList = [];
+            var sourceURLs = this._compilerSourceMapping.sources();
+            for (var i = 0; i < sourceURLs.length; ++i) {
+                var sourceURL = sourceURLs[i];
+                var contentProvider = new WebInspector.CompilerSourceMappingContentProvider(sourceURL, this._compilerSourceMapping);
+                var uiSourceCode = new WebInspector.UISourceCode(sourceURL, sourceURL, this.isContentScript, this, contentProvider);
+                uiSourceCodeList.push(uiSourceCode);
+            }
+            var sourceMapping = new WebInspector.RawSourceCode.CompilerSourceMapping(this, uiSourceCodeList, this._compilerSourceMapping);
+            callback(sourceMapping);
             return;
         }
 
index 05b8bb1..3186ba8 100644 (file)
@@ -18,7 +18,6 @@
     <file>Checkbox.js</file>
     <file>Color.js</file>
     <file>CompilerSourceMapping.js</file>
-    <file>CompilerSourceMappingProvider.js</file>
     <file>ConsoleMessage.js</file>
     <file>ConsoleModel.js</file>
     <file>ConsolePanel.js</file>
index 712eaec..d2c70d0 100644 (file)
@@ -165,7 +165,6 @@ THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
     <script type="text/javascript" src="ContentProviders.js"></script>
     <script type="text/javascript" src="RawSourceCode.js"></script>
     <script type="text/javascript" src="CompilerSourceMapping.js"></script>
-    <script type="text/javascript" src="CompilerSourceMappingProvider.js"></script>
     <script type="text/javascript" src="ScriptsSearchScope.js"></script>
     <script type="text/javascript" src="DOMAgent.js"></script>
     <script type="text/javascript" src="TimelineAgent.js"></script>
index ad8ae88..9fb77aa 100644 (file)
@@ -872,7 +872,7 @@ WebInspector._toolbarItemClicked = function(event)
 WebInspector.installSourceMappingForTest = function(url)
 {
     // FIXME: remove this method when it's possible to set compiler source mappings via UI.
-    var provider = new WebInspector.CompilerSourceMappingProvider(url);
+    var sourceMapping = new WebInspector.ClosureCompilerSourceMapping(url);
     var uiSourceCode = WebInspector.panels.scripts.visibleView._delegate._uiSourceCode;
-    uiSourceCode.rawSourceCode.setCompilerSourceMappingProvider(provider);
+    uiSourceCode.rawSourceCode.setCompilerSourceMapping(sourceMapping);
 }