Title: [103795] trunk
Revision
103795
Author
podivi...@chromium.org
Date
2011-12-29 04:16:05 -0800 (Thu, 29 Dec 2011)

Log Message

Web Inspector: add "enable source maps" checkbox setting.
https://bugs.webkit.org/show_bug.cgi?id=75311

Reviewed by Pavel Feldman.

Source/WebCore:

When "enable source maps" is on, all auto detected source maps are silently applied.

* English.lproj/localizedStrings.js:
* inspector/front-end/DebuggerPresentationModel.js:
* inspector/front-end/_javascript_SourceFrame.js:
(WebInspector._javascript_SourceFrame.prototype.populateTextAreaContextMenu):
* inspector/front-end/RawSourceCode.js:
(WebInspector.RawSourceCode):
(WebInspector.RawSourceCode.prototype.setFormatted):
(WebInspector.RawSourceCode.prototype._updateSourceMapping.didCreateSourceMapping):
(WebInspector.RawSourceCode.prototype._updateSourceMapping):
(WebInspector.RawSourceCode.prototype._createUISourceCode):
* inspector/front-end/Settings.js:
(WebInspector.Settings):
* inspector/front-end/SettingsScreen.js:
(WebInspector.SettingsScreen):
* inspector/front-end/UISourceCode.js:
(WebInspector.UISourceCode):
* inspector/front-end/inspector.js:
(WebInspector._toolbarItemClicked):

LayoutTests:

* http/tests/inspector/compiler-source-mapping-debug-expected.txt:
* http/tests/inspector/compiler-source-mapping-debug.html:
* inspector/debugger/raw-source-code.html:

Modified Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (103794 => 103795)


--- trunk/LayoutTests/ChangeLog	2011-12-29 11:21:20 UTC (rev 103794)
+++ trunk/LayoutTests/ChangeLog	2011-12-29 12:16:05 UTC (rev 103795)
@@ -1,3 +1,14 @@
+2011-12-28  Pavel Podivilov  <podivi...@chromium.org>
+
+        Web Inspector: add "enable source maps" checkbox setting.
+        https://bugs.webkit.org/show_bug.cgi?id=75311
+
+        Reviewed by Pavel Feldman.
+
+        * http/tests/inspector/compiler-source-mapping-debug-expected.txt:
+        * http/tests/inspector/compiler-source-mapping-debug.html:
+        * inspector/debugger/raw-source-code.html:
+
 2011-12-28  Alexis Menard  <alexis.men...@openbossa.org>
 
         getComputedStyle for border-color is not implemented.

Modified: trunk/LayoutTests/http/tests/inspector/compiler-source-mapping-debug-expected.txt (103794 => 103795)


--- trunk/LayoutTests/http/tests/inspector/compiler-source-mapping-debug-expected.txt	2011-12-29 11:21:20 UTC (rev 103794)
+++ trunk/LayoutTests/http/tests/inspector/compiler-source-mapping-debug-expected.txt	2011-12-29 12:16:05 UTC (rev 103795)
@@ -5,6 +5,7 @@
 Debugger was enabled.
 
 Running: testSetBreakpoint
+Page reloaded.
 Script source was shown.
 Script execution paused.
 Call stack:

Modified: trunk/LayoutTests/http/tests/inspector/compiler-source-mapping-debug.html (103794 => 103795)


