Changeset 103541 in webkit


Ignore:
Timestamp:
Dec 22, 2011 7:19:40 AM (12 years ago)
Author:
podivilov@chromium.org
Message:

Web Inspector: add "install source map" to JS source frame context menu.
https://bugs.webkit.org/show_bug.cgi?id=74181

Reviewed by Pavel Feldman.

Source/WebCore:

Add "install source map" to source frame context menu when source map url is auto detected.

  • English.lproj/localizedStrings.js:
  • inspector/front-end/CompilerSourceMapping.js:

(WebInspector.ClosureCompilerSourceMapping.prototype.load):
(WebInspector.ClosureCompilerSourceMapping.prototype._parseSections):

  • inspector/front-end/DebuggerPresentationModel.js:

(WebInspector.DebuggerPresentationModel.prototype.installCompilerSourceMapping):

  • inspector/front-end/JavaScriptSourceFrame.js:

(WebInspector.JavaScriptSourceFrame.prototype.populateTextAreaContextMenu):
(WebInspector.JavaScriptSourceFrame.prototype.cancelEditing):

  • inspector/front-end/RawSourceCode.js:

(WebInspector.RawSourceCode.prototype._createSourceMapping.didRequestContent.didFormatContent):
(WebInspector.RawSourceCode.prototype._createSourceMapping.didRequestContent):
(WebInspector.RawSourceCode.prototype._createSourceMapping):
(WebInspector.RawSourceCode.prototype._createUISourceCode):

  • inspector/front-end/UISourceCode.js:

(WebInspector.UISourceCode):

LayoutTests:

  • http/tests/inspector/compiler-source-mapping-debug.html:
  • http/tests/inspector/compiler-source-mapping.html:
  • inspector/debugger/scripts-panel.html:
  • inspector/debugger/scripts-sorting.html:
  • inspector/debugger/ui-source-code.html:
