Changeset 147102 in webkit
- Timestamp:
- Mar 28, 2013 6:06:25 AM (11 years ago)
- Location:
- trunk
- Files:
-
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r147101 r147102 1 2013-03-28 Vsevolod Vlasov <vsevik@chromium.org> 2 3 Web Inspector: ResourceScriptFile should check if resource content really matches VM script when determining hasDiverged state. 4 https://bugs.webkit.org/show_bug.cgi?id=113488 5 6 Reviewed by Pavel Feldman. 7 8 * http/tests/inspector/debugger-test.js: 9 * inspector/debugger/file-system-project-mapping-expected.txt: 10 * inspector/debugger/file-system-project-mapping.html: 11 1 12 2013-03-28 Ádám Kallai <kadam@inf.u-szeged.hu> 2 13 -
trunk/LayoutTests/http/tests/inspector/debugger-test.js
r144467 r147102 285 285 var endLine = startLine + lineCount - 1; 286 286 var endColumn = lineCount === 1 ? startColumn + source.length : source.length - source.lineEndings()[lineCount - 2]; 287 var script = new WebInspector.Script(scriptId, url, startLine, startColumn, endLine, endColumn, isContentScript); 287 var hasSourceURL = !!source.match(/\/\/@\ssourceURL=\s*(\S*?)\s*$/m); 288 var script = new WebInspector.Script(scriptId, url, startLine, startColumn, endLine, endColumn, isContentScript, null, hasSourceURL); 288 289 script.requestContent = function(callback) { callback(source, false, "text/javascript"); }; 289 290 WebInspector.debuggerModel._registerScript(script); -
trunk/LayoutTests/inspector/debugger/file-system-project-mapping-expected.txt
r145539 r147102 21 21 Running: testScriptFileOnReloadWithDirtyFile 22 22 Adding file system. 23 Dumping uiSourceCode and script content: 24 uiSourceCode: <foo content> 25 script: <foo content> 26 //@ sourceURL=http://localhost/html/foo.js 27 23 28 - hasDivergedFromVM: false 24 29 Editing uiSourceCode: 25 30 - hasDivergedFromVM: true 26 31 Committing uiSourceCode with live edit failure: 32 Dumping uiSourceCode and script content: 33 uiSourceCode: <foo content edited> 34 script: <foo content> 35 //@ sourceURL=http://localhost/html/foo.js 36 37 - hasDivergedFromVM: true 38 Reloading with saved but diverged uiSourceCode: 39 Dumping uiSourceCode and script content: 40 uiSourceCode: <foo content edited> 41 script: <foo content> 42 //@ sourceURL=http://localhost/html/foo.js 43 27 44 - hasDivergedFromVM: true 28 45 Editing uiSourceCode again: 29 46 - hasDivergedFromVM: true 30 47 Committing uiSourceCode again (with live edit success now): 48 Dumping uiSourceCode and script content: 49 uiSourceCode: <foo content edited again> 50 script: <foo content edited again> 51 //@ sourceURL=http://localhost/html/foo.js 31 52 - hasDivergedFromVM: false 32 53 Reloading page: -
trunk/LayoutTests/inspector/debugger/file-system-project-mapping.html
r145539 r147102 91 91 function testScriptFileOnReloadWithDirtyFile(next) 92 92 { 93 var originalFileContent = "<foo content>"; 94 var scriptURL = "http://localhost/html/foo.js"; 95 var scriptContent = originalFileContent + "\n //@ sourceURL=" + scriptURL + " \n "; 93 96 function uiSourceCodeAdded(uiSourceCode) { } 94 97 … … 97 100 resourceScriptMapping._debuggerReset(); 98 101 defaultScriptMapping._debuggerReset(); 99 script = InspectorTest.createScriptMock( "http://localhost/html/foo.js", 0, 0, false, "<foo content>");102 script = InspectorTest.createScriptMock(scriptURL, 0, 0, false, scriptContent); 100 103 InspectorTest.waitForWorkspaceUISourceCodeAddedEvent(uiSourceCodeAdded, 1); 101 104 defaultScriptMapping.addScript(script); … … 105 108 var fileSystemPath = "/var/www"; 106 109 var fileSystemProjectId = WebInspector.FileSystemProjectDelegate.projectId(fileSystemPath); 107 var files = {"/html/foo.js": "<foo content>", "/bar.js": "<bar content>"};110 var files = {"/html/foo.js": originalFileContent, "/bar.js": "<bar content>"}; 108 111 createObjects(); 109 112 var entry1 = new WebInspector.FileMapping.Entry("http://localhost/", "/var/www/"); … … 116 119 117 120 var uiSourceCode = InspectorTest.testWorkspace.uiSourceCode(fileSystemProjectId, ["html", "foo.js"]); 118 InspectorTest.addResult(" - hasDivergedFromVM: " + !!uiSourceCode.scriptFile().hasDivergedFromVM()); 119 InspectorTest.addResult("Editing uiSourceCode:"); 120 uiSourceCode.setWorkingCopy("<foo content edited>"); 121 InspectorTest.addResult(" - hasDivergedFromVM: " + !!uiSourceCode.scriptFile().hasDivergedFromVM()); 121 InspectorTest.showUISourceCode(uiSourceCode, didShowScriptSource); 122 122 123 function setScriptSourceOverrideFailure(scriptId, newContent, callback)123 function dumpUISourceCodeAndScriptContents() 124 124 { 125 callback("error"); 125 InspectorTest.addResult("Dumping uiSourceCode and script content:"); 126 InspectorTest.addResult(" uiSourceCode: " + uiSourceCode.workingCopy()); 127 InspectorTest.addResult(" script: " + scriptContent); 126 128 } 127 InspectorTest.override(WebInspector.debuggerModel, "setScriptSource", setScriptSourceOverrideFailure);128 InspectorTest.addResult("Committing uiSourceCode with live edit failure:");129 uiSourceCode.commitWorkingCopy(function() { });130 InspectorTest.addResult(" - hasDivergedFromVM: " + !!uiSourceCode.scriptFile().hasDivergedFromVM());131 129 132 InspectorTest.addResult("Editing uiSourceCode again:"); 133 uiSourceCode.setWorkingCopy("<foo content edited again>"); 134 InspectorTest.addResult(" - hasDivergedFromVM: " + !!uiSourceCode.scriptFile().hasDivergedFromVM()); 130 function didShowScriptSource(sourceFrame) 131 { 132 dumpUISourceCodeAndScriptContents(); 133 InspectorTest.addResult(" - hasDivergedFromVM: " + !!uiSourceCode.scriptFile().hasDivergedFromVM()); 135 134 136 function setScriptSourceOverrideSuccess(scriptId, newContent, callback) 137 { 138 callback(); 135 InspectorTest.addResult("Editing uiSourceCode:"); 136 uiSourceCode.setWorkingCopy("<foo content edited>"); 137 InspectorTest.addResult(" - hasDivergedFromVM: " + !!uiSourceCode.scriptFile().hasDivergedFromVM()); 138 139 function setScriptSourceOverrideFailure(scriptId, newContent, callback) 140 { 141 callback("error"); 142 } 143 InspectorTest.override(WebInspector.debuggerModel, "setScriptSource", setScriptSourceOverrideFailure); 144 145 InspectorTest.addResult("Committing uiSourceCode with live edit failure:"); 146 uiSourceCode.commitWorkingCopy(function() { }); 147 dumpUISourceCodeAndScriptContents(); 148 InspectorTest.addResult(" - hasDivergedFromVM: " + !!uiSourceCode.scriptFile().hasDivergedFromVM()); 149 150 InspectorTest.addResult("Reloading with saved but diverged uiSourceCode:"); 151 reload(); 152 dumpUISourceCodeAndScriptContents(); 153 InspectorTest.addResult(" - hasDivergedFromVM: " + !!uiSourceCode.scriptFile().hasDivergedFromVM()); 154 155 InspectorTest.addResult("Editing uiSourceCode again:"); 156 uiSourceCode.setWorkingCopy("<foo content edited again>"); 157 InspectorTest.addResult(" - hasDivergedFromVM: " + !!uiSourceCode.scriptFile().hasDivergedFromVM()); 158 159 function setScriptSourceOverrideSuccess(scriptId, newContent, callback) 160 { 161 scriptContent = newContent; 162 callback(); 163 } 164 InspectorTest.override(WebInspector.debuggerModel, "setScriptSource", setScriptSourceOverrideSuccess); 165 166 InspectorTest.addResult("Committing uiSourceCode again (with live edit success now):"); 167 uiSourceCode.commitWorkingCopy(function() { }); 168 dumpUISourceCodeAndScriptContents(); 169 InspectorTest.addResult(" - hasDivergedFromVM: " + !!uiSourceCode.scriptFile().hasDivergedFromVM()); 170 171 InspectorTest.addResult("Reloading page:"); 172 reload(); 173 InspectorTest.addResult(" - hasDivergedFromVM: " + !!uiSourceCode.scriptFile().hasDivergedFromVM()); 174 175 InspectorTest.addResult("Editing uiSourceCode again and reloading while it is dirty:"); 176 uiSourceCode.setWorkingCopy("<foo content edited and dirty>"); 177 reload(); 178 InspectorTest.addResult(" - hasDivergedFromVM: " + !!uiSourceCode.scriptFile().hasDivergedFromVM()); 179 next(); 139 180 } 140 InspectorTest.override(WebInspector.debuggerModel, "setScriptSource", setScriptSourceOverrideSuccess);141 InspectorTest.addResult("Committing uiSourceCode again (with live edit success now):");142 uiSourceCode.commitWorkingCopy(function() { });143 InspectorTest.addResult(" - hasDivergedFromVM: " + !!uiSourceCode.scriptFile().hasDivergedFromVM());144 145 InspectorTest.addResult("Reloading page:");146 reload();147 InspectorTest.addResult(" - hasDivergedFromVM: " + !!uiSourceCode.scriptFile().hasDivergedFromVM());148 149 InspectorTest.addResult("Editing uiSourceCode again and reloading while it is dirty:");150 uiSourceCode.setWorkingCopy("<foo content edited and dirty>");151 reload();152 InspectorTest.addResult(" - hasDivergedFromVM: " + !!uiSourceCode.scriptFile().hasDivergedFromVM());153 next();154 181 } 155 182 ]); -
trunk/Source/WebCore/ChangeLog
r147099 r147102 1 2013-03-28 Vsevolod Vlasov <vsevik@chromium.org> 2 3 Web Inspector: ResourceScriptFile should check if resource content really matches VM script when determining hasDiverged state. 4 https://bugs.webkit.org/show_bug.cgi?id=113488 5 6 Reviewed by Pavel Feldman. 7 8 Enabled support for checking that file content matches VM script in ResourceScriptFile (For script resources only). 9 This check is never done before content is loaded in corresponding editor to avoid regressing performance. 10 File - script content matching is done bearing in mind sourceURLs. 11 Live edit keeps sourceURL in script content now even if it is not present in file's content. 12 13 * inspector/front-end/JavaScriptSourceFrame.js: 14 (WebInspector.JavaScriptSourceFrame.prototype._updateScriptFile): 15 (WebInspector.JavaScriptSourceFrame.prototype.onTextEditorContentLoaded): 16 * inspector/front-end/LiveEditSupport.js: 17 (WebInspector.LiveEditScriptFile.prototype.checkMapping): 18 * inspector/front-end/ResourceScriptMapping.js: 19 (WebInspector.ResourceScriptMapping.prototype._bindUISourceCodeToScripts): 20 (WebInspector.ScriptFile.prototype.checkMapping): 21 (WebInspector.ResourceScriptFile): 22 (WebInspector.ResourceScriptFile.prototype._workingCopyCommitted): 23 (WebInspector.ResourceScriptFile.prototype._isDiverged): 24 (WebInspector.ResourceScriptFile.prototype._sourceMatchesScriptSource): 25 (WebInspector.ResourceScriptFile.prototype._sourceEndsWithSourceURL): 26 (WebInspector.ResourceScriptFile.prototype.checkMapping.callback): 27 (WebInspector.ResourceScriptFile.prototype.checkMapping): 28 * inspector/front-end/ScriptSnippetModel.js: 29 (WebInspector.SnippetScriptFile.prototype.checkMapping): 30 1 31 2013-03-28 Vsevolod Vlasov <vsevik@chromium.org> 2 32 -
trunk/Source/WebCore/inspector/front-end/JavaScriptSourceFrame.js
r147099 r147102 492 492 this._scriptFile.addEventListener(WebInspector.ScriptFile.Events.DidMergeToVM, this._didMergeToVM, this); 493 493 this._scriptFile.addEventListener(WebInspector.ScriptFile.Events.DidDivergeFromVM, this._didDivergeFromVM, this); 494 495 if (this.loaded) 496 this._scriptFile.checkMapping(); 494 497 } 495 498 }, … … 509 512 this.addMessageToSource(message.lineNumber, message.originalMessage); 510 513 } 514 515 if (this._scriptFile) 516 this._scriptFile.checkMapping(); 511 517 }, 512 518 -
trunk/Source/WebCore/inspector/front-end/LiveEditSupport.js
r147099 r147102 135 135 }, 136 136 137 checkMapping: function() 138 { 139 }, 140 137 141 __proto__: WebInspector.Object.prototype 138 142 } -
trunk/Source/WebCore/inspector/front-end/ResourceScriptMapping.js
r147099 r147102 183 183 { 184 184 console.assert(scripts.length); 185 var scriptFile = new WebInspector.ResourceScriptFile(this, uiSourceCode );185 var scriptFile = new WebInspector.ResourceScriptFile(this, uiSourceCode, scripts); 186 186 uiSourceCode.setScriptFile(scriptFile); 187 187 for (var i = 0; i < scripts.length; ++i) … … 263 263 */ 264 264 isMergingToVM: function() { return false; }, 265 266 checkMapping: function() { }, 265 267 } 266 268 … … 272 274 * @param {WebInspector.UISourceCode} uiSourceCode 273 275 */ 274 WebInspector.ResourceScriptFile = function(resourceScriptMapping, uiSourceCode )276 WebInspector.ResourceScriptFile = function(resourceScriptMapping, uiSourceCode, scripts) 275 277 { 278 console.assert(scripts.length); 279 276 280 WebInspector.ScriptFile.call(this); 277 281 this._resourceScriptMapping = resourceScriptMapping; 278 282 this._uiSourceCode = uiSourceCode; 283 284 if (this._uiSourceCode.contentType() === WebInspector.resourceTypes.Script) 285 this._script = scripts[0]; 279 286 280 287 this._uiSourceCode.addEventListener(WebInspector.UISourceCode.Events.WorkingCopyCommitted, this._workingCopyCommitted, this); … … 292 299 { 293 300 if (error) { 294 this._ lastLiveEditFailed = true;301 this._update(); 295 302 WebInspector.showErrorMessage(error); 296 303 return; 297 304 } 298 299 delete this._lastLiveEditFailed;300 this._ mergeToVM();305 306 this._scriptSource = source; 307 this._update(); 301 308 } 302 303 var rawLocation = /** @type {WebInspector.DebuggerModel.Location} */ (this._uiSourceCode.uiLocationToRawLocation(0, 0)); 304 if (!rawLocation) 305 return; 306 var script = WebInspector.debuggerModel.scriptForId(rawLocation.scriptId); 307 WebInspector.debuggerModel.setScriptSource(script.scriptId, this._uiSourceCode.workingCopy(), innerCallback.bind(this)); 308 }, 309 309 if (!this._script) 310 return; 311 var source = this._uiSourceCode.workingCopy(); 312 if (this._script.hasSourceURL && !this._sourceEndsWithSourceURL(source)) 313 source += "\n //@ sourceURL=" + this._script.sourceURL; 314 WebInspector.debuggerModel.setScriptSource(this._script.scriptId, source, innerCallback.bind(this)); 315 }, 316 317 /** 318 * @return {boolean} 319 */ 310 320 _isDiverged: function() 311 321 { 312 322 if (this._uiSourceCode.isDirty()) 313 323 return true; 314 return this._lastLiveEditFailed; 315 }, 316 324 if (!this._script) 325 return false; 326 if (typeof this._scriptSource === "undefined") 327 return false; 328 return !this._sourceMatchesScriptSource(this._uiSourceCode.workingCopy(), this._scriptSource); 329 }, 330 331 /** 332 * @param {string} source 333 * @param {string} scriptSource 334 * @return {boolean} 335 */ 336 _sourceMatchesScriptSource: function(source, scriptSource) 337 { 338 if (!scriptSource.startsWith(source)) 339 return false; 340 var scriptSourceTail = scriptSource.substr(source.length).trim(); 341 return !scriptSourceTail || !!scriptSourceTail.match(/^\/\/@\ssourceURL=\s*(\S*?)\s*$/m); 342 }, 343 344 /** 345 * @param {string} source 346 * @return {boolean} 347 */ 348 _sourceEndsWithSourceURL: function(source) 349 { 350 return !!source.match(/\/\/@\ssourceURL=\s*(\S*?)\s*$/m); 351 }, 352 353 /** 354 * @param {WebInspector.Event} event 355 */ 317 356 _workingCopyChanged: function(event) 318 357 { … … 370 409 }, 371 410 411 checkMapping: function() 412 { 413 if (!this._script) 414 return; 415 if (typeof this._scriptSource !== "undefined") 416 return; 417 this._script.requestContent(callback.bind(this)); 418 419 /** 420 * @param {?string} source 421 * @param {boolean} encoded 422 * @param {string} contentType 423 */ 424 function callback(source, encoded, contentType) 425 { 426 this._scriptSource = source; 427 this._update(); 428 } 429 }, 430 372 431 dispose: function() 373 432 { -
trunk/Source/WebCore/inspector/front-end/ScriptSnippetModel.js
r147099 r147102 434 434 }, 435 435 436 checkMapping: function() 437 { 438 }, 439 436 440 /** 437 441 * @return {boolean}
Note: See TracChangeset
for help on using the changeset viewer.