- Revision
- 199897
- Author
- [email protected]
- Date
- 2016-04-22 12:53:37 -0700 (Fri, 22 Apr 2016)
Log Message
Web Inspector: Debugger statement in console does not provide any call frames and debugger UI is confused
https://bugs.webkit.org/show_bug.cgi?id=156919
rdar://problem/25857118
This makes console expressions show up in the Debugger tab sidebar if a ScriptContentView is shown for them.
We now also show call frames that originate from a console _expression_, so the call frames in the sidebar is not empty.
Also fix a bug where when there are no call frames we auto resume the debugger and don't leave it in a broken state.
Reviewed by Joseph Pecoraro.
* Localizations/en.lproj/localizedStrings.js: Updated.
* UserInterface/Base/Utilities.js:
(appendWebInspectorSourceURL): Don't append if another sourceURL is already added.
(appendWebInspectorConsoleEvaluationSourceURL): Added.
(isWebInspectorConsoleEvaluationScript): Added.
(isWebKitInternalScript): Return false for isWebInspectorConsoleEvaluationScript().
* UserInterface/Controllers/DebuggerManager.js:
(WebInspector.DebuggerManager.prototype.debuggerDidPause): Resume if call frames is empty. This is not as common now
since console _expression_ call frames are not skipped.
(WebInspector.DebuggerManager.prototype.scriptDidParse): Change an early return for isWebInspectorInternalScript() that
was skipping adding internal scripts to the known script lists, but it should only do that when the debug UI is disabled.
* UserInterface/Controllers/_javascript_LogViewController.js:
(WebInspector._javascript_LogViewController.prototype.consolePromptTextCommitted):
Call appendWebInspectorConsoleEvaluationSourceURL so the console expressions are tagged before evaluateInInspectedWindow
added the internal sourceURL name.
* UserInterface/Models/Script.js:
(WebInspector.Script): Assign unique identifiers to console scripts so they are named correctly.
(WebInspector.Script.resetUniqueDisplayNameNumbers): Reset _nextUniqueConsoleDisplayNameNumber.
(WebInspector.Script.prototype.get displayName): Special case console expressions with a better name.
* UserInterface/Views/DebuggerSidebarPanel.js:
(WebInspector.DebuggerSidebarPanel.prototype.treeElementForRepresentedObject): Add a script tree element on demand
like the ResourceSidebarPanel does for anonymous scripts.
(WebInspector.DebuggerSidebarPanel.prototype._addScript): Return treeElement so treeElementForRepresentedObject can use it.
Modified Paths
Diff
Modified: trunk/Source/WebInspectorUI/ChangeLog (199896 => 199897)
--- trunk/Source/WebInspectorUI/ChangeLog 2016-04-22 19:44:08 UTC (rev 199896)
+++ trunk/Source/WebInspectorUI/ChangeLog 2016-04-22 19:53:37 UTC (rev 199897)
@@ -1,3 +1,45 @@
+2016-04-22 Timothy Hatcher <[email protected]>
+
+ Web Inspector: Debugger statement in console does not provide any call frames and debugger UI is confused
+
+ https://bugs.webkit.org/show_bug.cgi?id=156919
+ rdar://problem/25857118
+
+ This makes console expressions show up in the Debugger tab sidebar if a ScriptContentView is shown for them.
+ We now also show call frames that originate from a console _expression_, so the call frames in the sidebar is not empty.
+ Also fix a bug where when there are no call frames we auto resume the debugger and don't leave it in a broken state.
+
+ Reviewed by Joseph Pecoraro.
+
+ * Localizations/en.lproj/localizedStrings.js: Updated.
+
+ * UserInterface/Base/Utilities.js:
+ (appendWebInspectorSourceURL): Don't append if another sourceURL is already added.
+ (appendWebInspectorConsoleEvaluationSourceURL): Added.
+ (isWebInspectorConsoleEvaluationScript): Added.
+ (isWebKitInternalScript): Return false for isWebInspectorConsoleEvaluationScript().
+
+ * UserInterface/Controllers/DebuggerManager.js:
+ (WebInspector.DebuggerManager.prototype.debuggerDidPause): Resume if call frames is empty. This is not as common now
+ since console _expression_ call frames are not skipped.
+ (WebInspector.DebuggerManager.prototype.scriptDidParse): Change an early return for isWebInspectorInternalScript() that
+ was skipping adding internal scripts to the known script lists, but it should only do that when the debug UI is disabled.
+
+ * UserInterface/Controllers/_javascript_LogViewController.js:
+ (WebInspector._javascript_LogViewController.prototype.consolePromptTextCommitted):
+ Call appendWebInspectorConsoleEvaluationSourceURL so the console expressions are tagged before evaluateInInspectedWindow
+ added the internal sourceURL name.
+
+ * UserInterface/Models/Script.js:
+ (WebInspector.Script): Assign unique identifiers to console scripts so they are named correctly.
+ (WebInspector.Script.resetUniqueDisplayNameNumbers): Reset _nextUniqueConsoleDisplayNameNumber.
+ (WebInspector.Script.prototype.get displayName): Special case console expressions with a better name.
+
+ * UserInterface/Views/DebuggerSidebarPanel.js:
+ (WebInspector.DebuggerSidebarPanel.prototype.treeElementForRepresentedObject): Add a script tree element on demand
+ like the ResourceSidebarPanel does for anonymous scripts.
+ (WebInspector.DebuggerSidebarPanel.prototype._addScript): Return treeElement so treeElementForRepresentedObject can use it.
+
2016-04-21 Joseph Pecoraro <[email protected]>
Web Inspector: sourceMappingURL not loaded in generated script
Modified: trunk/Source/WebInspectorUI/Localizations/en.lproj/localizedStrings.js (199896 => 199897)
--- trunk/Source/WebInspectorUI/Localizations/en.lproj/localizedStrings.js 2016-04-22 19:44:08 UTC (rev 199896)
+++ trunk/Source/WebInspectorUI/Localizations/en.lproj/localizedStrings.js 2016-04-22 19:53:37 UTC (rev 199897)
@@ -181,6 +181,7 @@
localizedStrings["Condition"] = "Condition";
localizedStrings["Conditional _expression_"] = "Conditional _expression_";
localizedStrings["Console"] = "Console";
+localizedStrings["Console Evaluation %d"] = "Console Evaluation %d";
localizedStrings["Console Profile Recorded"] = "Console Profile Recorded";
localizedStrings["Console errors, click to show the Console tab"] = "Console errors, click to show the Console tab";
localizedStrings["Console logs, click to show the Console tab"] = "Console logs, click to show the Console tab";
Modified: trunk/Source/WebInspectorUI/UserInterface/Base/Utilities.js (199896 => 199897)
--- trunk/Source/WebInspectorUI/UserInterface/Base/Utilities.js 2016-04-22 19:44:08 UTC (rev 199896)
+++ trunk/Source/WebInspectorUI/UserInterface/Base/Utilities.js 2016-04-22 19:53:37 UTC (rev 199897)
@@ -1256,16 +1256,32 @@
function appendWebInspectorSourceURL(string)
{
+ if (string.includes("//# sourceURL"))
+ return string;
return "\n//# sourceURL=__WebInspectorInternal__\n" + string;
}
+function appendWebInspectorConsoleEvaluationSourceURL(string)
+{
+ if (string.includes("//# sourceURL"))
+ return string;
+ return "\n//# sourceURL=__WebInspectorConsoleEvaluation__\n" + string;
+}
+
function isWebInspectorInternalScript(url)
{
return url ="" "__WebInspectorInternal__";
}
+function isWebInspectorConsoleEvaluationScript(url)
+{
+ return url ="" "__WebInspectorConsoleEvaluation__";
+}
+
function isWebKitInternalScript(url)
{
+ if (isWebInspectorConsoleEvaluationScript(url))
+ return false;
return url && url.startsWith("__Web") && url.endsWith("__");
}
Modified: trunk/Source/WebInspectorUI/UserInterface/Controllers/DebuggerManager.js (199896 => 199897)
--- trunk/Source/WebInspectorUI/UserInterface/Controllers/DebuggerManager.js 2016-04-22 19:44:08 UTC (rev 199896)
+++ trunk/Source/WebInspectorUI/UserInterface/Controllers/DebuggerManager.js 2016-04-22 19:53:37 UTC (rev 199897)
@@ -545,6 +545,12 @@
this._activeCallFrame = this._callFrames[0];
+ if (!this._activeCallFrame) {
+ console.assert("We should always have one call frame. This could indicate we are hitting an exception or debugger statement in an internal injected script.");
+ this._didResumeInternal();
+ return;
+ }
+
if (!wasStillPaused)
this.dispatchEventToListeners(WebInspector.DebuggerManager.Event.Paused);
this.dispatchEventToListeners(WebInspector.DebuggerManager.Event.CallFramesDidChange);
@@ -578,7 +584,7 @@
return;
}
- if (isWebInspectorInternalScript(sourceURL))
+ if (!WebInspector.isDebugUIEnabled() && isWebKitInternalScript(sourceURL))
return;
let script = new WebInspector.Script(scriptIdentifier, new WebInspector.TextRange(startLine, startColumn, endLine, endColumn), url, isContentScript, sourceURL, sourceMapURL);
@@ -600,6 +606,10 @@
return;
}
+ // Console expressions are not added to the UI by default.
+ if (isWebInspectorConsoleEvaluationScript(script.sourceURL))
+ return;
+
this.dispatchEventToListeners(WebInspector.DebuggerManager.Event.ScriptAdded, {script});
}
Modified: trunk/Source/WebInspectorUI/UserInterface/Controllers/_javascript_LogViewController.js (199896 => 199897)
--- trunk/Source/WebInspectorUI/UserInterface/Controllers/_javascript_LogViewController.js 2016-04-22 19:44:08 UTC (rev 199896)
+++ trunk/Source/WebInspectorUI/UserInterface/Controllers/_javascript_LogViewController.js 2016-04-22 19:53:37 UTC (rev 199897)
@@ -228,6 +228,8 @@
this._appendConsoleMessageView(commandResultMessageView, true);
}
+ text = appendWebInspectorConsoleEvaluationSourceURL(text);
+
WebInspector.runtimeManager.evaluateInInspectedWindow(text, WebInspector.RuntimeManager.ConsoleObjectGroup, true, false, false, true, true, printResult.bind(this));
}
Modified: trunk/Source/WebInspectorUI/UserInterface/Models/Script.js (199896 => 199897)
--- trunk/Source/WebInspectorUI/UserInterface/Models/Script.js 2016-04-22 19:44:08 UTC (rev 199896)
+++ trunk/Source/WebInspectorUI/UserInterface/Models/Script.js 2016-04-22 19:53:37 UTC (rev 199897)
@@ -45,6 +45,11 @@
if (sourceMapURL)
WebInspector.sourceMapManager.downloadSourceMap(sourceMapURL, this._url, this);
+ if (isWebInspectorConsoleEvaluationScript(this._sourceURL)) {
+ // Assign a unique number to the script object so it will stay the same.
+ this._uniqueDisplayNameNumber = this.constructor._nextUniqueConsoleDisplayNameNumber++;
+ }
+
this._scriptSyntaxTree = null;
}
@@ -53,6 +58,7 @@
static resetUniqueDisplayNameNumbers()
{
WebInspector.Script._nextUniqueDisplayNameNumber = 1;
+ WebInspector.Script._nextUniqueConsoleDisplayNameNumber = 1;
}
// Public
@@ -94,6 +100,11 @@
if (this._url)
return WebInspector.displayNameForURL(this._url, this.urlComponents);
+ if (isWebInspectorConsoleEvaluationScript(this._sourceURL)) {
+ console.assert(this._uniqueDisplayNameNumber);
+ return WebInspector.UIString("Console Evaluation %d").format(this._uniqueDisplayNameNumber);
+ }
+
if (this._sourceURL) {
if (!this._sourceURLComponents)
this._sourceURLComponents = parseURL(this._sourceURL);
@@ -247,3 +258,4 @@
WebInspector.Script.DisplayNameCookieKey = "script-display-name";
WebInspector.Script._nextUniqueDisplayNameNumber = 1;
+WebInspector.Script._nextUniqueConsoleDisplayNameNumber = 1;
Modified: trunk/Source/WebInspectorUI/UserInterface/Views/DebuggerSidebarPanel.js (199896 => 199897)
--- trunk/Source/WebInspectorUI/UserInterface/Views/DebuggerSidebarPanel.js 2016-04-22 19:44:08 UTC (rev 199896)
+++ trunk/Source/WebInspectorUI/UserInterface/Views/DebuggerSidebarPanel.js 2016-04-22 19:53:37 UTC (rev 199897)
@@ -208,7 +208,27 @@
if (representedObject instanceof WebInspector.Frame)
representedObject = representedObject.mainResource;
- return this.contentTreeOutline.getCachedTreeElement(representedObject);
+ let treeElement = this.contentTreeOutline.findTreeElement(representedObject);
+ if (treeElement)
+ return treeElement;
+
+ // Only special case Script objects.
+ if (!(representedObject instanceof WebInspector.Script)) {
+ console.error("Didn't find a TreeElement for representedObject", representedObject);
+ return null;
+ }
+
+ // If the Script has a URL we should have found it earlier.
+ if (representedObject.url) {
+ console.error("Didn't find a ScriptTreeElement for a Script with a URL.");
+ return null;
+ }
+
+ // Since the Script does not have a URL we consider it an 'anonymous' script. These scripts happen from calls to
+ // window.eval() or browser features like Auto Fill and Reader. They are not normally added to the sidebar, but since
+ // we have a ScriptContentView asking for the tree element we will make a ScriptTreeElement on demand and add it.
+
+ return this._addScript(representedObject);
}
// Protected
@@ -429,12 +449,12 @@
{
// COMPATIBILITY(iOS 9): Backends could send the frontend built-in code, filter out JSC internals.
if (!script.url && !script.sourceURL)
- return;
+ return null;
// Don't add breakpoints if the script is represented by a Resource. They were
// already added by _resourceAdded.
if (script.resource)
- return;
+ return null;
let treeElement = this._addTreeElementForSourceCodeToContentTreeOutline(script);
this._addBreakpointsForSourceCode(script);
@@ -442,6 +462,8 @@
if (!this.contentBrowser.currentContentView)
this.showDefaultContentViewForTreeElement(treeElement);
+
+ return treeElement;
}
_scriptRemoved(event)