<!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>[191839] 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/191839">191839</a></dd>
<dt>Author</dt> <dd>commit-queue@webkit.org</dd>
<dt>Date</dt> <dd>2015-10-30 21:58:28 -0700 (Fri, 30 Oct 2015)</dd>
</dl>

<h3>Log Message</h3>
<pre>Web Inspector: Test Debugger.scriptParsed events received after opening inspector frontend
https://bugs.webkit.org/show_bug.cgi?id=150753

Patch by Joseph Pecoraro &lt;pecoraro@apple.com&gt; on 2015-10-30
Reviewed by Timothy Hatcher.

Source/JavaScriptCore:

* parser/Parser.h:
(JSC::Parser&lt;LexerType&gt;::parse):
Only set the directives on the SourceProvider if we were parsing the
entire file (Program or Module), not if we are in function parsing mode.
This was inadvertently clearing the directives stored on the
SourceProvider when the function parse didn't see directives and reset
the values on the source provider.

LayoutTests:

Explicit test for the scriptParsed events we expect to see
when first opening the inspector on an already open page.
We do not expect to see some scripts (built-ins) but do expect
to see all user scripts evaluated on the page.

* inspector/debugger/scriptParsed-expected.txt: Added.
* inspector/debugger/scriptParsed.html: Added.</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkLayoutTestsChangeLog">trunk/LayoutTests/ChangeLog</a></li>
<li><a href="#trunkSourceJavaScriptCoreChangeLog">trunk/Source/JavaScriptCore/ChangeLog</a></li>
<li><a href="#trunkSourceJavaScriptCoreparserParserh">trunk/Source/JavaScriptCore/parser/Parser.h</a></li>
</ul>