--- trunk/LayoutTests/http/tests/inspector/compiler-source-mapping-debug.html	2011-12-29 11:21:20 UTC (rev 103794)
+++ trunk/LayoutTests/http/tests/inspector/compiler-source-mapping-debug.html	2011-12-29 12:16:05 UTC (rev 103795)
@@ -13,21 +13,29 @@
 
 function test()
 {
+    WebInspector.OriginalScript = WebInspector.Script;
+    WebInspector.Script = function()
+    {
+        WebInspector.OriginalScript.apply(this, arguments);
+        if (this.sourceURL.indexOf("compiled.js") !== -1)
+            this.sourceMapURL = "http://localhost:8000/inspector/resources/source-map.json";
+    }
+    WebInspector.Script.prototype = WebInspector.OriginalScript.prototype;
+
     InspectorTest.runDebuggerTestSuite([
         function testSetBreakpoint(next)
         {
-            InspectorTest.showScriptSource("compiled.js", didShowCompiled);
+            WebInspector.settings.sourceMapsEnabled.set(true);
+            InspectorTest.reloadPage(pageReloaded);
 
-            function didShowCompiled(sourceFrame)
+            function pageReloaded()
             {
-                InspectorTest.addResult("Script source was shown.");
-                sourceFrame._uiSourceCode.sourceMapURL = "http://localhost:8000/inspector/resources/source-map.json";
-                sourceFrame._model.installCompilerSourceMapping(sourceFrame._uiSourceCode);
-                InspectorTest.showScriptSource("source1.js", didShowSource1);
+                InspectorTest.showScriptSource("source1.js", didShowSource);
             }
 
-            function didShowSource1(sourceFrame)
+            function didShowSource(sourceFrame)
             {
+                InspectorTest.addResult("Script source was shown.");
                 InspectorTest.setBreakpoint(sourceFrame, 14, "", true);
                 InspectorTest.waitUntilPaused(paused);
                 InspectorTest.evaluateInPage("setTimeout(clickButton, 0)");

Modified: trunk/LayoutTests/inspector/debugger/raw-source-code.html (103794 => 103795)


--- trunk/LayoutTests/inspector/debugger/raw-source-code.html	2011-12-29 11:21:20 UTC (rev 103794)
+++ trunk/LayoutTests/inspector/debugger/raw-source-code.html	2011-12-29 12:16:05 UTC (rev 103795)
@@ -56,9 +56,9 @@
         return formatter;
       };
 
-    function createRawSourceCode(script, resource, formatted)
+    function createRawSourceCode(script, resource, formatted, compilerSourceMapping)
     {
-        var rawSourceCode = new WebInspector.RawSourceCode("id", script, resource, createScriptFormatterMock(), !!formatted);
+        var rawSourceCode = new WebInspector.RawSourceCode("id", script, resource, createScriptFormatterMock(), !!formatted, compilerSourceMapping);
         rawSourceCode.addEventListener(WebInspector.RawSourceCode.Events.SourceMappingUpdated, defaultSourceMappingUpdatedHandler);
         return rawSourceCode;
     }
@@ -359,25 +359,20 @@
 
             var script = createScriptMock("compiled.js", 0, 0, true, "<script source>");
             var resource = createPendingResourceMock("script", "<resource content>");
-            var rawSourceCode = createRawSourceCode(script, resource);
+            var rawSourceCode = createRawSourceCode(script, resource, false, compilerSourceMappingMock);
             var uiSourceCodeList;
 
-            waitForSourceMappingEvent(rawSourceCode, checkMapping);
-            rawSourceCode.setCompilerSourceMapping(compilerSourceMappingMock);
-            function checkMapping()
-            {
-                var sourceMapping = rawSourceCode.sourceMapping;
-                uiSourceCodeList = sourceMapping.uiSourceCodeList();
-                var uiSourceCodeByURL = {};
-                for (var i = 0; i < uiSourceCodeList.length; ++i)
-                    uiSourceCodeByURL[uiSourceCodeList[i].url] = uiSourceCodeList[i];
-                checkUILocation(uiSourceCodeByURL["source1.js"], 2, 4, sourceMapping.rawLocationToUILocation(createRawLocation(1, 2)));
-                checkUILocation(uiSourceCodeByURL["source2.js"], 10, 40, sourceMapping.rawLocationToUILocation(createRawLocation(15, 20)));
-                checkRawLocation(script, 1, 0, sourceMapping.uiLocationToRawLocation(uiSourceCodeByURL["source1.js"], 2, 0));
-                checkRawLocation(script, 15, 0, sourceMapping.uiLocationToRawLocation(uiSourceCodeByURL["source2.js"], 10, 0));
+            var sourceMapping = rawSourceCode.sourceMapping;
+            uiSourceCodeList = sourceMapping.uiSourceCodeList();
+            var uiSourceCodeByURL = {};
+            for (var i = 0; i < uiSourceCodeList.length; ++i)
+                uiSourceCodeByURL[uiSourceCodeList[i].url] = uiSourceCodeList[i];
+            checkUILocation(uiSourceCodeByURL["source1.js"], 2, 4, sourceMapping.rawLocationToUILocation(createRawLocation(1, 2)));
+            checkUILocation(uiSourceCodeByURL["source2.js"], 10, 40, sourceMapping.rawLocationToUILocation(createRawLocation(15, 20)));
+            checkRawLocation(script, 1, 0, sourceMapping.uiLocationToRawLocation(uiSourceCodeByURL["source1.js"], 2, 0));
+            checkRawLocation(script, 15, 0, sourceMapping.uiLocationToRawLocation(uiSourceCodeByURL["source2.js"], 10, 0));
 
-                uiSourceCodeList[0].requestContent(didRequestContent1);
-            }
+            uiSourceCodeList[0].requestContent(didRequestContent1);
 
             function didRequestContent1(mimeType, content)
             {
@@ -399,17 +394,10 @@
             var compilerSourceMappingMock = { load: function() { return false; } };
 
             var script = createScriptMock("compiled.js", 0, 0, true, "<script source>");
-            var rawSourceCode = createRawSourceCode(script, null);
-            var uiSourceCodeList;
+            var rawSourceCode = createRawSourceCode(script, null, false, compilerSourceMappingMock);
 
-            waitForSourceMappingEvent(rawSourceCode, checkMapping);
-            rawSourceCode.setCompilerSourceMapping(compilerSourceMappingMock);
-
-            function checkMapping()
-            {
-                InspectorTest.assertTrue(false, "Should not be reached.");
-            }
-
+            InspectorTest.assertEquals(1, rawSourceCode.sourceMapping.uiSourceCodeList().length);
+            InspectorTest.assertEquals("compiled.js", rawSourceCode.sourceMapping.uiSourceCodeList()[0].url);
             next();
         }
     ]);

Modified: trunk/Source/WebCore/ChangeLog (103794 => 103795)


--- trunk/Source/WebCore/ChangeLog	2011-12-29 11:21:20 UTC (rev 103794)
+++ trunk/Source/WebCore/ChangeLog	2011-12-29 12:16:05 UTC (rev 103795)
@@ -1,3 +1,31 @@
+2011-12-28  Pavel Podivilov  <podivi...@chromium.org>
+
+        Web Inspector: add "enable source maps" checkbox setting.
+        https://bugs.webkit.org/show_bug.cgi?id=75311
+
+        Reviewed by Pavel Feldman.
+
+        When "enable source maps" is on, all auto detected source maps are silently applied.
+
+        * English.lproj/localizedStrings.js:
+        * inspector/front-end/DebuggerPresentationModel.js:
+        * inspector/front-end/_javascript_SourceFrame.js:
+        (WebInspector._javascript_SourceFrame.prototype.populateTextAreaContextMenu):
+        * inspector/front-end/RawSourceCode.js:
+        (WebInspector.RawSourceCode):
+        (WebInspector.RawSourceCode.prototype.setFormatted):
+        (WebInspector.RawSourceCode.prototype._updateSourceMapping.didCreateSourceMapping):
+        (WebInspector.RawSourceCode.prototype._updateSourceMapping):
+        (WebInspector.RawSourceCode.prototype._createUISourceCode):
+        * inspector/front-end/Settings.js:
+        (WebInspector.Settings):
+        * inspector/front-end/SettingsScreen.js:
+        (WebInspector.SettingsScreen):
+        * inspector/front-end/UISourceCode.js:
+        (WebInspector.UISourceCode):
+        * inspector/front-end/inspector.js:
+        (WebInspector._toolbarItemClicked):
+
 2011-12-29  Julien Chaffraix  <jchaffr...@webkit.org>
 
         Tighten our checks for needsSectionRecalc in RenderTable

Modified: trunk/Source/WebCore/English.lproj/localizedStrings.js


(Binary files differ)

Modified: trunk/Source/WebCore/inspector/front-end/DebuggerPresentationModel.js (103794 => 103795)


--- trunk/Source/WebCore/inspector/front-end/DebuggerPresentationModel.js	2011-12-29 11:21:20 UTC (rev 103794)
+++ trunk/Source/WebCore/inspector/front-end/DebuggerPresentationModel.js	2011-12-29 12:16:05 UTC (rev 103795)
@@ -89,7 +89,7 @@
         return new WebInspector.DebuggerPresentationModel.CallFramePlacard(callFrame);
     },
 
-    /*
+    /**
      * @param {DebuggerAgent.Location} rawLocation
      * @return {?WebInspector.UILocation}
      */
@@ -139,7 +139,11 @@
             }
         }
 
