<!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>[209706] trunk</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/209706">209706</a></dd>
<dt>Author</dt> <dd>mattbaker@apple.com</dd>
<dt>Date</dt> <dd>2016-12-12 03:11:59 -0800 (Mon, 12 Dec 2016)</dd>
</dl>

<h3>Log Message</h3>
<pre>Web Inspector: Breakpoint Log action should support template literals
https://bugs.webkit.org/show_bug.cgi?id=165116
&lt;rdar://problem/29464765&gt;

Reviewed by Joseph Pecoraro.

Source/WebInspectorUI:

* Localizations/en.lproj/localizedStrings.js:
New string &quot;${expr} = expression&quot; for breakpoint popover.

* UserInterface/Controllers/BreakpointLogMessageLexer.js: Added.
To support template literal placeholders in message text, it is necessary
to distinguish plain text parts of the message from placeholders, since
plain text must be escaped.

(WebInspector.BreakpointLogMessageLexer):
(WebInspector.BreakpointLogMessageLexer.prototype.tokenize):
(WebInspector.BreakpointLogMessageLexer.prototype.reset):
(WebInspector.BreakpointLogMessageLexer.prototype._finishPlainText):
(WebInspector.BreakpointLogMessageLexer.prototype._finishExpression):
(WebInspector.BreakpointLogMessageLexer.prototype._appendToken):
(WebInspector.BreakpointLogMessageLexer.prototype._consume):
(WebInspector.BreakpointLogMessageLexer.prototype._peek):
(WebInspector.BreakpointLogMessageLexer.prototype._expression):
(WebInspector.BreakpointLogMessageLexer.prototype._plainText):
(WebInspector.BreakpointLogMessageLexer.prototype._possiblePlaceholder):
(WebInspector.BreakpointLogMessageLexer.prototype._regExpOrStringLiteral):

* UserInterface/Controllers/DebuggerManager.js:
(WebInspector.DebuggerManager.prototype._debuggerBreakpointOptions):
Build breakpoint &quot;options&quot; object for DebuggerAgent. If a Log action
contains template literal placeholders it is changed to an Evaluate
action, which calls console.log with a template literal.

(WebInspector.DebuggerManager.prototype._setBreakpoint):
Use converted breakpoint options.

* UserInterface/Main.html:
* UserInterface/Test.html:
New file.

* UserInterface/Views/BreakpointActionView.css:
(.breakpoint-action-block-body &gt; .description):
Styles for breakpoint Log action hint text.

* UserInterface/Views/BreakpointActionView.js:
(WebInspector.BreakpointActionView.prototype._updateBody):
Add Log action hint text element.

LayoutTests:

* inspector/debugger/breakpoint-action-log-expected.txt: Added.
* inspector/debugger/breakpoint-action-log.html: Added.
Check that breakpoint log actions support template literal placeholders.

* inspector/unit-tests/breakpoint-log-message-lexer-expected.txt: Added.
* inspector/unit-tests/breakpoint-log-message-lexer.html: Added.
Check that the lexer correctly scans breakpoint log action text.</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkLayoutTestsChangeLog">trunk/LayoutTests/ChangeLog</a></li>
<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="#trunkSourceWebInspectorUIUserInterfaceControllersDebuggerManagerjs">trunk/Source/WebInspectorUI/UserInterface/Controllers/DebuggerManager.js</a></li>
<li><a href="#trunkSourceWebInspectorUIUserInterfaceMainhtml">trunk/Source/WebInspectorUI/UserInterface/Main.html</a></li>
<li><a href="#trunkSourceWebInspectorUIUserInterfaceTesthtml">trunk/Source/WebInspectorUI/UserInterface/Test.html</a></li>
<li><a href="#trunkSourceWebInspectorUIUserInterfaceViewsBreakpointActionViewcss">trunk/Source/WebInspectorUI/UserInterface/Views/BreakpointActionView.css</a></li>
<li><a href="#trunkSourceWebInspectorUIUserInterfaceViewsBreakpointActionViewjs">trunk/Source/WebInspectorUI/UserInterface/Views/BreakpointActionView.js</a></li>
</ul>

