Diff
Modified: trunk/LayoutTests/ChangeLog (130392 => 130393)
--- trunk/LayoutTests/ChangeLog 2012-10-04 15:31:42 UTC (rev 130392)
+++ trunk/LayoutTests/ChangeLog 2012-10-04 15:32:08 UTC (rev 130393)
@@ -1,3 +1,13 @@
+2012-10-04 Vsevolod Vlasov <[email protected]>
+
+ Web Inspector: When uiSourceCode content has diverged from VM script, call frames should be shown in temporary script based uiSourceCodes.
+ https://bugs.webkit.org/show_bug.cgi?id=98385
+
+ Reviewed by Pavel Feldman.
+
+ * inspector/debugger/dynamic-script-tag-expected.txt:
+ * inspector/debugger/resource-script-mapping-expected.txt:
+
2012-10-04 Ádám Kallai <[email protected]>
[Qt] Unreviewed gardening after r130385. Skip a failing test.
Modified: trunk/LayoutTests/inspector/debugger/dynamic-script-tag-expected.txt (130392 => 130393)
--- trunk/LayoutTests/inspector/debugger/dynamic-script-tag-expected.txt 2012-10-04 15:31:42 UTC (rev 130392)
+++ trunk/LayoutTests/inspector/debugger/dynamic-script-tag-expected.txt 2012-10-04 15:32:08 UTC (rev 130393)
@@ -10,12 +10,12 @@
Is inline script:false
Dumping uiSourceCodes:
UISourceCode:
-UISourceCode is editable: true
+UISourceCode is editable: false
UISourceCode is content script: false
Mime type: text/_javascript_
UISourceCode content: function foo() { }
UISourceCode:
-UISourceCode is editable: true
+UISourceCode is editable: false
UISourceCode is content script: false
Mime type: text/_javascript_
UISourceCode content: function bar() { }
Modified: trunk/LayoutTests/inspector/debugger/resource-script-mapping-expected.txt (130392 => 130393)
--- trunk/LayoutTests/inspector/debugger/resource-script-mapping-expected.txt 2012-10-04 15:31:42 UTC (rev 130392)
+++ trunk/LayoutTests/inspector/debugger/resource-script-mapping-expected.txt 2012-10-04 15:32:08 UTC (rev 130393)
@@ -4,7 +4,7 @@
Running: testScriptWithPendingResource
Adding script for pending request.
UISourceCode: foo.js
-UISourceCode is editable: true
+UISourceCode is editable: false
UISourceCode is content script: true
Mime type: text/_javascript_
UISourceCode content: <content script source>
Modified: trunk/Source/WebCore/ChangeLog (130392 => 130393)
--- trunk/Source/WebCore/ChangeLog 2012-10-04 15:31:42 UTC (rev 130392)
+++ trunk/Source/WebCore/ChangeLog 2012-10-04 15:32:08 UTC (rev 130393)
@@ -1,5 +1,46 @@
2012-10-04 Vsevolod Vlasov <[email protected]>
+ Web Inspector: When uiSourceCode content has diverged from VM script, call frames should be shown in temporary script based uiSourceCodes.
+ https://bugs.webkit.org/show_bug.cgi?id=98385
+
+ Reviewed by Pavel Feldman.
+
+ When _javascript_Source diverges from VM, ResourceScriptMapping now switches debugging
+ to temporary VM scripts based uiSourceCode with isDivergedReplacement property set.
+ Added hasDivergedFromVM and isDivergingFromVM properties to _javascript_Source.
+ _javascript_SourceFrame and ScriptSnippetsModel are updated to process breakpoint changes correctly.
+
+ * inspector/front-end/BreakpointManager.js:
+ (WebInspector.BreakpointManager.prototype.restoreBreakpoints):
+ (WebInspector.BreakpointManager.prototype._uiSourceCodeRemoved):
+ * inspector/front-end/_javascript_Source.js:
+ (WebInspector._javascript_Source.prototype.workingCopyCommitted):
+ (WebInspector._javascript_Source.prototype.workingCopyChanged):
+ (WebInspector._javascript_Source.prototype.fireHasDivergedFromVMChanged):
+ * inspector/front-end/_javascript_SourceFrame.js:
+ (WebInspector._javascript_SourceFrame.prototype.commitEditing):
+ (WebInspector._javascript_SourceFrame.prototype._hasDivergedFromVM):
+ (WebInspector._javascript_SourceFrame.prototype.onTextChanged):
+ (WebInspector._javascript_SourceFrame.prototype._getBreakpointDecorations):
+ (WebInspector._javascript_SourceFrame.prototype._muteBreakpointsWhileEditing):
+ (WebInspector._javascript_SourceFrame.prototype._didEditContent):
+ (WebInspector._javascript_SourceFrame.prototype._restoreBreakpointsAfterEditing):
+ (WebInspector._javascript_SourceFrame.prototype._addBreakpointDecoration):
+ * inspector/front-end/ResourceScriptMapping.js:
+ (WebInspector.ResourceScriptMapping.prototype.rawLocationToUILocation):
+ (WebInspector.ResourceScriptMapping.prototype._hasDivergedFromVMChanged):
+ (WebInspector.ResourceScriptMapping.prototype._bindUISourceCodeToScripts):
+ (WebInspector.ResourceScriptMapping.prototype._getOrCreateTemporaryUISourceCode):
+ * inspector/front-end/ScriptSnippetModel.js:
+ (WebInspector.ScriptSnippetModel.prototype._createUISourceCodeForScript):
+ (WebInspector.ScriptSnippetModel.prototype._restoreBreakpoints):
+ * inspector/front-end/ScriptsPanel.js:
+ (WebInspector.ScriptsPanel.prototype._revealExecutionLine):
+ * inspector/front-end/UISourceCode.js:
+ (WebInspector.UISourceCode.prototype.formatted):
+
+2012-10-04 Vsevolod Vlasov <[email protected]>
+
Web Inspector: Scripts panel should not automatically switch to snippet evaluation when previously evaluated snippet is edited.
https://bugs.webkit.org/show_bug.cgi?id=98402
Modified: trunk/Source/WebCore/inspector/front-end/BreakpointManager.js (130392 => 130393)
--- trunk/Source/WebCore/inspector/front-end/BreakpointManager.js 2012-10-04 15:31:42 UTC (rev 130392)
+++ trunk/Source/WebCore/inspector/front-end/BreakpointManager.js 2012-10-04 15:32:08 UTC (rev 130393)
@@ -86,6 +86,7 @@
continue;
this._debuggerModel.removeBreakpoint(debuggerId);
delete this._breakpointForDebuggerId[debuggerId];
+ delete breakpoint._debuggerId;
}
this._storage._restoreBreakpoints(uiSourceCode);
},
@@ -108,6 +109,8 @@
var uiSourceCode = /** @type {WebInspector.UISourceCode} */ event.data;
if (!(uiSourceCode instanceof WebInspector._javascript_Source))
return;
+ if (uiSourceCode.divergedVersion)
+ return;
var sourceFileId = WebInspector.BreakpointManager.breakpointStorageId(uiSourceCode);
if (!sourceFileId)
Modified: trunk/Source/WebCore/inspector/front-end/_javascript_Source.js (130392 => 130393)
--- trunk/Source/WebCore/inspector/front-end/_javascript_Source.js 2012-10-04 15:31:42 UTC (rev 130392)
+++ trunk/Source/WebCore/inspector/front-end/_javascript_Source.js 2012-10-04 15:32:08 UTC (rev 130393)
@@ -40,6 +40,10 @@
WebInspector.UISourceCode.call(this, url, contentProvider, isEditable);
}
+WebInspector._javascript_Source.Events = {
+ HasDivergedFromVMChanged: "HasDivergedFromVMChanged"
+}
+
WebInspector._javascript_Source.prototype = {
/**
* @param {function(?string)} callback
@@ -55,6 +59,7 @@
this.hasDivergedFromVM = true;
else
delete this.hasDivergedFromVM;
+ this.fireHasDivergedFromVMChanged();
callback(error);
}
@@ -64,8 +69,20 @@
return;
}
var script = WebInspector.debuggerModel.scriptForId(rawLocation.scriptId);
- WebInspector.debuggerModel.setScriptSource(script.scriptId, this.workingCopy(), innerCallback);
+ WebInspector.debuggerModel.setScriptSource(script.scriptId, this.workingCopy(), innerCallback.bind(this));
},
+ workingCopyChanged: function()
+ {
+ this.fireHasDivergedFromVMChanged();
+ },
+
+ fireHasDivergedFromVMChanged: function()
+ {
+ this.isDivergingFromVM = true;
+ this.dispatchEventToListeners(WebInspector._javascript_Source.Events.HasDivergedFromVMChanged, this);
+ delete this.isDivergingFromVM;
+ },
+
__proto__: WebInspector.UISourceCode.prototype
}
Modified: trunk/Source/WebCore/inspector/front-end/_javascript_SourceFrame.js (130392 => 130393)
--- trunk/Source/WebCore/inspector/front-end/_javascript_SourceFrame.js 2012-10-04 15:31:42 UTC (rev 130392)
+++ trunk/Source/WebCore/inspector/front-end/_javascript_SourceFrame.js 2012-10-04 15:32:08 UTC (rev 130393)
@@ -92,7 +92,8 @@
return;
this._isCommittingEditing = true;
- this._javaScriptSource.commitWorkingCopy(this._didEditContent.bind(this));
+ var breakpoints = this._getBreakpointDecorations();
+ this._javaScriptSource.commitWorkingCopy(this._didEditContent.bind(this, breakpoints));
delete this._isCommittingEditing;
},
@@ -149,65 +150,94 @@
contextMenu.appendApplicableItems(this._javaScriptSource);
},
+ _hasDivergedFromVM: function()
+ {
+ return this._javaScriptSource.isDirty() || this._javaScriptSource.hasDivergedFromVM;
+ },
+
onTextChanged: function(oldRange, newRange)
{
WebInspector.SourceFrame.prototype.onTextChanged.call(this, oldRange, newRange);
- this._removeBreakpointsBeforeEditing();
+
+ var wasDiverged = this._hasDivergedFromVM();
+
+ this._preserveDecorations = true;
this._javaScriptSource.setWorkingCopy(this._textEditor.text());
- this._restoreBreakpointsAfterEditing();
+ delete this._preserveDecorations;
+
+ if (this._supportsEnabledBreakpointsWhileEditing())
+ return;
+
+ var isDiverged = this._hasDivergedFromVM();
+ if (!wasDiverged && isDiverged)
+ this._muteBreakpointsWhileEditing();
+ else if (wasDiverged && !isDiverged) {
+ var breakpoints = this._getBreakpointDecorations();
+ this._restoreBreakpointsAfterEditing(breakpoints);
+ }
},
+ _getBreakpointDecorations: function()
+ {
+ var breakpoints = {};
+ // Restore all muted breakpoints.
+ for (var lineNumber = 0; lineNumber < this._textEditor.linesCount; ++lineNumber) {
+ var breakpointDecoration = this._textEditor.getAttribute(lineNumber, "breakpoint");
+ if (breakpointDecoration)
+ breakpoints[lineNumber] = breakpointDecoration;
+ }
+
+ return breakpoints;
+ },
+
+ _muteBreakpointsWhileEditing: function()
+ {
+ var breakpoints = this._getBreakpointDecorations();
+ for (var lineNumber = 0; lineNumber < this._textEditor.linesCount; ++lineNumber) {
+ var breakpointDecoration = this._textEditor.getAttribute(lineNumber, "breakpoint");
+ if (!breakpointDecoration)
+ continue;
+ this._removeBreakpointDecoration(lineNumber);
+ this._addBreakpointDecoration(lineNumber, breakpointDecoration.condition, breakpointDecoration.enabled, true);
+ }
+ },
+
_supportsEnabledBreakpointsWhileEditing: function()
{
return this._javaScriptSource.isSnippet;
},
- _didEditContent: function(error)
+ _didEditContent: function(breakpoints, error)
{
+ if (!this._supportsEnabledBreakpointsWhileEditing())
+ this._restoreBreakpointsAfterEditing(breakpoints);
+
if (error) {
WebInspector.showErrorMessage(error);
return;
}
- if (!this._supportsEnabledBreakpointsWhileEditing())
- this._restoreBreakpointsAfterEditing();
},
- _removeBreakpointsBeforeEditing: function()
+ _restoreBreakpointsAfterEditing: function(breakpoints)
{
- var supportsBreakpointsOnEdit = this._supportsEnabledBreakpointsWhileEditing();
- if (!this._javaScriptSource.isDirty() || supportsBreakpointsOnEdit) {
- // Disable all breakpoints in the model, store them as muted breakpoints.
- var breakpointLocations = this._breakpointManager.breakpointLocationsForUISourceCode(this._javaScriptSource);
- var lineNumbers = {};
- this._preserveDecorations = true;
- for (var i = 0; i < breakpointLocations.length; ++i) {
- var breakpoint = breakpointLocations[i].breakpoint;
- breakpointLocations[i].breakpoint.remove();
- }
- delete this._preserveDecorations;
-
- for (var lineNumber = 0; lineNumber < this._textEditor.linesCount; ++lineNumber) {
- var breakpointDecoration = this._textEditor.getAttribute(lineNumber, "breakpoint");
- if (breakpointDecoration)
- this._addBreakpointDecoration(lineNumber, breakpointDecoration.condition, breakpointDecoration.enabled, !supportsBreakpointsOnEdit);
- }
- this.clearExecutionLine();
+ var breakpointLocations = this._breakpointManager.breakpointLocationsForUISourceCode(this._javaScriptSource);
+ var lineNumbers = {};
+ for (var i = 0; i < breakpointLocations.length; ++i) {
+ var breakpoint = breakpointLocations[i].breakpoint;
+ breakpointLocations[i].breakpoint.remove();
}
- },
- _restoreBreakpointsAfterEditing: function()
- {
- if (!this._javaScriptSource.isDirty() || this._supportsEnabledBreakpointsWhileEditing()) {
- // Restore all muted breakpoints.
- for (var lineNumber = 0; lineNumber < this._textEditor.linesCount; ++lineNumber) {
- var breakpointDecoration = this._textEditor.getAttribute(lineNumber, "breakpoint");
- if (breakpointDecoration) {
- // Remove fake decoration
- this._removeBreakpointDecoration(lineNumber);
- // Set new breakpoint
- this._setBreakpoint(lineNumber, breakpointDecoration.condition, breakpointDecoration.enabled);
- }
- }
+ for (var lineNumber = 0; lineNumber < this._textEditor.linesCount; ++lineNumber)
+ this._removeBreakpointDecoration(lineNumber);
+
+ // Restore all muted breakpoints.
+ for (var lineNumberString in breakpoints) {
+ var lineNumber = parseInt(lineNumberString, 10);
+ if (isNaN(lineNumber))
+ continue;
+ var breakpointDecoration = breakpoints[lineNumberString];
+ // Set new breakpoint
+ this._setBreakpoint(lineNumber, breakpointDecoration.condition, breakpointDecoration.enabled);
}
},
@@ -336,13 +366,15 @@
*/
_addBreakpointDecoration: function(lineNumber, condition, enabled, mutedWhileEditing)
{
+ if (this._preserveDecorations)
+ return;
var breakpoint = {
condition: condition,
enabled: enabled
};
this.textEditor.setAttribute(lineNumber, "breakpoint", breakpoint);
- var disabled = !enabled || (mutedWhileEditing && !this._supportsEnabledBreakpointsWhileEditing());
+ var disabled = !enabled || mutedWhileEditing;
this.textEditor.addBreakpoint(lineNumber, disabled, !!condition);
},
Modified: trunk/Source/WebCore/inspector/front-end/ResourceScriptMapping.js (130392 => 130393)
--- trunk/Source/WebCore/inspector/front-end/ResourceScriptMapping.js 2012-10-04 15:31:42 UTC (rev 130392)
+++ trunk/Source/WebCore/inspector/front-end/ResourceScriptMapping.js 2012-10-04 15:32:08 UTC (rev 130393)
@@ -53,11 +53,30 @@
{
var debuggerModelLocation = /** @type {WebInspector.DebuggerModel.Location} */ rawLocation;
var script = WebInspector.debuggerModel.scriptForId(debuggerModelLocation.scriptId);
- var uiSourceCode = this._workspaceUISourceCodeForScript(script) || this._getOrCreateTemporaryUISourceCode(script);
+ var uiSourceCode = this._workspaceUISourceCodeForScript(script);
+ if (!uiSourceCode)
+ uiSourceCode = this._getOrCreateTemporaryUISourceCode(script);
+ else if (uiSourceCode.isDirty() || uiSourceCode.hasDivergedFromVM) {
+ var temporaryUISourceCode = this._getOrCreateTemporaryUISourceCode(script);
+ temporaryUISourceCode.divergedVersion = uiSourceCode;
+ uiSourceCode = temporaryUISourceCode;
+ }
console.assert(!!uiSourceCode);
return new WebInspector.UILocation(uiSourceCode, debuggerModelLocation.lineNumber, debuggerModelLocation.columnNumber || 0);
},
+ _hasDivergedFromVMChanged: function(event)
+ {
+ var uiSourceCode = /** @type {WebInspector.UISourceCode} */ event.data;
+ var scripts = this._scriptsForUISourceCode(uiSourceCode);
+ if (!scripts.length)
+ return;
+ for (var i = 0; i < scripts.length; ++i)
+ scripts[i].setSourceMapping(this);
+ if (!uiSourceCode.isDirty() && !uiSourceCode.hasDivergedFromVM)
+ this._deleteTemporaryUISourceCodeForScripts(scripts);
+ },
+
/**
* @param {WebInspector.Script} script
* @return {WebInspector.UISourceCode}
@@ -129,6 +148,9 @@
scripts[i].setSourceMapping(this);
uiSourceCode.isContentScript = scripts[0].isContentScript;
uiSourceCode.setSourceMapping(this);
+ if (!uiSourceCode.isTemporary)
+ uiSourceCode.addEventListener(WebInspector._javascript_Source.Events.HasDivergedFromVMChanged, this._hasDivergedFromVMChanged, this);
+
},
/**
@@ -172,7 +194,7 @@
var contentProvider = script.isInlineScript() ? new WebInspector.ConcatenatedScriptsContentProvider(scripts) : script;
var isDynamicScript = this._isDynamicScript(script);
var url = "" ? "" : script.sourceURL;
- temporaryUISourceCode = new WebInspector._javascript_Source(url, contentProvider, !script.isInlineScript());
+ temporaryUISourceCode = new WebInspector._javascript_Source(url, contentProvider, false);
temporaryUISourceCode.isTemporary = true;
for (var i = 0; i < scripts.length; ++i)
this._temporaryUISourceCodeForScriptId[scripts[i].scriptId] = temporaryUISourceCode;
Modified: trunk/Source/WebCore/inspector/front-end/ScriptSnippetModel.js (130392 => 130393)
--- trunk/Source/WebCore/inspector/front-end/ScriptSnippetModel.js 2012-10-04 15:31:42 UTC (rev 130392)
+++ trunk/Source/WebCore/inspector/front-end/ScriptSnippetModel.js 2012-10-04 15:32:08 UTC (rev 130393)
@@ -143,8 +143,10 @@
return;
var breakpointLocations = this._removeBreakpoints(snippetJavaScriptSource);
- this._releaseSnippetScript(snippetJavaScriptSource);
+ var uiSourceCode = this._releaseSnippetScript(snippetJavaScriptSource);
this._restoreBreakpoints(snippetJavaScriptSource, breakpointLocations);
+ if (uiSourceCode)
+ this._restoreBreakpoints(uiSourceCode, breakpointLocations);
},
/**
@@ -313,6 +315,7 @@
/**
* @param {WebInspector.Script} script
+ * @return {WebInspector.UISourceCode} uiSourceCode
*/
_createUISourceCodeForScript: function(script)
{
@@ -324,6 +327,7 @@
this._uiSourceCodeForScriptId[script.scriptId] = uiSourceCode;
this._scriptForUISourceCode.put(uiSourceCode, script);
script.setSourceMapping(this._snippetScriptMapping);
+ return uiSourceCode;
},
/**
@@ -339,34 +343,36 @@
},
/**
- * @param {WebInspector.SnippetJavaScriptSource} snippetJavaScriptSource
+ * @param {WebInspector.UISourceCode} uiSourceCode
* @param {Array.<Object>} breakpointLocations
*/
- _restoreBreakpoints: function(snippetJavaScriptSource, breakpointLocations)
+ _restoreBreakpoints: function(uiSourceCode, breakpointLocations)
{
for (var i = 0; i < breakpointLocations.length; ++i) {
var uiLocation = breakpointLocations[i].uiLocation;
var breakpoint = breakpointLocations[i].breakpoint;
- WebInspector.breakpointManager.setBreakpoint(uiLocation.uiSourceCode, uiLocation.lineNumber, breakpoint.condition(), breakpoint.enabled());
+ WebInspector.breakpointManager.setBreakpoint(uiSourceCode, uiLocation.lineNumber, breakpoint.condition(), breakpoint.enabled());
}
},
/**
* @param {WebInspector.SnippetJavaScriptSource} snippetJavaScriptSource
+ * @return {WebInspector.UISourceCode}
*/
_releaseSnippetScript: function(snippetJavaScriptSource)
{
var script = this._scriptForUISourceCode.get(snippetJavaScriptSource);
if (!script)
- return;
+ return null;
snippetJavaScriptSource.isDivergingFromVM = true;
snippetJavaScriptSource.hasDivergedFromVM = true;
delete this._uiSourceCodeForScriptId[script.scriptId];
this._scriptForUISourceCode.remove(snippetJavaScriptSource);
delete snippetJavaScriptSource._evaluationIndex;
- this._createUISourceCodeForScript(script);
+ var uiSourceCode = this._createUISourceCodeForScript(script);
delete snippetJavaScriptSource.isDivergingFromVM;
+ return uiSourceCode;
},
/**
Modified: trunk/Source/WebCore/inspector/front-end/ScriptsPanel.js (130392 => 130393)
--- trunk/Source/WebCore/inspector/front-end/ScriptsPanel.js 2012-10-04 15:31:42 UTC (rev 130392)
+++ trunk/Source/WebCore/inspector/front-end/ScriptsPanel.js 2012-10-04 15:32:08 UTC (rev 130393)
@@ -509,6 +509,8 @@
if (this._currentUISourceCode && this._currentUISourceCode.isDivergingFromVM)
return;
this._editorContainer.addUISourceCode(uiSourceCode);
+ if (uiSourceCode.formatted() !== this._toggleFormatSourceButton.toggled)
+ uiSourceCode.setFormatted(this._toggleFormatSourceButton.toggled, this._uiSourceCodeFormatted.bind(this, uiSourceCode));
}
var sourceFrame = this._showFile(uiSourceCode);
sourceFrame.revealLine(uiLocation.lineNumber);
Modified: trunk/Source/WebCore/inspector/front-end/UISourceCode.js (130392 => 130393)
--- trunk/Source/WebCore/inspector/front-end/UISourceCode.js 2012-10-04 15:31:42 UTC (rev 130392)
+++ trunk/Source/WebCore/inspector/front-end/UISourceCode.js 2012-10-04 15:32:08 UTC (rev 130393)
@@ -485,7 +485,7 @@
*/
formatted: function()
{
- return this._formatted;
+ return !!this._formatted;
},
/**