-        rawSourceCode = new WebInspector.RawSourceCode(script.scriptId, script, resource, this._formatter, this._formatSource);
+        var compilerSourceMapping = null;
+        if (WebInspector.settings.sourceMapsEnabled.get() && script.sourceMapURL)
+            compilerSourceMapping = new WebInspector.ClosureCompilerSourceMapping(script.sourceMapURL, script.sourceURL);
+
+        rawSourceCode = new WebInspector.RawSourceCode(script.scriptId, script, resource, this._formatter, this._formatSource, compilerSourceMapping);
         this._bindScriptToRawSourceCode(script, rawSourceCode);
 
         if (isInlineScript)
@@ -336,15 +340,6 @@
     },
 
     /**
-     * @param {WebInspector.UISourceCode} uiSourceCode
-     */
-    installCompilerSourceMapping: function(uiSourceCode)
-    {
-        var sourceMapping = new WebInspector.ClosureCompilerSourceMapping(uiSourceCode.sourceMapURL, uiSourceCode.url);
-        uiSourceCode.rawSourceCode.setCompilerSourceMapping(sourceMapping);
-    },
-
-    /**
      * @param {WebInspector.Event} event
      */
     _consoleMessageAdded: function(event)

Modified: trunk/Source/WebCore/inspector/front-end/_javascript_SourceFrame.js (103794 => 103795)


