<!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>[163363] trunk/LayoutTests</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/163363">163363</a></dd>
<dt>Author</dt> <dd>mark.lam@apple.com</dd>
<dt>Date</dt> <dd>2014-02-03 21:10:04 -0800 (Mon, 03 Feb 2014)</dd>
</dl>

<h3>Log Message</h3>
<pre>Need regression test for the debugger modifying locals in a DFG frame.
https://bugs.webkit.org/show_bug.cgi?id=128120.

Reviewed by Geoffrey Garen.

Regression test for https://bugs.webkit.org/show_bug.cgi?id=128112.

This test does the following:
1. Warm up a DFG function.
2. Sets a breakpoint in a function breakpointBasic() that will be called
   by the DFG function, but has never been called yet.
3. Call a driver function which in turn calls the DFG function, and expect
   the debugger to break.
4. At the breakpoint in breakpointBasic(), evaluate an expression on its
   caller i.e. the DFG function, and change a local variable in it.
5. Resume from the debugger, and let the DFG function and its driver
   function run to completion. The DFG function will return a value
   computed using the modified local.
6. At the end of the driver function, verify that the returned computed
   value reflects the modified value.

This test has been verified with tracing enabled to ensure that the test
DFG function was indeed DFG compiled, and that the test passed with the
expected results.

* inspector-protocol/debugger/resources/breakpoint.js:
(notInlineable2):
(dfgWithoutInline2):
(callNotInlineable2):
* inspector-protocol/debugger/setBreakpoint-dfg-and-modify-local-expected.txt: Added.
* inspector-protocol/debugger/setBreakpoint-dfg-and-modify-local.html: Added.</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkLayoutTestsChangeLog">trunk/LayoutTests/ChangeLog</a></li>
<li><a href="#trunkLayoutTestsinspectorprotocoldebuggerresourcesbreakpointjs">trunk/LayoutTests/inspector-protocol/debugger/resources/breakpoint.js</a></li>
</ul>