Location:
trunk
Files:
13 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r103539 r103541  
     12011-12-22  Pavel Podivilov  <podivilov@chromium.org>
     2
     3        Web Inspector: add "install source map" to JS source frame context menu.
     4        https://bugs.webkit.org/show_bug.cgi?id=74181
     5
     6        Reviewed by Pavel Feldman.
     7
     8        * http/tests/inspector/compiler-source-mapping-debug.html:
     9        * http/tests/inspector/compiler-source-mapping.html:
     10        * inspector/debugger/scripts-panel.html:
     11        * inspector/debugger/scripts-sorting.html:
     12        * inspector/debugger/ui-source-code.html:
     13
    1142011-12-22  Branimir Lambov  <blambov@google.com>
    215
  • trunk/LayoutTests/http/tests/inspector/compiler-source-mapping-debug.html

    r101128 r103541  
    1414function test()
    1515{
    16 
    1716    InspectorTest.runDebuggerTestSuite([
    1817        function testSetBreakpoint(next)
     
    2322            {
    2423                InspectorTest.addResult("Script source was shown.");
    25                 sourceFrame._model.setCompilerSourceMapping(sourceFrame._uiSourceCode, "http://localhost:8000/inspector/resources/source-map.json");
     24                sourceFrame._uiSourceCode.sourceMapURL = "http://localhost:8000/inspector/resources/source-map.json";
     25                sourceFrame._model.installCompilerSourceMapping(sourceFrame._uiSourceCode);
    2626                InspectorTest.showScriptSource("source1.js", didShowSource1);
    27 
    2827            }
    2928
  • trunk/LayoutTests/http/tests/inspector/compiler-source-mapping.html

    r103534 r103541  
    9595            var mappingPayload = {
    9696                "sections": [{
    97                     "offset": { "line": 1, "column": 0 },
     97                    "offset": { "line": 0, "column": 0 },
    9898                    "map": {
    9999                        "mappings":"AAAA,CAEC",
     
    101101                    }
    102102                }, {
    103                     "offset": { "line": 3, "column": 10 },
     103                    "offset": { "line": 2, "column": 10 },
    104104                    "map": {
    105105                        "mappings":"AAAA,CAEC",
  • trunk/LayoutTests/inspector/debugger/scripts-panel.html

    r102671 r103541  
    2020    function createUISouceCode(url)
    2121    {
    22         var uiSourceCode = new WebInspector.UISourceCode(0, url, false, null, null);
     22        var uiSourceCode = new WebInspector.UISourceCode(0, url, null, null);
    2323        uiSourceCode.requestContent = function(callback)
    2424        {
     
    137137            function addOption(url, isContentScript)
    138138            {
    139                 panel._addOptionToFilesSelect(new WebInspector.UISourceCode(nextId++, url, isContentScript, null, null));
     139                var uiSourceCode = new WebInspector.UISourceCode(nextId++, url, null, null);
     140                uiSourceCode.isContentScript = isContentScript;
     141                panel._addOptionToFilesSelect(uiSourceCode);
    140142            }
    141143            addOption(rootURL + "foo/bar/script.js", false);
  • trunk/LayoutTests/inspector/debugger/scripts-sorting.html

    r102671 r103541  
    5858    function addOption(url, isContentScript)
    5959    {
    60         WebInspector.panels.scripts._addOptionToFilesSelect(new WebInspector.UISourceCode(nextId++, url, isContentScript, null, null));
     60        var uiSourceCode = new WebInspector.UISourceCode(nextId++, url, null, null);
     61        uiSourceCode.isContentScript = isContentScript;
     62        WebInspector.panels.scripts._addOptionToFilesSelect(uiSourceCode);
    6163    }
    6264
  • trunk/LayoutTests/inspector/debugger/ui-source-code.html

    r93969 r103541  
    1818        function testUISourceCode(next)
    1919        {
    20             var uiSourceCode = new WebInspector.UISourceCode("id", "url", false, null, contentProvider);
     20            var uiSourceCode = new WebInspector.UISourceCode("id", "url", null, contentProvider);
    2121            function didRequestContent(callNumber, mimeType, content)
    2222            {
  • trunk/Source/WebCore/ChangeLog

    r103539 r103541  
     12011-12-22  Pavel Podivilov  <podivilov@chromium.org>
     2
     3        Web Inspector: add "install source map" to JS source frame context menu.
     4        https://bugs.webkit.org/show_bug.cgi?id=74181
     5
     6        Reviewed by Pavel Feldman.
     7
     8        Add "install source map" to source frame context menu when source map url is auto detected.
     9
     10        * English.lproj/localizedStrings.js:
     11        * inspector/front-end/CompilerSourceMapping.js:
     12        (WebInspector.ClosureCompilerSourceMapping.prototype.load):
     13        (WebInspector.ClosureCompilerSourceMapping.prototype._parseSections):
     14        * inspector/front-end/DebuggerPresentationModel.js:
     15        (WebInspector.DebuggerPresentationModel.prototype.installCompilerSourceMapping):
     16        * inspector/front-end/JavaScriptSourceFrame.js:
     17        (WebInspector.JavaScriptSourceFrame.prototype.populateTextAreaContextMenu):
     18        (WebInspector.JavaScriptSourceFrame.prototype.cancelEditing):
     19        * inspector/front-end/RawSourceCode.js:
     20        (WebInspector.RawSourceCode.prototype._createSourceMapping.didRequestContent.didFormatContent):
     21        (WebInspector.RawSourceCode.prototype._createSourceMapping.didRequestContent):
     22        (WebInspector.RawSourceCode.prototype._createSourceMapping):
     23        (WebInspector.RawSourceCode.prototype._createUISourceCode):
     24        * inspector/front-end/UISourceCode.js:
     25        (WebInspector.UISourceCode):
     26
    1272011-12-22  Branimir Lambov  <blambov@google.com>
    228
  • trunk/Source/WebCore/inspector/front-end/CompilerSourceMapping.js

    r103534 r103541  
    9898            // FIXME: make sendRequest async.
    9999            var response = InspectorFrontendHost.loadResourceSynchronously(this._sourceMappingURL);
     100            if (response.slice(0, 3) === ")]}")
     101                response = response.substring(response.indexOf('\n'));
    100102            this._parseMappingPayload(JSON.parse(response));
    101103            return true
     
    183185        for (var i = 0; i < sections.length; ++i) {
    184186            var section = sections[i];
    185             this._parseMap(section.map, section.offset.line - 1, section.offset.column)
     187            this._parseMap(section.map, section.offset.line, section.offset.column)
    186188        }
    187189    },
  • trunk/Source/WebCore/inspector/front-end/DebuggerPresentationModel.js

    r103534 r103541  
    338338    /**
    339339     * @param {WebInspector.UISourceCode} uiSourceCode
    340      * @param {string} sourceMappingURL
    341      */
    342     setCompilerSourceMapping: function(uiSourceCode, sourceMappingURL)
    343     {
    344         var sourceMapping = new WebInspector.ClosureCompilerSourceMapping(sourceMappingURL, uiSourceCode.url);
     340     */
     341    installCompilerSourceMapping: function(uiSourceCode)
     342    {
     343        var sourceMapping = new WebInspector.ClosureCompilerSourceMapping(uiSourceCode.sourceMapURL, uiSourceCode.url);
    345344        uiSourceCode.rawSourceCode.setCompilerSourceMapping(sourceMapping);
    346345    },
  • trunk/Source/WebCore/inspector/front-end/JavaScriptSourceFrame.js

    r102671 r103541  
    148148        WebInspector.SourceFrame.prototype.populateTextAreaContextMenu.call(this, contextMenu, lineNumber);
    149149        var selection = window.getSelection();
    150         if (selection.type !== "Range" || selection.isCollapsed)
    151             return;
    152         contextMenu.appendItem(WebInspector.UIString(WebInspector.useLowerCaseMenuTitles() ? "Add to watch" : "Add to Watch"),
    153                 this._scriptsPanel.addToWatch.bind(this._scriptsPanel, selection.toString()));
    154 
    155         contextMenu.appendItem(WebInspector.UIString(WebInspector.useLowerCaseMenuTitles() ? "Evaluate in console" : "Evaluate in Console"), WebInspector.evaluateInConsole.bind(WebInspector, selection.toString()));
     150        if (selection.type === "Range" && !selection.isCollapsed) {
     151            var addToWatchLabel = WebInspector.UIString(WebInspector.useLowerCaseMenuTitles() ? "Add to watch" : "Add to Watch");
     152            contextMenu.appendItem(addToWatchLabel, this._scriptsPanel.addToWatch.bind(this._scriptsPanel, selection.toString()));
     153            var evaluateLabel = WebInspector.UIString(WebInspector.useLowerCaseMenuTitles() ? "Evaluate in console" : "Evaluate in Console");
     154            contextMenu.appendItem(evaluateLabel, WebInspector.evaluateInConsole.bind(WebInspector, selection.toString()));
     155            contextMenu.appendSeparator();
     156        }
     157
     158        if (this._uiSourceCode.sourceMapURL) {
     159            var installSourceMapLabel = WebInspector.UIString(WebInspector.useLowerCaseMenuTitles() ? "Install source map" : "Install Source Map");
     160            contextMenu.appendItem(installSourceMapLabel, this._model.installCompilerSourceMapping.bind(this._model, this._uiSourceCode));
     161        }
     162
    156163    },
    157164
     
    199206    {
    200207        WebInspector.SourceFrame.prototype.cancelEditing.call(this);
    201        
     208
    202209        if (!this._javaScriptSourceFrameState)
    203210            return;
  • trunk/Source/WebCore/inspector/front-end/RawSourceCode.js

    r103532 r103541  
    196196                var sourceURL = sourceURLs[i];
    197197                var contentProvider = new WebInspector.CompilerSourceMappingContentProvider(sourceURL, this._compilerSourceMapping);
    198                 var uiSourceCode = new WebInspector.UISourceCode(sourceURL, sourceURL, this.isContentScript, this, contentProvider);
     198                var uiSourceCode = this._createUISourceCode(sourceURL, sourceURL, contentProvider);
    199199                uiSourceCodeList.push(uiSourceCode);
    200200            }
     
    206206        var originalContentProvider = this._createContentProvider();
    207207        if (!this._formatted) {
    208             var uiSourceCode = new WebInspector.UISourceCode(this.url, this.url, this.isContentScript, this, originalContentProvider);
     208            var uiSourceCode = this._createUISourceCode(this.url, this.url, originalContentProvider);
    209209            var sourceMapping = new WebInspector.RawSourceCode.PlainSourceMapping(this, uiSourceCode);
    210210            callback(sourceMapping);
     
    227227            {
    228228                var contentProvider = new WebInspector.StaticContentProvider(mimeType, formattedContent)
    229                 var uiSourceCode = new WebInspector.UISourceCode("deobfuscated:" + this.url, this.url, this.isContentScript, this, contentProvider);
     229                var uiSourceCode = this._createUISourceCode("deobfuscated:" + this.url, this.url, contentProvider);
    230230                var sourceMapping = new WebInspector.RawSourceCode.FormattedSourceMapping(this, uiSourceCode, mapping);
    231231                callback(sourceMapping);
     
    234234        }
    235235        originalContentProvider.requestContent(didRequestContent.bind(this));
     236    },
     237
     238    /**
     239     * @param {string} id
     240     * @param {string} url
     241     * @param {WebInspector.ContentProvider} contentProvider
     242     */
     243    _createUISourceCode: function(id, url, contentProvider)
     244    {
     245        var uiSourceCode = new WebInspector.UISourceCode(id, url, this, contentProvider);
     246        uiSourceCode.isContentScript = this.isContentScript;
     247        uiSourceCode.sourceMapURL = this.sourceMapURL;
     248        return uiSourceCode;
    236249    },
    237250
  • trunk/Source/WebCore/inspector/front-end/UISourceCode.js

    r102671 r103541  
    3434 * @param {string} id
    3535 * @param {string} url
    36  * @param {boolean} isContentScript
    3736 * @param {WebInspector.RawSourceCode} rawSourceCode
    3837 * @param {WebInspector.ContentProvider} contentProvider
    3938 */
    40 WebInspector.UISourceCode = function(id, url, isContentScript, rawSourceCode, contentProvider)
     39WebInspector.UISourceCode = function(id, url, rawSourceCode, contentProvider)
    4140{
    4241    this._id = id;
    4342    this._url = url;
    44     this._isContentScript = isContentScript;
    4543    this._rawSourceCode = rawSourceCode;
    4644    this._contentProvider = contentProvider;
     45    this.isContentScript = false;
     46    this.sourceMapURL = "";
    4747    /**
    4848     * @type Array.<function(string,string)>
     
    7070    {
    7171        return this._url;
    72     },
    73 
    74     /**
    75      * @return {boolean}
    76      */
    77     get isContentScript()
    78     {
    79         return this._isContentScript;
    8072    },
    8173
Note: See TracChangeset for help on using the changeset viewer.