<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[199897] trunk/Source/WebInspectorUI</title>
</head>
<body>
<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; }
#msg dl a { font-weight: bold}
#msg dl a:link { color:#fc3; }
#msg dl a:active { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://trac.webkit.org/projects/webkit/changeset/199897">199897</a></dd>
<dt>Author</dt> <dd>timothy@apple.com</dd>
<dt>Date</dt> <dd>2016-04-22 12:53:37 -0700 (Fri, 22 Apr 2016)</dd>
</dl>
<h3>Log Message</h3>
<pre>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/JavaScriptLogViewController.js:
(WebInspector.JavaScriptLogViewController.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.</pre>
<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkSourceWebInspectorUIChangeLog">trunk/Source/WebInspectorUI/ChangeLog</a></li>
<li><a href="#trunkSourceWebInspectorUILocalizationsenlprojlocalizedStringsjs">trunk/Source/WebInspectorUI/Localizations/en.lproj/localizedStrings.js</a></li>
<li><a href="#trunkSourceWebInspectorUIUserInterfaceBaseUtilitiesjs">trunk/Source/WebInspectorUI/UserInterface/Base/Utilities.js</a></li>
<li><a href="#trunkSourceWebInspectorUIUserInterfaceControllersDebuggerManagerjs">trunk/Source/WebInspectorUI/UserInterface/Controllers/DebuggerManager.js</a></li>
<li><a href="#trunkSourceWebInspectorUIUserInterfaceControllersJavaScriptLogViewControllerjs">trunk/Source/WebInspectorUI/UserInterface/Controllers/JavaScriptLogViewController.js</a></li>
<li><a href="#trunkSourceWebInspectorUIUserInterfaceModelsScriptjs">trunk/Source/WebInspectorUI/UserInterface/Models/Script.js</a></li>
<li><a href="#trunkSourceWebInspectorUIUserInterfaceViewsDebuggerSidebarPaneljs">trunk/Source/WebInspectorUI/UserInterface/Views/DebuggerSidebarPanel.js</a></li>
</ul>
</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkSourceWebInspectorUIChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebInspectorUI/ChangeLog (199896 => 199897)</h4>
<pre class="diff"><span>
<span class="info">--- 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)
</span><span class="lines">@@ -1,3 +1,45 @@
</span><ins>+2016-04-22 Timothy Hatcher <timothy@apple.com>
+
+ 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/JavaScriptLogViewController.js:
+ (WebInspector.JavaScriptLogViewController.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.
+
</ins><span class="cx"> 2016-04-21 Joseph Pecoraro <pecoraro@apple.com>
</span><span class="cx">
</span><span class="cx"> Web Inspector: sourceMappingURL not loaded in generated script
</span></span></pre></div>
<a id="trunkSourceWebInspectorUILocalizationsenlprojlocalizedStringsjs"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebInspectorUI/Localizations/en.lproj/localizedStrings.js (199896 => 199897)</h4>
<pre class="diff"><span>
<span class="info">--- 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)
</span><span class="lines">@@ -181,6 +181,7 @@
</span><span class="cx"> localizedStrings["Condition"] = "Condition";
</span><span class="cx"> localizedStrings["Conditional expression"] = "Conditional expression";
</span><span class="cx"> localizedStrings["Console"] = "Console";
</span><ins>+localizedStrings["Console Evaluation %d"] = "Console Evaluation %d";
</ins><span class="cx"> localizedStrings["Console Profile Recorded"] = "Console Profile Recorded";
</span><span class="cx"> localizedStrings["Console errors, click to show the Console tab"] = "Console errors, click to show the Console tab";
</span><span class="cx"> localizedStrings["Console logs, click to show the Console tab"] = "Console logs, click to show the Console tab";
</span></span></pre></div>
<a id="trunkSourceWebInspectorUIUserInterfaceBaseUtilitiesjs"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebInspectorUI/UserInterface/Base/Utilities.js (199896 => 199897)</h4>
<pre class="diff"><span>
<span class="info">--- 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)
</span><span class="lines">@@ -1256,16 +1256,32 @@
</span><span class="cx">
</span><span class="cx"> function appendWebInspectorSourceURL(string)
</span><span class="cx"> {
</span><ins>+ if (string.includes("//# sourceURL"))
+ return string;
</ins><span class="cx"> return "\n//# sourceURL=__WebInspectorInternal__\n" + string;
</span><span class="cx"> }
</span><span class="cx">
</span><ins>+function appendWebInspectorConsoleEvaluationSourceURL(string)
+{
+ if (string.includes("//# sourceURL"))
+ return string;
+ return "\n//# sourceURL=__WebInspectorConsoleEvaluation__\n" + string;
+}
+
</ins><span class="cx"> function isWebInspectorInternalScript(url)
</span><span class="cx"> {
</span><span class="cx"> return url === "__WebInspectorInternal__";
</span><span class="cx"> }
</span><span class="cx">
</span><ins>+function isWebInspectorConsoleEvaluationScript(url)
+{
+ return url === "__WebInspectorConsoleEvaluation__";
+}
+
</ins><span class="cx"> function isWebKitInternalScript(url)
</span><span class="cx"> {
</span><ins>+ if (isWebInspectorConsoleEvaluationScript(url))
+ return false;
</ins><span class="cx"> return url && url.startsWith("__Web") && url.endsWith("__");
</span><span class="cx"> }
</span><span class="cx">
</span></span></pre></div>
<a id="trunkSourceWebInspectorUIUserInterfaceControllersDebuggerManagerjs"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebInspectorUI/UserInterface/Controllers/DebuggerManager.js (199896 => 199897)</h4>
<pre class="diff"><span>
<span class="info">--- 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)
</span><span class="lines">@@ -545,6 +545,12 @@
</span><span class="cx">
</span><span class="cx"> this._activeCallFrame = this._callFrames[0];
</span><span class="cx">
</span><ins>+ 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;
+ }
+
</ins><span class="cx"> if (!wasStillPaused)
</span><span class="cx"> this.dispatchEventToListeners(WebInspector.DebuggerManager.Event.Paused);
</span><span class="cx"> this.dispatchEventToListeners(WebInspector.DebuggerManager.Event.CallFramesDidChange);
</span><span class="lines">@@ -578,7 +584,7 @@
</span><span class="cx"> return;
</span><span class="cx"> }
</span><span class="cx">
</span><del>- if (isWebInspectorInternalScript(sourceURL))
</del><ins>+ if (!WebInspector.isDebugUIEnabled() && isWebKitInternalScript(sourceURL))
</ins><span class="cx"> return;
</span><span class="cx">
</span><span class="cx"> let script = new WebInspector.Script(scriptIdentifier, new WebInspector.TextRange(startLine, startColumn, endLine, endColumn), url, isContentScript, sourceURL, sourceMapURL);
</span><span class="lines">@@ -600,6 +606,10 @@
</span><span class="cx"> return;
</span><span class="cx"> }
</span><span class="cx">
</span><ins>+ // Console expressions are not added to the UI by default.
+ if (isWebInspectorConsoleEvaluationScript(script.sourceURL))
+ return;
+
</ins><span class="cx"> this.dispatchEventToListeners(WebInspector.DebuggerManager.Event.ScriptAdded, {script});
</span><span class="cx"> }
</span><span class="cx">
</span></span></pre></div>
<a id="trunkSourceWebInspectorUIUserInterfaceControllersJavaScriptLogViewControllerjs"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebInspectorUI/UserInterface/Controllers/JavaScriptLogViewController.js (199896 => 199897)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebInspectorUI/UserInterface/Controllers/JavaScriptLogViewController.js        2016-04-22 19:44:08 UTC (rev 199896)
+++ trunk/Source/WebInspectorUI/UserInterface/Controllers/JavaScriptLogViewController.js        2016-04-22 19:53:37 UTC (rev 199897)
</span><span class="lines">@@ -228,6 +228,8 @@
</span><span class="cx"> this._appendConsoleMessageView(commandResultMessageView, true);
</span><span class="cx"> }
</span><span class="cx">
</span><ins>+ text = appendWebInspectorConsoleEvaluationSourceURL(text);
+
</ins><span class="cx"> WebInspector.runtimeManager.evaluateInInspectedWindow(text, WebInspector.RuntimeManager.ConsoleObjectGroup, true, false, false, true, true, printResult.bind(this));
</span><span class="cx"> }
</span><span class="cx">
</span></span></pre></div>
<a id="trunkSourceWebInspectorUIUserInterfaceModelsScriptjs"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebInspectorUI/UserInterface/Models/Script.js (199896 => 199897)</h4>
<pre class="diff"><span>
<span class="info">--- 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)
</span><span class="lines">@@ -45,6 +45,11 @@
</span><span class="cx"> if (sourceMapURL)
</span><span class="cx"> WebInspector.sourceMapManager.downloadSourceMap(sourceMapURL, this._url, this);
</span><span class="cx">
</span><ins>+ if (isWebInspectorConsoleEvaluationScript(this._sourceURL)) {
+ // Assign a unique number to the script object so it will stay the same.
+ this._uniqueDisplayNameNumber = this.constructor._nextUniqueConsoleDisplayNameNumber++;
+ }
+
</ins><span class="cx"> this._scriptSyntaxTree = null;
</span><span class="cx"> }
</span><span class="cx">
</span><span class="lines">@@ -53,6 +58,7 @@
</span><span class="cx"> static resetUniqueDisplayNameNumbers()
</span><span class="cx"> {
</span><span class="cx"> WebInspector.Script._nextUniqueDisplayNameNumber = 1;
</span><ins>+ WebInspector.Script._nextUniqueConsoleDisplayNameNumber = 1;
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> // Public
</span><span class="lines">@@ -94,6 +100,11 @@
</span><span class="cx"> if (this._url)
</span><span class="cx"> return WebInspector.displayNameForURL(this._url, this.urlComponents);
</span><span class="cx">
</span><ins>+ if (isWebInspectorConsoleEvaluationScript(this._sourceURL)) {
+ console.assert(this._uniqueDisplayNameNumber);
+ return WebInspector.UIString("Console Evaluation %d").format(this._uniqueDisplayNameNumber);
+ }
+
</ins><span class="cx"> if (this._sourceURL) {
</span><span class="cx"> if (!this._sourceURLComponents)
</span><span class="cx"> this._sourceURLComponents = parseURL(this._sourceURL);
</span><span class="lines">@@ -247,3 +258,4 @@
</span><span class="cx"> WebInspector.Script.DisplayNameCookieKey = "script-display-name";
</span><span class="cx">
</span><span class="cx"> WebInspector.Script._nextUniqueDisplayNameNumber = 1;
</span><ins>+WebInspector.Script._nextUniqueConsoleDisplayNameNumber = 1;
</ins></span></pre></div>
<a id="trunkSourceWebInspectorUIUserInterfaceViewsDebuggerSidebarPaneljs"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebInspectorUI/UserInterface/Views/DebuggerSidebarPanel.js (199896 => 199897)</h4>
<pre class="diff"><span>
<span class="info">--- 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)
</span><span class="lines">@@ -208,7 +208,27 @@
</span><span class="cx"> if (representedObject instanceof WebInspector.Frame)
</span><span class="cx"> representedObject = representedObject.mainResource;
</span><span class="cx">
</span><del>- return this.contentTreeOutline.getCachedTreeElement(representedObject);
</del><ins>+ 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);
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> // Protected
</span><span class="lines">@@ -429,12 +449,12 @@
</span><span class="cx"> {
</span><span class="cx"> // COMPATIBILITY(iOS 9): Backends could send the frontend built-in code, filter out JSC internals.
</span><span class="cx"> if (!script.url && !script.sourceURL)
</span><del>- return;
</del><ins>+ return null;
</ins><span class="cx">
</span><span class="cx"> // Don't add breakpoints if the script is represented by a Resource. They were
</span><span class="cx"> // already added by _resourceAdded.
</span><span class="cx"> if (script.resource)
</span><del>- return;
</del><ins>+ return null;
</ins><span class="cx">
</span><span class="cx"> let treeElement = this._addTreeElementForSourceCodeToContentTreeOutline(script);
</span><span class="cx"> this._addBreakpointsForSourceCode(script);
</span><span class="lines">@@ -442,6 +462,8 @@
</span><span class="cx">
</span><span class="cx"> if (!this.contentBrowser.currentContentView)
</span><span class="cx"> this.showDefaultContentViewForTreeElement(treeElement);
</span><ins>+
+ return treeElement;
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> _scriptRemoved(event)
</span></span></pre>
</div>
</div>
</body>
</html>