<h3>Added Paths</h3>
<ul>
<li><a href="#trunkLayoutTestsinspectordebuggerscriptParsedexpectedtxt">trunk/LayoutTests/inspector/debugger/scriptParsed-expected.txt</a></li>
<li><a href="#trunkLayoutTestsinspectordebuggerscriptParsedhtml">trunk/LayoutTests/inspector/debugger/scriptParsed.html</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkLayoutTestsChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/ChangeLog (191838 => 191839)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/ChangeLog        2015-10-31 04:03:58 UTC (rev 191838)
+++ trunk/LayoutTests/ChangeLog        2015-10-31 04:58:28 UTC (rev 191839)
</span><span class="lines">@@ -1,3 +1,18 @@
</span><ins>+2015-10-30  Joseph Pecoraro  &lt;pecoraro@apple.com&gt;
+
+        Web Inspector: Test Debugger.scriptParsed events received after opening inspector frontend
+        https://bugs.webkit.org/show_bug.cgi?id=150753
+
+        Reviewed by Timothy Hatcher.
+
+        Explicit test for the scriptParsed events we expect to see
+        when first opening the inspector on an already open page.
+        We do not expect to see some scripts (built-ins) but do expect
+        to see all user scripts evaluated on the page.
+
+        * inspector/debugger/scriptParsed-expected.txt: Added.
+        * inspector/debugger/scriptParsed.html: Added.
+
</ins><span class="cx"> 2015-10-28  Wenson Hsieh  &lt;wenson_hsieh@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         Inner height behavior when the keyboard is shown should match on WKWebView and MobileSafari
</span></span></pre></div>
<a id="trunkLayoutTestsinspectordebuggerscriptParsedexpectedtxt"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/inspector/debugger/scriptParsed-expected.txt (0 => 191839)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/inspector/debugger/scriptParsed-expected.txt                                (rev 0)
+++ trunk/LayoutTests/inspector/debugger/scriptParsed-expected.txt        2015-10-31 04:58:28 UTC (rev 191839)
</span><span class="lines">@@ -0,0 +1,15 @@
</span><ins>+Tests for the Debugger.scriptParsed messages the frontend receives when enabling the Debugger domain.
+
+
+== Running test suite: Debugger.scriptParsed.enable
+-- Running test case: EnableDebuggerDomainAndCheckInitialScripts
+Debugger Enabled - Initial Scripts Received
+PASS: Should have received some scriptParsed messages.
+PASS: Should find External Script.
+PASS: Should find Inline Script Tag Script.
+PASS: Should find Inline Attribute Event Listener Script.
+PASS: Should find Eval Script.
+PASS: Should find Inspector InjectedScriptSource Script.
+PASS: Should find Inspector CommandLineAPISource Script.
+PASS: Should not receive any unexpected scripts.
+
</ins></span></pre></div>
<a id="trunkLayoutTestsinspectordebuggerscriptParsedhtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/inspector/debugger/scriptParsed.html (0 => 191839)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/inspector/debugger/scriptParsed.html                                (rev 0)
+++ trunk/LayoutTests/inspector/debugger/scriptParsed.html        2015-10-31 04:58:28 UTC (rev 191839)
</span><span class="lines">@@ -0,0 +1,123 @@
</span><ins>+&lt;!DOCTYPE html&gt;
+&lt;html&gt;
+&lt;head&gt;
+&lt;script src=&quot;../../http/tests/inspector/resources/protocol-test.js&quot;&gt;&lt;/script&gt;
+&lt;script&gt;
+// Create a named eval.
+eval(&quot;//# sourceURL=eval.js\nfunction foo() { }&quot;);
+
+function test()
+{
+    let suite = ProtocolTest.createAsyncSuite(&quot;Debugger.scriptParsed.enable&quot;);
+
+    ProtocolTest.dumpActivityToSystemConsole = true;
+    ProtocolTest.dumpInspectorProtocolMessages = true;
+
+    // Because InspectorTest output causes scripts to be parsed
+    // this test only checks the scripts the frontend is notified
+    // of when enabling the Debugger domain.
+    //
+    // Scripts we expect to see (in an undefined order)
+    //   - external &lt;script&gt; protocol-test.js
+    //   - inline &lt;script&gt; (this) starting on line 5
+    //   - inline body onload event listener attribute on &lt;body&gt; line below
+    //   - eval source above on line 7
+    //   - inspector internal scripts InjectedScriptSource.js CommandLineAPIModuleSource.js
+
+    let foundExternalScript = false;
+    let foundInlineScriptTagScript = false;
+    let foundInlineAttributeEventListenerScript = false;
+    let foundEvalScript = false;
+    let foundInjectedScriptSourceScript = false;
+    let foundCommandLineAPISourceScript = false;
+    let foundUnexpectedScript = false;
+
+    function isExternalScript(params) {
+        return /inspector\/resources\/protocol-test\.js/.test(params.url);
+    }
+
+    function isInlineScript(params) {
+        return /inspector\/debugger\/scriptParsed\.html$/.test(params.url);
+    }
+
+    function isInlineScriptTagScript(params) {
+        return isInlineScript(params) &amp;&amp; params.startLine === 4;
+    }
+
+    function isInlineAttributeEventListenerScript(params) {
+        return isInlineScript(params) &amp;&amp; params.startLine &gt;= 100; // Estimate of &lt;body&gt; below.
+    }
+
+    function isEvalScript(params) {
+        return params.hasSourceURL &amp;&amp; params.url === &quot;eval.js&quot;;
+    }
+
+    function isInjectedScriptSourceScript(params) {
+        return params.hasSourceURL &amp;&amp; params.url === &quot;__WebInspectorInjectedScript__&quot;;
+    }
+
+    function isCommandLineAPISourceScript(params) {
+        return params.hasSourceURL &amp;&amp; params.url === &quot;__WebInspectorCommandLineAPIModuleSource__&quot;;
+    }
+
+    suite.addTestCase({
+        name: &quot;EnableDebuggerDomainAndCheckInitialScripts&quot;,
+        test: (resolve, reject) =&gt; {
+
+            let initialScriptParsedMessages = [];
+            let receivingInitialScripts = true;
+            InspectorProtocol.sendCommand(&quot;Debugger.enable&quot;, {}, function() {
+                receivingInitialScripts = false;
+
+                ProtocolTest.log(&quot;Debugger Enabled - Initial Scripts Received&quot;);
+                ProtocolTest.expectThat(initialScriptParsedMessages.length &gt; 0, &quot;Should have received some scriptParsed messages.&quot;);
+
+                for (let messageObject of initialScriptParsedMessages) {
+                    let params = messageObject.params;
+                    if (!foundExternalScript &amp;&amp; isExternalScript(params))
+                        foundExternalScript = true;
+                    else if (!foundInlineScriptTagScript &amp;&amp; isInlineScriptTagScript(params))
+                        foundInlineScriptTagScript = true;
+                    else if (!foundInlineAttributeEventListenerScript &amp;&amp; isInlineAttributeEventListenerScript(params))
+                        foundInlineAttributeEventListenerScript = true;
+                    else if (!foundEvalScript &amp;&amp; isEvalScript(params))
+                        foundEvalScript = true;
+                    else if (!foundInjectedScriptSourceScript &amp;&amp; isInjectedScriptSourceScript(params))
+                        foundInjectedScriptSourceScript = true;
+                    else if (!foundCommandLineAPISourceScript &amp;&amp; isCommandLineAPISourceScript(params))
+                        foundCommandLineAPISourceScript = true;
+                    else {
+                        ProtocolTest.log(&quot;UNEXPECTED SCRIPT: &quot; + JSON.stringify(messageObject));
+                        foundUnexpectedScript = true;
+                    }
+                }
+
+                ProtocolTest.expectThat(foundExternalScript, &quot;Should find External Script.&quot;);
+                ProtocolTest.expectThat(foundInlineScriptTagScript, &quot;Should find Inline Script Tag Script.&quot;);
+                ProtocolTest.expectThat(foundInlineAttributeEventListenerScript, &quot;Should find Inline Attribute Event Listener Script.&quot;);
+                ProtocolTest.expectThat(foundEvalScript, &quot;Should find Eval Script.&quot;);
+                ProtocolTest.expectThat(foundInjectedScriptSourceScript, &quot;Should find Inspector InjectedScriptSource Script.&quot;);
+                ProtocolTest.expectThat(foundCommandLineAPISourceScript, &quot;Should find Inspector CommandLineAPISource Script.&quot;);
+                ProtocolTest.expectThat(!foundUnexpectedScript, &quot;Should not receive any unexpected scripts.&quot;);
+
+                resolve();
+            });
+
+            InspectorProtocol.eventHandler[&quot;Debugger.scriptParsed&quot;] = function(messageObject) {
+                // Ignore non-initial load scripts.
+                if (!receivingInitialScripts)
+                    return;
+
+                initialScriptParsedMessages.push(messageObject);
+            };
+        }
+    });
+
+    suite.runTestCasesAndFinish();
+}
+&lt;/script&gt;
+&lt;/head&gt;
+&lt;body onload=&quot;runTest()&quot;&gt; &lt;!-- This line number is important --&gt;
+&lt;p&gt;Tests for the Debugger.scriptParsed messages the frontend receives when enabling the Debugger domain.&lt;/p&gt;
+&lt;/body&gt;
+&lt;/html&gt;
</ins></span></pre></div>
<a id="trunkSourceJavaScriptCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/ChangeLog (191838 => 191839)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/ChangeLog        2015-10-31 04:03:58 UTC (rev 191838)
+++ trunk/Source/JavaScriptCore/ChangeLog        2015-10-31 04:58:28 UTC (rev 191839)
</span><span class="lines">@@ -1,3 +1,18 @@
</span><ins>+2015-10-30  Joseph Pecoraro  &lt;pecoraro@apple.com&gt;
+
+        Web Inspector: Test Debugger.scriptParsed events received after opening inspector frontend
+        https://bugs.webkit.org/show_bug.cgi?id=150753
+
+        Reviewed by Timothy Hatcher.
+
+        * parser/Parser.h:
+        (JSC::Parser&lt;LexerType&gt;::parse):
+        Only set the directives on the SourceProvider if we were parsing the
+        entire file (Program or Module), not if we are in function parsing mode.
+        This was inadvertently clearing the directives stored on the
+        SourceProvider when the function parse didn't see directives and reset
+        the values on the source provider.
+
</ins><span class="cx"> 2015-10-30  Benjamin Poulain  &lt;bpoulain@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         [JSC] Add lowering for B3's Sub operation with integers
</span></span></pre></div>
<a id="trunkSourceJavaScriptCoreparserParserh"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/parser/Parser.h (191838 => 191839)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/parser/Parser.h        2015-10-31 04:03:58 UTC (rev 191838)
+++ trunk/Source/JavaScriptCore/parser/Parser.h        2015-10-31 04:58:28 UTC (rev 191839)
</span><span class="lines">@@ -1330,8 +1330,10 @@
</span><span class="cx">         result-&gt;setLoc(m_source-&gt;firstLine(), m_lexer-&gt;lineNumber(), m_lexer-&gt;currentOffset(), m_lexer-&gt;currentLineStartOffset());
</span><span class="cx">         result-&gt;setEndOffset(m_lexer-&gt;currentOffset());
</span><span class="cx"> 
</span><del>-        m_source-&gt;provider()-&gt;setSourceURLDirective(m_lexer-&gt;sourceURL());
-        m_source-&gt;provider()-&gt;setSourceMappingURLDirective(m_lexer-&gt;sourceMappingURL());
</del><ins>+        if (!isFunctionParseMode(parseMode)) {
+            m_source-&gt;provider()-&gt;setSourceURLDirective(m_lexer-&gt;sourceURL());
+            m_source-&gt;provider()-&gt;setSourceMappingURLDirective(m_lexer-&gt;sourceMappingURL());
+        }
</ins><span class="cx">     } else {
</span><span class="cx">         // We can never see a syntax error when reparsing a function, since we should have
</span><span class="cx">         // reported the error when parsing the containing program or eval code. So if we're
</span></span></pre>
</div>
</div>

</body>
</html>