Changeset 103795 in webkit


Ignore:
Timestamp:
Dec 29, 2011 4:16:05 AM (12 years ago)
Author:
podivilov@chromium.org
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/JavaScriptSourceFrame.js:

(WebInspector.JavaScriptSourceFrame.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:
Location:
trunk
Files:
13 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r103780 r103795  
     12011-12-28  Pavel Podivilov  <podivilov@chromium.org>
     2
     3        Web Inspector: add "enable source maps" checkbox setting.
     4        https://bugs.webkit.org/show_bug.cgi?id=75311
     5
     6        Reviewed by Pavel Feldman.
     7
     8        * http/tests/inspector/compiler-source-mapping-debug-expected.txt:
     9        * http/tests/inspector/compiler-source-mapping-debug.html:
     10        * inspector/debugger/raw-source-code.html:
     11
    1122011-12-28  Alexis Menard  <alexis.menard@openbossa.org>
    213
  • trunk/LayoutTests/http/tests/inspector/compiler-source-mapping-debug-expected.txt

    r101128 r103795  
    66
    77Running: testSetBreakpoint
     8Page reloaded.
    89Script source was shown.
    910Script execution paused.
  • trunk/LayoutTests/http/tests/inspector/compiler-source-mapping-debug.html

    r103541 r103795  
    1414function test()
    1515{
     16    WebInspector.OriginalScript = WebInspector.Script;
     17    WebInspector.Script = function()
     18    {
     19        WebInspector.OriginalScript.apply(this, arguments);
     20        if (this.sourceURL.indexOf("compiled.js") !== -1)
     21            this.sourceMapURL = "http://localhost:8000/inspector/resources/source-map.json";
     22    }
     23    WebInspector.Script.prototype = WebInspector.OriginalScript.prototype;
     24
    1625    InspectorTest.runDebuggerTestSuite([
    1726        function testSetBreakpoint(next)
    1827        {
    19             InspectorTest.showScriptSource("compiled.js", didShowCompiled);
     28            WebInspector.settings.sourceMapsEnabled.set(true);
     29            InspectorTest.reloadPage(pageReloaded);
    2030
    21             function didShowCompiled(sourceFrame)
     31            function pageReloaded()
     32            {
     33                InspectorTest.showScriptSource("source1.js", didShowSource);
     34            }
     35
     36            function didShowSource(sourceFrame)
    2237            {
    2338                InspectorTest.addResult("Script source was shown.");
    24                 sourceFrame._uiSourceCode.sourceMapURL = "http://localhost:8000/inspector/resources/source-map.json";
    25                 sourceFrame._model.installCompilerSourceMapping(sourceFrame._uiSourceCode);
    26                 InspectorTest.showScriptSource("source1.js", didShowSource1);
    27             }
    28 
    29             function didShowSource1(sourceFrame)
    30             {
    3139                InspectorTest.setBreakpoint(sourceFrame, 14, "", true);
    3240                InspectorTest.waitUntilPaused(paused);
  • trunk/LayoutTests/inspector/debugger/raw-source-code.html

    r99823 r103795  
    5757      };
    5858
    59     function createRawSourceCode(script, resource, formatted)
    60     {
    61         var rawSourceCode = new WebInspector.RawSourceCode("id", script, resource, createScriptFormatterMock(), !!formatted);
     59    function createRawSourceCode(script, resource, formatted, compilerSourceMapping)
     60    {
     61        var rawSourceCode = new WebInspector.RawSourceCode("id", script, resource, createScriptFormatterMock(), !!formatted, compilerSourceMapping);
    6262        rawSourceCode.addEventListener(WebInspector.RawSourceCode.Events.SourceMappingUpdated, defaultSourceMappingUpdatedHandler);
    6363        return rawSourceCode;
     
    360360            var script = createScriptMock("compiled.js", 0, 0, true, "<script source>");
    361361            var resource = createPendingResourceMock("script", "<resource content>");
    362             var rawSourceCode = createRawSourceCode(script, resource);
     362            var rawSourceCode = createRawSourceCode(script, resource, false, compilerSourceMappingMock);
    363363            var uiSourceCodeList;
    364364
    365             waitForSourceMappingEvent(rawSourceCode, checkMapping);
    366             rawSourceCode.setCompilerSourceMapping(compilerSourceMappingMock);
    367             function checkMapping()
    368             {
    369                 var sourceMapping = rawSourceCode.sourceMapping;
    370                 uiSourceCodeList = sourceMapping.uiSourceCodeList();
    371                 var uiSourceCodeByURL = {};
    372                 for (var i = 0; i < uiSourceCodeList.length; ++i)
    373                     uiSourceCodeByURL[uiSourceCodeList[i].url] = uiSourceCodeList[i];
    374                 checkUILocation(uiSourceCodeByURL["source1.js"], 2, 4, sourceMapping.rawLocationToUILocation(createRawLocation(1, 2)));
    375                 checkUILocation(uiSourceCodeByURL["source2.js"], 10, 40, sourceMapping.rawLocationToUILocation(createRawLocation(15, 20)));
    376                 checkRawLocation(script, 1, 0, sourceMapping.uiLocationToRawLocation(uiSourceCodeByURL["source1.js"], 2, 0));
    377                 checkRawLocation(script, 15, 0, sourceMapping.uiLocationToRawLocation(uiSourceCodeByURL["source2.js"], 10, 0));
    378 
    379                 uiSourceCodeList[0].requestContent(didRequestContent1);
    380             }
     365            var sourceMapping = rawSourceCode.sourceMapping;
     366            uiSourceCodeList = sourceMapping.uiSourceCodeList();
     367            var uiSourceCodeByURL = {};
     368            for (var i = 0; i < uiSourceCodeList.length; ++i)
     369                uiSourceCodeByURL[uiSourceCodeList[i].url] = uiSourceCodeList[i];
     370            checkUILocation(uiSourceCodeByURL["source1.js"], 2, 4, sourceMapping.rawLocationToUILocation(createRawLocation(1, 2)));
     371            checkUILocation(uiSourceCodeByURL["source2.js"], 10, 40, sourceMapping.rawLocationToUILocation(createRawLocation(15, 20)));
     372            checkRawLocation(script, 1, 0, sourceMapping.uiLocationToRawLocation(uiSourceCodeByURL["source1.js"], 2, 0));
     373            checkRawLocation(script, 15, 0, sourceMapping.uiLocationToRawLocation(uiSourceCodeByURL["source2.js"], 10, 0));
     374
     375            uiSourceCodeList[0].requestContent(didRequestContent1);
    381376
    382377            function didRequestContent1(mimeType, content)
     
    400395
    401396            var script = createScriptMock("compiled.js", 0, 0, true, "<script source>");
    402             var rawSourceCode = createRawSourceCode(script, null);
    403             var uiSourceCodeList;
    404 
    405             waitForSourceMappingEvent(rawSourceCode, checkMapping);
    406             rawSourceCode.setCompilerSourceMapping(compilerSourceMappingMock);
    407 
    408             function checkMapping()
    409             {
    410                 InspectorTest.assertTrue(false, "Should not be reached.");
    411             }
    412 
     397            var rawSourceCode = createRawSourceCode(script, null, false, compilerSourceMappingMock);
     398
     399            InspectorTest.assertEquals(1, rawSourceCode.sourceMapping.uiSourceCodeList().length);
     400            InspectorTest.assertEquals("compiled.js", rawSourceCode.sourceMapping.uiSourceCodeList()[0].url);
    413401            next();
    414402        }
  • trunk/Source/WebCore/ChangeLog

    r103794 r103795  
     12011-12-28  Pavel Podivilov  <podivilov@chromium.org>
     2
     3        Web Inspector: add "enable source maps" checkbox setting.
     4        https://bugs.webkit.org/show_bug.cgi?id=75311
     5
     6        Reviewed by Pavel Feldman.
     7
     8        When "enable source maps" is on, all auto detected source maps are silently applied.
     9
     10        * English.lproj/localizedStrings.js:
     11        * inspector/front-end/DebuggerPresentationModel.js:
     12        * inspector/front-end/JavaScriptSourceFrame.js:
     13        (WebInspector.JavaScriptSourceFrame.prototype.populateTextAreaContextMenu):
     14        * inspector/front-end/RawSourceCode.js:
     15        (WebInspector.RawSourceCode):
     16        (WebInspector.RawSourceCode.prototype.setFormatted):
     17        (WebInspector.RawSourceCode.prototype._updateSourceMapping.didCreateSourceMapping):
     18        (WebInspector.RawSourceCode.prototype._updateSourceMapping):
     19        (WebInspector.RawSourceCode.prototype._createUISourceCode):
     20        * inspector/front-end/Settings.js:
     21        (WebInspector.Settings):
     22        * inspector/front-end/SettingsScreen.js:
     23        (WebInspector.SettingsScreen):
     24        * inspector/front-end/UISourceCode.js:
     25        (WebInspector.UISourceCode):
     26        * inspector/front-end/inspector.js:
     27        (WebInspector._toolbarItemClicked):
     28
    1292011-12-29  Julien Chaffraix  <jchaffraix@webkit.org>
    230
  • trunk/Source/WebCore/inspector/front-end/DebuggerPresentationModel.js

    r103759 r103795  
    9090    },
    9191
    92     /*
     92    /**
    9393     * @param {DebuggerAgent.Location} rawLocation
    9494     * @return {?WebInspector.UILocation}
     
    140140        }
    141141
    142         rawSourceCode = new WebInspector.RawSourceCode(script.scriptId, script, resource, this._formatter, this._formatSource);
     142        var compilerSourceMapping = null;
     143        if (WebInspector.settings.sourceMapsEnabled.get() && script.sourceMapURL)
     144            compilerSourceMapping = new WebInspector.ClosureCompilerSourceMapping(script.sourceMapURL, script.sourceURL);
     145
     146        rawSourceCode = new WebInspector.RawSourceCode(script.scriptId, script, resource, this._formatter, this._formatSource, compilerSourceMapping);
    143147        this._bindScriptToRawSourceCode(script, rawSourceCode);
    144148
     
    337341
    338342    /**
    339      * @param {WebInspector.UISourceCode} uiSourceCode
    340      */
    341     installCompilerSourceMapping: function(uiSourceCode)
    342     {
    343         var sourceMapping = new WebInspector.ClosureCompilerSourceMapping(uiSourceCode.sourceMapURL, uiSourceCode.url);
    344         uiSourceCode.rawSourceCode.setCompilerSourceMapping(sourceMapping);
    345     },
    346 
    347     /**
    348343     * @param {WebInspector.Event} event
    349344     */
  • trunk/Source/WebCore/inspector/front-end/JavaScriptSourceFrame.js

    r103690 r103795  
    158158            var evaluateLabel = WebInspector.UIString(WebInspector.useLowerCaseMenuTitles() ? "Evaluate in console" : "Evaluate in Console");
    159159            contextMenu.appendItem(evaluateLabel, WebInspector.evaluateInConsole.bind(WebInspector, selection.toString()));
    160             contextMenu.appendSeparator();
    161         }
    162 
    163         if (this._uiSourceCode.sourceMapURL) {
    164             var installSourceMapLabel = WebInspector.UIString(WebInspector.useLowerCaseMenuTitles() ? "Install source map" : "Install Source Map");
    165             contextMenu.appendItem(installSourceMapLabel, this._model.installCompilerSourceMapping.bind(this._model, this._uiSourceCode));
    166         }
    167 
     160        }
    168161    },
    169162
  • trunk/Source/WebCore/inspector/front-end/RawSourceCode.js

    r103711 r103795  
    4040 * @param {WebInspector.ScriptFormatter} formatter
    4141 * @param {boolean} formatted
    42  */
    43 WebInspector.RawSourceCode = function(id, script, resource, formatter, formatted)
     42 * @param {WebInspector.CompilerSourceMapping} compilerSourceMapping
     43 */
     44WebInspector.RawSourceCode = function(id, script, resource, formatter, formatted, compilerSourceMapping)
    4445{
    4546    this.id = id;
    4647    this.url = script.sourceURL;
    4748    this.isContentScript = script.isContentScript;
    48     this.sourceMapURL = script.sourceMapURL;
    4949    this._scripts = [script];
    5050    this._formatter = formatter;
    5151    this._formatted = formatted;
     52    this._compilerSourceMapping = compilerSourceMapping;
    5253    this._resource = resource;
    5354    this.messages = [];
    5455
    55     this._useTemporaryContent = this._resource && !this._resource.finished;
     56    this._useTemporaryContent = !this._compilerSourceMapping && this._resource && !this._resource.finished;
    5657    this._hasNewScripts = true;
    5758    if (!this._useTemporaryContent)
     
    9192            return;
    9293        this._formatted = formatted;
    93         this._updateSourceMapping();
    94     },
    95 
    96     /**
    97      * @param {WebInspector.CompilerSourceMapping} compilerSourceMapping
    98      */
    99     setCompilerSourceMapping: function(compilerSourceMapping)
    100     {
    101         if (compilerSourceMapping)
    102             this._useTemporaryContent = false;
    103         this._compilerSourceMapping = compilerSourceMapping;
    104         this._updateSourceMapping();
     94        if (!this._compilerSourceMapping)
     95            this._updateSourceMapping();
    10596    },
    10697
     
    161152        {
    162153            this._updatingSourceMapping = false;
    163             if (!sourceMapping)
    164                 return;
    165             if (!this._updateNeeded)
     154            if (sourceMapping && !this._updateNeeded)
    166155                this._saveSourceMapping(sourceMapping);
    167156            else
     
    245234        var uiSourceCode = new WebInspector.UISourceCode(id, url, this, contentProvider);
    246235        uiSourceCode.isContentScript = this.isContentScript;
    247         uiSourceCode.sourceMapURL = this.sourceMapURL;
    248236        return uiSourceCode;
    249237    },
  • trunk/Source/WebCore/inspector/front-end/Settings.js

    r103767 r103795  
    8282    this.domBreakpoints = this.createSetting("domBreakpoints", []);
    8383    this.xhrBreakpoints = this.createSetting("xhrBreakpoints", []);
     84    this.sourceMapsEnabled = this.createSetting("sourceMapsEnabled", false);
    8485    this.cacheDisabled = this.createSetting("cacheDisabled", false);
    8586    this.overrideUserAgent = this.createSetting("overrideUserAgent", "");
  • trunk/Source/WebCore/inspector/front-end/SettingsScreen.js

    r103767 r103795  
    6767    p.appendChild(this._createCheckboxSetting(WebInspector.UIString("Show script folders"), WebInspector.settings.showScriptFolders));
    6868    p.appendChild(this._createCheckboxSetting(WebInspector.UIString("Search in content scripts"), WebInspector.settings.searchInContentScripts));
     69    p.appendChild(this._createCheckboxSetting(WebInspector.UIString("Enable source maps"), WebInspector.settings.sourceMapsEnabled));
    6970
    7071    p = this._appendSection(WebInspector.UIString("Profiler"), true);
  • trunk/Source/WebCore/inspector/front-end/UISourceCode.js

    r103690 r103795  
    4444    this._contentProvider = contentProvider;
    4545    this.isContentScript = false;
    46     this.sourceMapURL = "";
    4746    /**
    4847     * @type Array.<function(string,string)>
  • trunk/Source/WebCore/inspector/front-end/inspector.js

    r101777 r103795  
    886886    WebInspector.inspectorView.setCurrentPanel(toolbarItem.panel);
    887887}
    888 
    889 WebInspector.installSourceMappingForTest = function(url)
    890 {
    891     // FIXME: remove this method when it's possible to set compiler source mappings via UI.
    892     var sourceMapping = new WebInspector.ClosureCompilerSourceMapping(url);
    893     var uiSourceCode = WebInspector.panels.scripts.visibleView._uiSourceCode;
    894     uiSourceCode.rawSourceCode.setCompilerSourceMapping(sourceMapping);
    895 }
Note: See TracChangeset for help on using the changeset viewer.