--- trunk/Source/WebCore/inspector/front-end/_javascript_SourceFrame.js	2011-12-29 11:21:20 UTC (rev 103794)
+++ trunk/Source/WebCore/inspector/front-end/_javascript_SourceFrame.js	2011-12-29 12:16:05 UTC (rev 103795)
@@ -157,14 +157,7 @@
             contextMenu.appendItem(addToWatchLabel, this._scriptsPanel.addToWatch.bind(this._scriptsPanel, selection.toString()));
             var evaluateLabel = WebInspector.UIString(WebInspector.useLowerCaseMenuTitles() ? "Evaluate in console" : "Evaluate in Console");
             contextMenu.appendItem(evaluateLabel, WebInspector.evaluateInConsole.bind(WebInspector, selection.toString()));
-            contextMenu.appendSeparator();
         }
-
-        if (this._uiSourceCode.sourceMapURL) {
-            var installSourceMapLabel = WebInspector.UIString(WebInspector.useLowerCaseMenuTitles() ? "Install source map" : "Install Source Map");
-            contextMenu.appendItem(installSourceMapLabel, this._model.installCompilerSourceMapping.bind(this._model, this._uiSourceCode));
-        }
-
     },
 
     afterTextChanged: function(oldRange, newRange)

Modified: trunk/Source/WebCore/inspector/front-end/RawSourceCode.js (103794 => 103795)


--- trunk/Source/WebCore/inspector/front-end/RawSourceCode.js	2011-12-29 11:21:20 UTC (rev 103794)
+++ trunk/Source/WebCore/inspector/front-end/RawSourceCode.js	2011-12-29 12:16:05 UTC (rev 103795)
@@ -39,20 +39,21 @@
  * @param {WebInspector.Resource} resource
  * @param {WebInspector.ScriptFormatter} formatter
  * @param {boolean} formatted
+ * @param {WebInspector.CompilerSourceMapping} compilerSourceMapping
  */
-WebInspector.RawSourceCode = function(id, script, resource, formatter, formatted)
+WebInspector.RawSourceCode = function(id, script, resource, formatter, formatted, compilerSourceMapping)
 {
     this.id = id;
     this.url = ""
     this.isContentScript = script.isContentScript;
-    this.sourceMapURL = script.sourceMapURL;
     this._scripts = [script];
     this._formatter = formatter;
     this._formatted = formatted;
+    this._compilerSourceMapping = compilerSourceMapping;
     this._resource = resource;
     this.messages = [];
 
-    this._useTemporaryContent = this._resource && !this._resource.finished;
+    this._useTemporaryContent = !this._compilerSourceMapping && this._resource && !this._resource.finished;
     this._hasNewScripts = true;
     if (!this._useTemporaryContent)
         this._updateSourceMapping();
@@ -90,20 +91,10 @@
         if (this._formatted === formatted)
             return;
         this._formatted = formatted;
-        this._updateSourceMapping();
+        if (!this._compilerSourceMapping)
+            this._updateSourceMapping();
     },
 