<h3>Added Paths</h3>
<ul>
<li><a href="#trunkLayoutTestsinspectorprotocoldebuggersetBreakpointdfgandmodifylocalexpectedtxt">trunk/LayoutTests/inspector-protocol/debugger/setBreakpoint-dfg-and-modify-local-expected.txt</a></li>
<li><a href="#trunkLayoutTestsinspectorprotocoldebuggersetBreakpointdfgandmodifylocalhtml">trunk/LayoutTests/inspector-protocol/debugger/setBreakpoint-dfg-and-modify-local.html</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkLayoutTestsChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/ChangeLog (163362 => 163363)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/ChangeLog        2014-02-04 05:05:43 UTC (rev 163362)
+++ trunk/LayoutTests/ChangeLog        2014-02-04 05:10:04 UTC (rev 163363)
</span><span class="lines">@@ -1,5 +1,39 @@
</span><span class="cx"> 2014-02-03  Mark Lam  &lt;mark.lam@apple.com&gt;
</span><span class="cx"> 
</span><ins>+        Need regression test for the debugger modifying locals in a DFG frame.
+        https://bugs.webkit.org/show_bug.cgi?id=128120.
+
+        Reviewed by Geoffrey Garen.
+
+        Regression test for https://bugs.webkit.org/show_bug.cgi?id=128112.
+
+        This test does the following:
+        1. Warm up a DFG function.
+        2. Sets a breakpoint in a function breakpointBasic() that will be called
+           by the DFG function, but has never been called yet.
+        3. Call a driver function which in turn calls the DFG function, and expect
+           the debugger to break.
+        4. At the breakpoint in breakpointBasic(), evaluate an expression on its
+           caller i.e. the DFG function, and change a local variable in it.
+        5. Resume from the debugger, and let the DFG function and its driver
+           function run to completion. The DFG function will return a value
+           computed using the modified local.
+        6. At the end of the driver function, verify that the returned computed
+           value reflects the modified value.
+
+        This test has been verified with tracing enabled to ensure that the test
+        DFG function was indeed DFG compiled, and that the test passed with the
+        expected results.
+
+        * inspector-protocol/debugger/resources/breakpoint.js:
+        (notInlineable2):
+        (dfgWithoutInline2):
+        (callNotInlineable2):
+        * inspector-protocol/debugger/setBreakpoint-dfg-and-modify-local-expected.txt: Added.
+        * inspector-protocol/debugger/setBreakpoint-dfg-and-modify-local.html: Added.
+
+2014-02-03  Mark Lam  &lt;mark.lam@apple.com&gt;
+
</ins><span class="cx">         Need regression test to ensure that the debugger does not attempt to execute a bad script from its console.
</span><span class="cx">         &lt;https://webkit.org/b/128121&gt;
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkLayoutTestsinspectorprotocoldebuggerresourcesbreakpointjs"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/inspector-protocol/debugger/resources/breakpoint.js (163362 => 163363)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/inspector-protocol/debugger/resources/breakpoint.js        2014-02-04 05:05:43 UTC (rev 163362)
+++ trunk/LayoutTests/inspector-protocol/debugger/resources/breakpoint.js        2014-02-04 05:10:04 UTC (rev 163363)
</span><span class="lines">@@ -56,3 +56,29 @@
</span><span class="cx">         result += inliningFoo(i);
</span><span class="cx">     log(&quot;dfgWithInline result: &quot; + result);    
</span><span class="cx"> }
</span><ins>+
+function notInlineable2(x, callFunctionWithBreakpoint)
+{
+    var func = new Function(&quot;return x + 100;&quot;);
+    if (callFunctionWithBreakpoint)
+        breakpointBasic();
+    return x + 3;
+}
+
+function dfgWithoutInline2()
+{
+    var i;
+    var result = 0;
+    for (i = 0; i &lt; 1000; i++)
+        result += notInlineable2(i, false);
+    log(&quot;result: &quot; + result);
+}
+
+function callNotInlineable2()
+{
+    var result = notInlineable2(10000, true);
+    if (result == 20003)
+        log(&quot;PASS: result is &quot; + result);
+    else
+        log(&quot;FAIL: result is &quot; + result + &quot;, expecting 20003&quot;);
+}
</ins></span></pre></div>
<a id="trunkLayoutTestsinspectorprotocoldebuggersetBreakpointdfgandmodifylocalexpectedtxt"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/inspector-protocol/debugger/setBreakpoint-dfg-and-modify-local-expected.txt (0 => 163363)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/inspector-protocol/debugger/setBreakpoint-dfg-and-modify-local-expected.txt                                (rev 0)
+++ trunk/LayoutTests/inspector-protocol/debugger/setBreakpoint-dfg-and-modify-local-expected.txt        2014-02-04 05:10:04 UTC (rev 163363)
</span><span class="lines">@@ -0,0 +1,14 @@
</span><ins>+Debugger.evaluateOnCallFrame in a DFG compiled functions.
+
+Found breakpoint.js
+result: 502500
+dfg function warmed up
+
+Breakpoint set in breakpointBasic()
+Hit Breakpoint!
+Evaluating in DFG frame at frame[1]: 'x = 20000;'
+Resumed from breakpoint
+inside breakpointBasic
+PASS: result is 20003
+Test complete
+
</ins></span></pre></div>
<a id="trunkLayoutTestsinspectorprotocoldebuggersetBreakpointdfgandmodifylocalhtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/inspector-protocol/debugger/setBreakpoint-dfg-and-modify-local.html (0 => 163363)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/inspector-protocol/debugger/setBreakpoint-dfg-and-modify-local.html                                (rev 0)
+++ trunk/LayoutTests/inspector-protocol/debugger/setBreakpoint-dfg-and-modify-local.html        2014-02-04 05:10:04 UTC (rev 163363)
</span><span class="lines">@@ -0,0 +1,72 @@
</span><ins>+&lt;html&gt;
+&lt;head&gt;
+&lt;script src=&quot;../../http/tests/inspector-protocol/resources/protocol-test.js&quot;&gt;&lt;/script&gt;
+&lt;script src=&quot;resources/breakpoint.js&quot;&gt;&lt;/script&gt;
+
+&lt;script&gt;
+// Put this here instead of on &lt;body onload&gt; to prevent an extra Debugger.scriptParsed event.
+window.onload = runTest;
+
+function test()
+{
+    // This test setting 2 breakpoints in DFG compiled functions: one inlined,
+    // and one not inlined.
+
+    InspectorTest.sendCommand(&quot;Debugger.enable&quot;, {});
+
+    var breakpointId = null;
+    var scriptId = 0;
+    var startLine = 0;
+
+    InspectorTest.eventHandler[&quot;Debugger.scriptParsed&quot;] = function(messageObject)
+    {
+        if (/resources\/breakpoint\.js$/.test(messageObject.params.url)) {
+            InspectorTest.log(&quot;Found breakpoint.js&quot;);
+            scriptId = messageObject.params.scriptId;
+            startLine = messageObject.params.startLine;
+
+            InspectorTest.sendCommand(&quot;Runtime.evaluate&quot;, {
+                expression: &quot;dfgWithoutInline2();&quot;
+            }, function(responseObject) {
+                InspectorTest.log(&quot;dfg function warmed up\n&quot;);
+
+                var location1 = {scriptId: scriptId, lineNumber: 2, columnNumber: 0};
+
+                InspectorTest.sendCommand(&quot;Debugger.setBreakpoint&quot;, {location: location1}, function(responseObject) {
+                    InspectorTest.checkForError(responseObject);
+                    InspectorTest.log(&quot;Breakpoint set in breakpointBasic()&quot;);
+
+                    breakpointId = responseObject.result.breakpointId;
+                    InspectorTest.sendCommand(&quot;Runtime.evaluate&quot;, {
+                        expression: &quot;callNotInlineable2();&quot;
+                    }, function(responseObject) {
+                        InspectorTest.log(&quot;Test complete&quot;);
+                        InspectorTest.completeTest();
+                    });
+                });
+            });
+        }
+    }
+
+    InspectorTest.eventHandler[&quot;Debugger.paused&quot;] = function(messageObject)
+    {
+        InspectorTest.log(&quot;Hit Breakpoint!&quot;);
+        var callFrames = messageObject.params.callFrames;
+        if (callFrames.length &lt; 3)
+            InspectorTest.log(&quot;FAIL: too few frames in stack trace&quot;);
+
+        var callFrameId = callFrames[1].callFrameId;
+        InspectorTest.log(&quot;Evaluating in DFG frame at frame[1]: 'x = 20000;'&quot;);
+        InspectorTest.sendCommand(&quot;Debugger.evaluateOnCallFrame&quot;, { callFrameId: callFrameId, expression: &quot;x = 20000;&quot; }, function(responseObject) {
+            InspectorTest.sendCommand(&quot;Debugger.resume&quot;, {}, function(responseObject) {
+                InspectorTest.log(&quot;Resumed from breakpoint&quot;);
+            });
+        });
+    }
+}
+&lt;/script&gt;
+&lt;/head&gt;
+&lt;body&gt;
+&lt;p&gt;Debugger.evaluateOnCallFrame in a DFG compiled functions.&lt;/p&gt;
+&lt;/body&gt;
+&lt;/html&gt;
</ins></span></pre>
</div>
</div>

</body>
</html>