<h3>Added Paths</h3>
<ul>
<li><a href="#trunkLayoutTestsinspectordebuggerbreakpointactionlogexpectedtxt">trunk/LayoutTests/inspector/debugger/breakpoint-action-log-expected.txt</a></li>
<li><a href="#trunkLayoutTestsinspectordebuggerbreakpointactionloghtml">trunk/LayoutTests/inspector/debugger/breakpoint-action-log.html</a></li>
<li><a href="#trunkLayoutTestsinspectorunittestsbreakpointlogmessagelexerexpectedtxt">trunk/LayoutTests/inspector/unit-tests/breakpoint-log-message-lexer-expected.txt</a></li>
<li><a href="#trunkLayoutTestsinspectorunittestsbreakpointlogmessagelexerhtml">trunk/LayoutTests/inspector/unit-tests/breakpoint-log-message-lexer.html</a></li>
<li><a href="#trunkSourceWebInspectorUIUserInterfaceControllersBreakpointLogMessageLexerjs">trunk/Source/WebInspectorUI/UserInterface/Controllers/BreakpointLogMessageLexer.js</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkLayoutTestsChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/ChangeLog (209705 => 209706)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/ChangeLog        2016-12-12 09:10:07 UTC (rev 209705)
+++ trunk/LayoutTests/ChangeLog        2016-12-12 11:11:59 UTC (rev 209706)
</span><span class="lines">@@ -1,3 +1,19 @@
</span><ins>+2016-12-12  Matt Baker  &lt;mattbaker@apple.com&gt;
+
+        Web Inspector: Breakpoint Log action should support template literals
+        https://bugs.webkit.org/show_bug.cgi?id=165116
+        &lt;rdar://problem/29464765&gt;
+
+        Reviewed by Joseph Pecoraro.
+
+        * inspector/debugger/breakpoint-action-log-expected.txt: Added.
+        * inspector/debugger/breakpoint-action-log.html: Added.
+        Check that breakpoint log actions support template literal placeholders.
+
+        * inspector/unit-tests/breakpoint-log-message-lexer-expected.txt: Added.
+        * inspector/unit-tests/breakpoint-log-message-lexer.html: Added.
+        Check that the lexer correctly scans breakpoint log action text.
+
</ins><span class="cx"> 2016-12-11  Simon Fraser  &lt;simon.fraser@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         REGRESSION (r200283): Transform, overflow hidden and filter combination completely hides the element
</span></span></pre></div>
<a id="trunkLayoutTestsinspectordebuggerbreakpointactionlogexpectedtxt"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/inspector/debugger/breakpoint-action-log-expected.txt (0 => 209706)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/inspector/debugger/breakpoint-action-log-expected.txt                                (rev 0)
+++ trunk/LayoutTests/inspector/debugger/breakpoint-action-log-expected.txt        2016-12-12 11:11:59 UTC (rev 209706)
</span><span class="lines">@@ -0,0 +1,17 @@
</span><ins>+CONSOLE MESSAGE: line 1: `42`
+CONSOLE MESSAGE: line 1: '42'
+CONSOLE MESSAGE: line 1: abc
+CONSOLE MESSAGE: line 1: {abc}
+CONSOLE MESSAGE: line 1: {abc}
+CONSOLE MESSAGE: line 1: {abc}
+CONSOLE MESSAGE: line 1: abc
+CONSOLE MESSAGE: line 1: 137
+CONSOLE MESSAGE: line 1: close curly brace in RegExp: true
+CONSOLE MESSAGE: line 1: 42 and {&quot;x&quot;:1,&quot;y&quot;:2}
+Testing that &quot;Log&quot; breakpoint actions work correctly.
+
+inside breakpointActions a:(42) b:([object Object])
+
+== Running test suite: Debugger.BreakpointAction.Log
+-- Running test case: TemplateLiteralPlaceholders
+
</ins></span></pre></div>
<a id="trunkLayoutTestsinspectordebuggerbreakpointactionloghtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/inspector/debugger/breakpoint-action-log.html (0 => 209706)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/inspector/debugger/breakpoint-action-log.html                                (rev 0)
+++ trunk/LayoutTests/inspector/debugger/breakpoint-action-log.html        2016-12-12 11:11:59 UTC (rev 209706)
</span><span class="lines">@@ -0,0 +1,60 @@
</span><ins>+&lt;!doctype html&gt;
+&lt;html&gt;
+&lt;head&gt;
+&lt;script src=&quot;../../http/tests/inspector/resources/inspector-test.js&quot;&gt;&lt;/script&gt;
+&lt;script src=&quot;resources/script-for-breakpoint-actions.js&quot;&gt;&lt;/script&gt;
+&lt;script&gt;
+function runBreakpointActions()
+{
+    breakpointActions(42, {x:1, y:2});
+}
+
+function test()
+{
+    let suite = InspectorTest.createAsyncSuite(&quot;Debugger.BreakpointAction.Log&quot;);
+
+    suite.addTestCase({
+        name: &quot;TemplateLiteralPlaceholders&quot;,
+        description: &quot;.&quot;,
+        test(resolve, reject) {
+            WebInspector.debuggerManager.addEventListener(WebInspector.DebuggerManager.Event.ScriptAdded, (event) =&gt; {
+                let scriptObject = event.data.script;
+                if (!/script\-for\-breakpoint\-actions\.js$/.test(scriptObject.url))
+                    return;
+
+                let location = scriptObject.createSourceCodeLocation(4, 0);
+                let breakpoint = new WebInspector.Breakpoint(location);
+                breakpoint.autoContinue = true;
+
+                function addLogAction(data) {
+                    breakpoint.createAction(WebInspector.BreakpointAction.Type.Log, breakpoint.actions.lastValue, data);
+                }
+
+                addLogAction(&quot;`${a}`&quot;);
+                addLogAction(&quot;'${a}'&quot;);
+                addLogAction(&quot;${'ab' + 'c'}&quot;);
+                addLogAction(&quot;${\&quot;{abc}\&quot;}&quot;);
+                addLogAction(&quot;${'{abc}'}&quot;);
+                addLogAction(&quot;${`{abc}`}&quot;);
+                addLogAction(&quot;${`ab${'c'}`}&quot;);
+                addLogAction(&quot;${({a: 137}).a}&quot;);
+                addLogAction(&quot;close curly brace in RegExp: ${/\\}/.test('}')}&quot;);
+                addLogAction(&quot;${a} and ${JSON.stringify(b)}&quot;);
+
+                WebInspector.debuggerManager.addBreakpoint(breakpoint);
+
+                InspectorTest.evaluateInPage(&quot;runBreakpointActions()&quot;, resolve);
+            });
+
+            InspectorTest.reloadPage();
+        }
+    });
+
+    suite.runTestCasesAndFinish();
+}
+&lt;/script&gt;
+&lt;/head&gt;
+&lt;body onload=&quot;runTest()&quot;&gt;
+    &lt;p&gt;Testing that &quot;Log&quot; breakpoint actions work correctly.&lt;/p&gt;
+&lt;/body&gt;
+&lt;/html&gt;
</ins></span></pre></div>
<a id="trunkLayoutTestsinspectorunittestsbreakpointlogmessagelexerexpectedtxt"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/inspector/unit-tests/breakpoint-log-message-lexer-expected.txt (0 => 209706)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/inspector/unit-tests/breakpoint-log-message-lexer-expected.txt                                (rev 0)
+++ trunk/LayoutTests/inspector/unit-tests/breakpoint-log-message-lexer-expected.txt        2016-12-12 11:11:59 UTC (rev 209706)
</span><span class="lines">@@ -0,0 +1,44 @@
</span><ins>+Check that BreakpointLogMessageLexer correctly tokenizes breakpoint action log messages. Message text can include template literal placeholders.
+
+
+== Running test suite: Debugger.BreakpointLogMessageLexer
+-- Running test case: EmptyMessage
+Input: 
+PASS: Token stream should match expected tokens.
+
+-- Running test case: TextOnly
+Input: hello world
+PASS: Token stream should match expected tokens.
+
+-- Running test case: PlaceholderOnly
+Input: ${x}
+PASS: Token stream should match expected tokens.
+
+-- Running test case: NestedTemplateLiteral
+Input: ${'x' + `${'y'}`}
+PASS: Token stream should match expected tokens.
+
+-- Running test case: TextBeforePlaceholder
+Input: abc ${x}
+PASS: Token stream should match expected tokens.
+
+-- Running test case: TextAfterPlaceholder
+Input: ${x} abc
+PASS: Token stream should match expected tokens.
+
+-- Running test case: PlaceholderWithNestedBraces
+Input: ${({a: '${}'}).a}
+PASS: Token stream should match expected tokens.
+
+-- Running test case: PlaceholderWithRegExpLiteral
+Input: ${/\}/.test('${')}
+PASS: Token stream should match expected tokens.
+
+-- Running test case: MultiplePlaceholders
+Input: ${1} ${2}
+PASS: Token stream should match expected tokens.
+
+-- Running test case: ExpressionFollowedByBraces
+Input: ${1}{2}
+PASS: Token stream should match expected tokens.
+
</ins></span></pre></div>
<a id="trunkLayoutTestsinspectorunittestsbreakpointlogmessagelexerhtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/inspector/unit-tests/breakpoint-log-message-lexer.html (0 => 209706)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/inspector/unit-tests/breakpoint-log-message-lexer.html                                (rev 0)
+++ trunk/LayoutTests/inspector/unit-tests/breakpoint-log-message-lexer.html        2016-12-12 11:11:59 UTC (rev 209706)
</span><span class="lines">@@ -0,0 +1,161 @@
</span><ins>+&lt;!doctype html&gt;
+&lt;html&gt;
+&lt;head&gt;
+&lt;script src=&quot;../../http/tests/inspector/resources/inspector-test.js&quot;&gt;&lt;/script&gt;
+&lt;script src=&quot;resources/script-for-breakpoint-actions.js&quot;&gt;&lt;/script&gt;
+&lt;script&gt;
+function runBreakpointActions()
+{
+    breakpointActions(42, {x:1, y:2});
+}
+
+function test()
+{
+    let suite = InspectorTest.createSyncSuite(&quot;Debugger.BreakpointLogMessageLexer&quot;);
+
+    function addTestCase({name, input, expectedTokens}) {
+        suite.addTestCase({
+            name,
+            test() {
+                let lexer = new WebInspector.BreakpointLogMessageLexer;
+                let tokens = lexer.tokenize(input);
+                InspectorTest.log(&quot;Input: &quot; + input);
+                InspectorTest.expectShallowEqual(tokens, expectedTokens, &quot;Token stream should match expected tokens.&quot;);
+                return true;
+            }
+        });
+    }
+
+    addTestCase({
+        name: &quot;EmptyMessage&quot;,
+        input: &quot;&quot;,
+        expectedTokens: []
+    });
+
+    addTestCase({
+        name: &quot;TextOnly&quot;,
+        input: &quot;hello world&quot;,
+        expectedTokens: [
+            {
+                type: WebInspector.BreakpointLogMessageLexer.TokenType.PlainText,
+                data: &quot;hello world&quot;,
+            }
+        ]
+    });
+
+    addTestCase({
+        name: &quot;PlaceholderOnly&quot;,
+        input: &quot;${x}&quot;,
+        expectedTokens: [
+            {
+                type: WebInspector.BreakpointLogMessageLexer.TokenType.Expression,
+                data: &quot;x&quot;,
+            }
+        ]
+    });
+
+    addTestCase({
+        name: &quot;NestedTemplateLiteral&quot;,
+        input: &quot;${'x' + `${'y'}`}&quot;,
+        expectedTokens: [
+            {
+                type: WebInspector.BreakpointLogMessageLexer.TokenType.Expression,
+                data: &quot;'x' + `${'y'}`&quot;,
+            }
+        ]
+    });
+
+    addTestCase({
+        name: &quot;TextBeforePlaceholder&quot;,
+        input: &quot;abc ${x}&quot;,
+        expectedTokens: [
+            {
+                type: WebInspector.BreakpointLogMessageLexer.TokenType.PlainText,
+                data: &quot;abc &quot;,
+            },
+            {
+                type: WebInspector.BreakpointLogMessageLexer.TokenType.Expression,
+                data: &quot;x&quot;,
+            },
+        ]
+    });
+
+    addTestCase({
+        name: &quot;TextAfterPlaceholder&quot;,
+        input: &quot;${x} abc&quot;,
+        expectedTokens: [
+            {
+                type: WebInspector.BreakpointLogMessageLexer.TokenType.Expression,
+                data: &quot;x&quot;,
+            },
+            {
+                type: WebInspector.BreakpointLogMessageLexer.TokenType.PlainText,
+                data: &quot; abc&quot;,
+            },
+        ]
+    });
+
+    addTestCase({
+        name: &quot;PlaceholderWithNestedBraces&quot;,
+        input: &quot;${({a: '${}'}).a}&quot;,
+        expectedTokens: [
+            {
+                type: WebInspector.BreakpointLogMessageLexer.TokenType.Expression,
+                data: &quot;({a: '${}'}).a&quot;,
+            }
+        ]
+    });
+
+    addTestCase({
+        name: &quot;PlaceholderWithRegExpLiteral&quot;,
+        input: &quot;${/\\}/.test('${')}&quot;,
+        expectedTokens: [
+            {
+                type: WebInspector.BreakpointLogMessageLexer.TokenType.Expression,
+                data: &quot;/\\}/.test('${')&quot;,
+            }
+        ]
+    });
+
+    addTestCase({
+        name: &quot;MultiplePlaceholders&quot;,
+        input: &quot;${1} ${2}&quot;,
+        expectedTokens: [
+            {
+                type: WebInspector.BreakpointLogMessageLexer.TokenType.Expression,
+                data: &quot;1&quot;,
+            },
+            {
+                type: WebInspector.BreakpointLogMessageLexer.TokenType.PlainText,
+                data: &quot; &quot;,
+            },
+            {
+                type: WebInspector.BreakpointLogMessageLexer.TokenType.Expression,
+                data: &quot;2&quot;,
+            }
+        ]
+    });
+
+    addTestCase({
+        name: &quot;ExpressionFollowedByBraces&quot;,
+        input: &quot;${1}{2}&quot;,
+        expectedTokens: [
+            {
+                type: WebInspector.BreakpointLogMessageLexer.TokenType.Expression,
+                data: &quot;1&quot;,
+            },
+            {
+                type: WebInspector.BreakpointLogMessageLexer.TokenType.PlainText,
+                data: &quot;{2}&quot;,
+            },
+        ]
+    });
+
+    suite.runTestCasesAndFinish();
+}
+&lt;/script&gt;
+&lt;/head&gt;
+&lt;body onload=&quot;runTest()&quot;&gt;
+    &lt;p&gt;Check that BreakpointLogMessageLexer correctly tokenizes breakpoint action log messages. Message text can include template literal placeholders.&lt;/p&gt;
+&lt;/body&gt;
+&lt;/html&gt;
</ins></span></pre></div>
<a id="trunkSourceWebInspectorUIChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebInspectorUI/ChangeLog (209705 => 209706)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebInspectorUI/ChangeLog        2016-12-12 09:10:07 UTC (rev 209705)
+++ trunk/Source/WebInspectorUI/ChangeLog        2016-12-12 11:11:59 UTC (rev 209706)
</span><span class="lines">@@ -1,3 +1,53 @@
</span><ins>+2016-12-12  Matt Baker  &lt;mattbaker@apple.com&gt;
+
+        Web Inspector: Breakpoint Log action should support template literals
+        https://bugs.webkit.org/show_bug.cgi?id=165116
+        &lt;rdar://problem/29464765&gt;
+
+        Reviewed by Joseph Pecoraro.
+
+        * Localizations/en.lproj/localizedStrings.js:
+        New string &quot;${expr} = expression&quot; for breakpoint popover.
+
+        * UserInterface/Controllers/BreakpointLogMessageLexer.js: Added.
+        To support template literal placeholders in message text, it is necessary
+        to distinguish plain text parts of the message from placeholders, since
+        plain text must be escaped.
+
+        (WebInspector.BreakpointLogMessageLexer):
+        (WebInspector.BreakpointLogMessageLexer.prototype.tokenize):
+        (WebInspector.BreakpointLogMessageLexer.prototype.reset):
+        (WebInspector.BreakpointLogMessageLexer.prototype._finishPlainText):
+        (WebInspector.BreakpointLogMessageLexer.prototype._finishExpression):
+        (WebInspector.BreakpointLogMessageLexer.prototype._appendToken):
+        (WebInspector.BreakpointLogMessageLexer.prototype._consume):
+        (WebInspector.BreakpointLogMessageLexer.prototype._peek):
+        (WebInspector.BreakpointLogMessageLexer.prototype._expression):
+        (WebInspector.BreakpointLogMessageLexer.prototype._plainText):
+        (WebInspector.BreakpointLogMessageLexer.prototype._possiblePlaceholder):
+        (WebInspector.BreakpointLogMessageLexer.prototype._regExpOrStringLiteral):
+
+        * UserInterface/Controllers/DebuggerManager.js:
+        (WebInspector.DebuggerManager.prototype._debuggerBreakpointOptions):
+        Build breakpoint &quot;options&quot; object for DebuggerAgent. If a Log action
+        contains template literal placeholders it is changed to an Evaluate
+        action, which calls console.log with a template literal.
+
+        (WebInspector.DebuggerManager.prototype._setBreakpoint):
+        Use converted breakpoint options.
+
+        * UserInterface/Main.html:
+        * UserInterface/Test.html:
+        New file.
+
+        * UserInterface/Views/BreakpointActionView.css:
+        (.breakpoint-action-block-body &gt; .description):
+        Styles for breakpoint Log action hint text.
+
+        * UserInterface/Views/BreakpointActionView.js:
+        (WebInspector.BreakpointActionView.prototype._updateBody):
+        Add Log action hint text element.
+
</ins><span class="cx"> 2016-12-11  Matt Baker  &lt;mattbaker@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         Web Inspector: ThreadTreeElement should have a &quot;Resume&quot; status button when paused
</span></span></pre></div>
<a id="trunkSourceWebInspectorUILocalizationsenlprojlocalizedStringsjs"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebInspectorUI/Localizations/en.lproj/localizedStrings.js (209705 => 209706)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebInspectorUI/Localizations/en.lproj/localizedStrings.js        2016-12-12 09:10:07 UTC (rev 209705)
+++ trunk/Source/WebInspectorUI/Localizations/en.lproj/localizedStrings.js        2016-12-12 11:11:59 UTC (rev 209706)
</span><span class="lines">@@ -2,6 +2,7 @@
</span><span class="cx"> 
</span><span class="cx"> localizedStrings[&quot; (Prototype)&quot;] = &quot; (Prototype)&quot;;
</span><span class="cx"> localizedStrings[&quot; (line %s)&quot;] = &quot; (line %s)&quot;;
</span><ins>+localizedStrings[&quot;${expr} = expression&quot;] = &quot;${expr} = expression&quot;;
</ins><span class="cx"> localizedStrings[&quot;%.0f B&quot;] = &quot;%.0f B&quot;;
</span><span class="cx"> localizedStrings[&quot;%.0fms&quot;] = &quot;%.0fms&quot;;
</span><span class="cx"> localizedStrings[&quot;%.1f KB&quot;] = &quot;%.1f KB&quot;;
</span></span></pre></div>
<a id="trunkSourceWebInspectorUIUserInterfaceControllersBreakpointLogMessageLexerjs"></a>
<div class="addfile"><h4>Added: trunk/Source/WebInspectorUI/UserInterface/Controllers/BreakpointLogMessageLexer.js (0 => 209706)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebInspectorUI/UserInterface/Controllers/BreakpointLogMessageLexer.js                                (rev 0)
+++ trunk/Source/WebInspectorUI/UserInterface/Controllers/BreakpointLogMessageLexer.js        2016-12-12 11:11:59 UTC (rev 209706)
</span><span class="lines">@@ -0,0 +1,197 @@
</span><ins>+/*
+ * Copyright (C) 2016 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+WebInspector.BreakpointLogMessageLexer = class BreakpointLogMessageLexer extends WebInspector.Object
+{
+    constructor()
+    {
+        super();
+
+        this._stateFunctions = {
+            [WebInspector.BreakpointLogMessageLexer.State.Expression]: this._expression,
+            [WebInspector.BreakpointLogMessageLexer.State.PlainText]: this._plainText,
+            [WebInspector.BreakpointLogMessageLexer.State.PossiblePlaceholder]: this._possiblePlaceholder,
+            [WebInspector.BreakpointLogMessageLexer.State.RegExpOrStringLiteral]: this._regExpOrStringLiteral,
+        };
+
+        this.reset();
+    }
+
+    // Public
+
+    tokenize(input)
+    {
+        this.reset();
+        this._input = input;
+
+        while (this._index &lt; this._input.length) {
+            let stateFunction = this._stateFunctions[this._states.lastValue];
+            console.assert(stateFunction);
+            if (!stateFunction) {
+                this.reset();
+                return null;
+            }
+
+            stateFunction.call(this);
+        }
+
+        // Needed for trailing plain text.
+        this._finishPlainText();
+
+        return this._tokens;
+    }
+
+    reset()
+    {
+        this._input = &quot;&quot;;
+        this._buffer = &quot;&quot;;
+
+        this._index = 0;
+        this._states = [WebInspector.BreakpointLogMessageLexer.State.PlainText];
+        this._literalStartCharacter = &quot;&quot;;
+        this._curlyBraceDepth = 0;
+        this._tokens = [];
+    }
+
+    // Private
+
+     _finishPlainText()
+    {
+        this._appendToken(WebInspector.BreakpointLogMessageLexer.TokenType.PlainText);
+    }
+
+    _finishExpression()
+    {
+        this._appendToken(WebInspector.BreakpointLogMessageLexer.TokenType.Expression);
+    }
+
+    _appendToken(type)
+    {
+        if (!this._buffer)
+            return;
+
+        this._tokens.push({type, data: this._buffer});
+        this._buffer = &quot;&quot;;
+    }
+
+    _consume()
+    {
+        console.assert(this._index &lt; this._input.length);
+
+        let character = this._peek();
+        this._index++;
+        return character;
+    }
+
+    _peek()
+    {
+        return this._input[this._index] || null;
+    }
+
+    // States
+
+    _expression()
+    {
+        let character = this._consume();
+
+        if (character === &quot;}&quot;) {
+            if (this._curlyBraceDepth === 0) {
+                this._finishExpression();
+
+                console.assert(this._states.lastValue === WebInspector.BreakpointLogMessageLexer.State.Expression);
+                this._states.pop();
+                return;
+            }
+
+            this._curlyBraceDepth--;
+        }
+
+        this._buffer += character;
+
+        if (character === &quot;/&quot; || character === &quot;\&quot;&quot; || character === &quot;'&quot;) {
+            this._literalStartCharacter = character;
+            this._states.push(WebInspector.BreakpointLogMessageLexer.State.RegExpOrStringLiteral);
+        } else if (character === &quot;{&quot;)
+            this._curlyBraceDepth++;
+    }
+
+    _plainText()
+    {
+        let character = this._peek();
+
+        if (character === &quot;$&quot;)
+            this._states.push(WebInspector.BreakpointLogMessageLexer.State.PossiblePlaceholder);
+        else {
+            this._buffer += character;
+            this._consume();
+        }
+    }
+
+    _possiblePlaceholder()
+    {
+        let character = this._consume();
+        console.assert(character === &quot;$&quot;)
+        let nextCharacter = this._peek();
+
+        console.assert(this._states.lastValue === WebInspector.BreakpointLogMessageLexer.State.PossiblePlaceholder);
+        this._states.pop();
+
+        if (nextCharacter === &quot;{&quot;) {
+            this._finishPlainText();
+            this._consume();
+            this._states.push(WebInspector.BreakpointLogMessageLexer.State.Expression);
+        } else
+            this._buffer += character;
+    }
+
+    _regExpOrStringLiteral()
+    {
+        let character = this._consume();
+        this._buffer += character;
+
+        if (character === &quot;\\&quot;) {
+            if (this._peek() !== null)
+                this._buffer += this._consume();
+            return;
+        }
+
+        if (character === this._literalStartCharacter) {
+            console.assert(this._states.lastValue === WebInspector.BreakpointLogMessageLexer.State.RegExpOrStringLiteral);
+            this._states.pop();
+        }
+    }
+};
+
+WebInspector.BreakpointLogMessageLexer.State = {
+    Expression: Symbol(&quot;expression&quot;),
+    PlainText: Symbol(&quot;plain-text&quot;),
+    PossiblePlaceholder: Symbol(&quot;possible-placeholder&quot;),
+    RegExpOrStringLiteral: Symbol(&quot;regexp-or-string-literal&quot;),
+};
+
+WebInspector.BreakpointLogMessageLexer.TokenType = {
+    PlainText: &quot;token-type-plain-text&quot;,
+    Expression: &quot;token-type-expression&quot;,
+};
</ins></span></pre></div>
<a id="trunkSourceWebInspectorUIUserInterfaceControllersDebuggerManagerjs"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebInspectorUI/UserInterface/Controllers/DebuggerManager.js (209705 => 209706)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebInspectorUI/UserInterface/Controllers/DebuggerManager.js        2016-12-12 09:10:07 UTC (rev 209705)
+++ trunk/Source/WebInspectorUI/UserInterface/Controllers/DebuggerManager.js        2016-12-12 11:11:59 UTC (rev 209706)
</span><span class="lines">@@ -823,6 +823,46 @@
</span><span class="cx">         }
</span><span class="cx">     }
</span><span class="cx"> 
</span><ins>+    _debuggerBreakpointOptions(breakpoint)
+    {
+        const templatePlaceholderRegex = /\$\{.*?\}/;
+
+        let options = breakpoint.options;
+        let invalidActions = [];
+
+        for (let action of options.actions) {
+            if (action.type !== WebInspector.BreakpointAction.Type.Log)
+                continue;
+
+            if (!templatePlaceholderRegex.test(action.data))
+                continue;
+
+            let lexer = new WebInspector.BreakpointLogMessageLexer;
+            let tokens = lexer.tokenize(action.data);
+            if (!tokens) {
+                invalidActions.push(action);
+                continue;
+            }
+
+            let templateLiteral = tokens.reduce((text, token) =&gt; {
+                if (token.type === WebInspector.BreakpointLogMessageLexer.TokenType.PlainText)
+                    return text + token.data.escapeCharacters(&quot;`\\&quot;);
+                if (token.type === WebInspector.BreakpointLogMessageLexer.TokenType.Expression)
+                    return text + &quot;${&quot; + token.data + &quot;}&quot;;
+                return text;
+            }, &quot;&quot;);
+
+            action.data = &quot;console.log(`&quot; + templateLiteral + &quot;`)&quot;;
+            action.type = WebInspector.BreakpointAction.Type.Evaluate;
+        }
+
+        const onlyFirst = true;
+        for (let invalidAction of invalidActions)
+            options.actions.remove(invalidAction, onlyFirst);
+
+        return options;
+    }
+
</ins><span class="cx">     _setBreakpoint(breakpoint, specificTarget, callback)
</span><span class="cx">     {
</span><span class="cx">         console.assert(!breakpoint.disabled);
</span><span class="lines">@@ -867,7 +907,7 @@
</span><span class="cx">         // COMPATIBILITY (iOS 7): Debugger.BreakpointActionType did not exist yet.
</span><span class="cx">         let options;
</span><span class="cx">         if (DebuggerAgent.BreakpointActionType) {
</span><del>-            options = breakpoint.options;
</del><ins>+            options = this._debuggerBreakpointOptions(breakpoint);
</ins><span class="cx">             if (options.actions.length) {
</span><span class="cx">                 for (let action of options.actions)
</span><span class="cx">                     action.type = this._debuggerBreakpointActionType(action.type);
</span></span></pre></div>
<a id="trunkSourceWebInspectorUIUserInterfaceMainhtml"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebInspectorUI/UserInterface/Main.html (209705 => 209706)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebInspectorUI/UserInterface/Main.html        2016-12-12 09:10:07 UTC (rev 209705)
+++ trunk/Source/WebInspectorUI/UserInterface/Main.html        2016-12-12 11:11:59 UTC (rev 209706)
</span><span class="lines">@@ -704,6 +704,7 @@
</span><span class="cx">     &lt;script src=&quot;Controllers/ApplicationCacheManager.js&quot;&gt;&lt;/script&gt;
</span><span class="cx">     &lt;script src=&quot;Controllers/BasicBlockAnnotator.js&quot;&gt;&lt;/script&gt;
</span><span class="cx">     &lt;script src=&quot;Controllers/BranchManager.js&quot;&gt;&lt;/script&gt;
</span><ins>+    &lt;script src=&quot;Controllers/BreakpointLogMessageLexer.js&quot;&gt;&lt;/script&gt;
</ins><span class="cx">     &lt;script src=&quot;Controllers/BreakpointPopoverController.js&quot;&gt;&lt;/script&gt;
</span><span class="cx">     &lt;script src=&quot;Controllers/CSSStyleManager.js&quot;&gt;&lt;/script&gt;
</span><span class="cx">     &lt;script src=&quot;Controllers/CodeMirrorColorEditingController.js&quot;&gt;&lt;/script&gt;
</span></span></pre></div>
<a id="trunkSourceWebInspectorUIUserInterfaceTesthtml"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebInspectorUI/UserInterface/Test.html (209705 => 209706)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebInspectorUI/UserInterface/Test.html        2016-12-12 09:10:07 UTC (rev 209705)
+++ trunk/Source/WebInspectorUI/UserInterface/Test.html        2016-12-12 11:11:59 UTC (rev 209706)
</span><span class="lines">@@ -179,6 +179,7 @@
</span><span class="cx">     &lt;script src=&quot;Proxies/HeapSnapshotProxy.js&quot;&gt;&lt;/script&gt;
</span><span class="cx">     &lt;script src=&quot;Proxies/HeapSnapshotWorkerProxy.js&quot;&gt;&lt;/script&gt;
</span><span class="cx"> 
</span><ins>+    &lt;script src=&quot;Controllers/BreakpointLogMessageLexer.js&quot;&gt;&lt;/script&gt;
</ins><span class="cx">     &lt;script src=&quot;Controllers/CSSStyleManager.js&quot;&gt;&lt;/script&gt;
</span><span class="cx">     &lt;script src=&quot;Controllers/DOMTreeManager.js&quot;&gt;&lt;/script&gt;
</span><span class="cx">     &lt;script src=&quot;Controllers/DebuggerManager.js&quot;&gt;&lt;/script&gt;
</span></span></pre></div>
<a id="trunkSourceWebInspectorUIUserInterfaceViewsBreakpointActionViewcss"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebInspectorUI/UserInterface/Views/BreakpointActionView.css (209705 => 209706)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebInspectorUI/UserInterface/Views/BreakpointActionView.css        2016-12-12 09:10:07 UTC (rev 209705)
+++ trunk/Source/WebInspectorUI/UserInterface/Views/BreakpointActionView.css        2016-12-12 11:11:59 UTC (rev 209706)
</span><span class="lines">@@ -61,6 +61,13 @@
</span><span class="cx">     box-shadow: inset 0 0 2px hsl(0, 0%, 78%);
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+.breakpoint-action-block-body &gt; .description {
+    color: var(--text-color-gray-medium);
+    text-align: right;
+    margin-top: 6px;
+    margin-right: 2px;
+}
+
</ins><span class="cx"> .breakpoint-action-block-body &gt; input {
</span><span class="cx">     width: 100%;
</span><span class="cx"> }
</span></span></pre></div>
<a id="trunkSourceWebInspectorUIUserInterfaceViewsBreakpointActionViewjs"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebInspectorUI/UserInterface/Views/BreakpointActionView.js (209705 => 209706)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebInspectorUI/UserInterface/Views/BreakpointActionView.js        2016-12-12 09:10:07 UTC (rev 209705)
+++ trunk/Source/WebInspectorUI/UserInterface/Views/BreakpointActionView.js        2016-12-12 11:11:59 UTC (rev 209706)
</span><span class="lines">@@ -142,6 +142,9 @@
</span><span class="cx">             if (!omitFocus)
</span><span class="cx">                 setTimeout(function() { input.focus(); }, 0);
</span><span class="cx"> 
</span><ins>+            let descriptionElement = this._bodyElement.appendChild(document.createElement(&quot;div&quot;));
+            descriptionElement.classList.add(&quot;description&quot;);
+            descriptionElement.textContent = WebInspector.UIString(&quot;${expr} = expression&quot;);
</ins><span class="cx">             break;
</span><span class="cx"> 
</span><span class="cx">         case WebInspector.BreakpointAction.Type.Evaluate:
</span></span></pre>
</div>
</div>

</body>
</html>