-    /**
-     * @param {WebInspector.CompilerSourceMapping} compilerSourceMapping
-     */
-    setCompilerSourceMapping: function(compilerSourceMapping)
-    {
-        if (compilerSourceMapping)
-            this._useTemporaryContent = false;
-        this._compilerSourceMapping = compilerSourceMapping;
-        this._updateSourceMapping();
-    },
-
     _resourceFinished: function()
     {
         if (this._compilerSourceMapping)
@@ -160,9 +151,7 @@
         function didCreateSourceMapping(sourceMapping)
         {
             this._updatingSourceMapping = false;
-            if (!sourceMapping)
-                return;
-            if (!this._updateNeeded)
+            if (sourceMapping && !this._updateNeeded)
                 this._saveSourceMapping(sourceMapping);
             else
                 this._updateSourceMapping();
@@ -244,7 +233,6 @@
     {
         var uiSourceCode = new WebInspector.UISourceCode(id, url, this, contentProvider);
         uiSourceCode.isContentScript = this.isContentScript;
-        uiSourceCode.sourceMapURL = this.sourceMapURL;
         return uiSourceCode;
     },
 

Modified: trunk/Source/WebCore/inspector/front-end/Settings.js (103794 => 103795)


--- trunk/Source/WebCore/inspector/front-end/Settings.js	2011-12-29 11:21:20 UTC (rev 103794)
+++ trunk/Source/WebCore/inspector/front-end/Settings.js	2011-12-29 12:16:05 UTC (rev 103795)
@@ -81,6 +81,7 @@
     this.eventListenerBreakpoints = this.createSetting("eventListenerBreakpoints", []);
     this.domBreakpoints = this.createSetting("domBreakpoints", []);
     this.xhrBreakpoints = this.createSetting("xhrBreakpoints", []);
+    this.sourceMapsEnabled = this.createSetting("sourceMapsEnabled", false);
     this.cacheDisabled = this.createSetting("cacheDisabled", false);
     this.overrideUserAgent = this.createSetting("overrideUserAgent", "");
     this.userAgent = this.createSetting("userAgent", "");

Modified: trunk/Source/WebCore/inspector/front-end/SettingsScreen.js (103794 => 103795)


--- trunk/Source/WebCore/inspector/front-end/SettingsScreen.js	2011-12-29 11:21:20 UTC (rev 103794)
+++ trunk/Source/WebCore/inspector/front-end/SettingsScreen.js	2011-12-29 12:16:05 UTC (rev 103795)
@@ -66,6 +66,7 @@
     p = this._appendSection(WebInspector.UIString("Scripts"), true);
     p.appendChild(this._createCheckboxSetting(WebInspector.UIString("Show script folders"), WebInspector.settings.showScriptFolders));
     p.appendChild(this._createCheckboxSetting(WebInspector.UIString("Search in content scripts"), WebInspector.settings.searchInContentScripts));
+    p.appendChild(this._createCheckboxSetting(WebInspector.UIString("Enable source maps"), WebInspector.settings.sourceMapsEnabled));
 
     p = this._appendSection(WebInspector.UIString("Profiler"), true);
     p.appendChild(this._createCheckboxSetting(WebInspector.UIString("Show objects' hidden properties"), WebInspector.settings.showHeapSnapshotObjectsHiddenProperties));

Modified: trunk/Source/WebCore/inspector/front-end/UISourceCode.js (103794 => 103795)


--- trunk/Source/WebCore/inspector/front-end/UISourceCode.js	2011-12-29 11:21:20 UTC (rev 103794)
+++ trunk/Source/WebCore/inspector/front-end/UISourceCode.js	2011-12-29 12:16:05 UTC (rev 103795)
@@ -43,7 +43,6 @@
     this._rawSourceCode = rawSourceCode;
     this._contentProvider = contentProvider;
     this.isContentScript = false;
-    this.sourceMapURL = "";
     /**
      * @type Array.<function(string,string)>
      */

Modified: trunk/Source/WebCore/inspector/front-end/inspector.js (103794 => 103795)


--- trunk/Source/WebCore/inspector/front-end/inspector.js	2011-12-29 11:21:20 UTC (rev 103794)
+++ trunk/Source/WebCore/inspector/front-end/inspector.js	2011-12-29 12:16:05 UTC (rev 103795)
@@ -885,11 +885,3 @@
     var toolbarItem = event.currentTarget;
     WebInspector.inspectorView.setCurrentPanel(toolbarItem.panel);
 }
-
-WebInspector.installSourceMappingForTest = function(url)
-{
-    // FIXME: remove this method when it's possible to set compiler source mappings via UI.
-    var sourceMapping = new WebInspector.ClosureCompilerSourceMapping(url);
-    var uiSourceCode = WebInspector.panels.scripts.visibleView._uiSourceCode;
-    uiSourceCode.rawSourceCode.setCompilerSourceMapping(sourceMapping);
-}
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to