<!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>[193261] branches/safari-601-branch</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/193261">193261</a></dd>
<dt>Author</dt> <dd>timothy@apple.com</dd>
<dt>Date</dt> <dd>2015-12-03 11:03:08 -0800 (Thu, 03 Dec 2015)</dd>
</dl>

<h3>Log Message</h3>
<pre>Merge <a href="http://trac.webkit.org/projects/webkit/changeset/191355">r191355</a>. rdar://problem/23221163</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#branchessafari601branchLayoutTestsChangeLog">branches/safari-601-branch/LayoutTests/ChangeLog</a></li>
<li><a href="#branchessafari601branchSourceJavaScriptCoreChangeLog">branches/safari-601-branch/Source/JavaScriptCore/ChangeLog</a></li>
<li><a href="#branchessafari601branchSourceJavaScriptCoreinspectorContentSearchUtilitiescpp">branches/safari-601-branch/Source/JavaScriptCore/inspector/ContentSearchUtilities.cpp</a></li>
<li><a href="#branchessafari601branchSourceJavaScriptCoreinspectorContentSearchUtilitiesh">branches/safari-601-branch/Source/JavaScriptCore/inspector/ContentSearchUtilities.h</a></li>
<li><a href="#branchessafari601branchSourceJavaScriptCoreinspectorScriptDebugServercpp">branches/safari-601-branch/Source/JavaScriptCore/inspector/ScriptDebugServer.cpp</a></li>
<li><a href="#branchessafari601branchSourceJavaScriptCoreinspectoragentsInspectorDebuggerAgentcpp">branches/safari-601-branch/Source/JavaScriptCore/inspector/agents/InspectorDebuggerAgent.cpp</a></li>
<li><a href="#branchessafari601branchSourceJavaScriptCoreparserLexercpp">branches/safari-601-branch/Source/JavaScriptCore/parser/Lexer.cpp</a></li>
<li><a href="#branchessafari601branchSourceJavaScriptCoreparserLexerh">branches/safari-601-branch/Source/JavaScriptCore/parser/Lexer.h</a></li>
<li><a href="#branchessafari601branchSourceJavaScriptCoreparserParserh">branches/safari-601-branch/Source/JavaScriptCore/parser/Parser.h</a></li>
<li><a href="#branchessafari601branchSourceJavaScriptCoreparserSourceProviderh">branches/safari-601-branch/Source/JavaScriptCore/parser/SourceProvider.h</a></li>
<li><a href="#branchessafari601branchSourceWebInspectorUIChangeLog">branches/safari-601-branch/Source/WebInspectorUI/ChangeLog</a></li>
</ul>

<h3>Added Paths</h3>
<ul>
<li><a href="#branchessafari601branchLayoutTestsinspectordebuggersourceURLsexpectedtxt">branches/safari-601-branch/LayoutTests/inspector/debugger/sourceURLs-expected.txt</a></li>
<li><a href="#branchessafari601branchLayoutTestsinspectordebuggersourceURLshtml">branches/safari-601-branch/LayoutTests/inspector/debugger/sourceURLs.html</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="branchessafari601branchLayoutTestsChangeLog"></a>
<div class="modfile"><h4>Modified: branches/safari-601-branch/LayoutTests/ChangeLog (193260 => 193261)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-601-branch/LayoutTests/ChangeLog        2015-12-03 19:02:58 UTC (rev 193260)
+++ branches/safari-601-branch/LayoutTests/ChangeLog        2015-12-03 19:03:08 UTC (rev 193261)
</span><span class="lines">@@ -1,5 +1,20 @@
</span><span class="cx"> 2015-12-02  Timothy Hatcher  &lt;timothy@apple.com&gt;
</span><span class="cx"> 
</span><ins>+        Merge r191355. rdar://problem/23221163
+
+    2015-10-20  Joseph Pecoraro  &lt;pecoraro@apple.com&gt;
+
+            Web Inspector: JavaScriptCore should parse sourceURL and sourceMappingURL directives
+            https://bugs.webkit.org/show_bug.cgi?id=150096
+
+            Reviewed by Geoffrey Garen.
+
+            * inspector/debugger/sourceURLs-expected.txt: Added.
+            * inspector/debugger/sourceURLs.html: Added.
+            sourceURL and sourceMappingURL detection.
+
+2015-12-02  Timothy Hatcher  &lt;timothy@apple.com&gt;
+
</ins><span class="cx">         Merge r190780. rdar://problem/23221163
</span><span class="cx"> 
</span><span class="cx">     2015-10-08  Nikita Vasilyev  &lt;nvasilyev@apple.com&gt;
</span></span></pre></div>
<a id="branchessafari601branchLayoutTestsinspectordebuggersourceURLsexpectedtxt"></a>
<div class="addfile"><h4>Added: branches/safari-601-branch/LayoutTests/inspector/debugger/sourceURLs-expected.txt (0 => 193261)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-601-branch/LayoutTests/inspector/debugger/sourceURLs-expected.txt                                (rev 0)
+++ branches/safari-601-branch/LayoutTests/inspector/debugger/sourceURLs-expected.txt        2015-12-03 19:03:08 UTC (rev 193261)
</span><span class="lines">@@ -0,0 +1,26 @@
</span><ins>+Tests for the Debugger.scriptParsed sourceURL and sourceMappingURL comment directive parsing.
+
+
+== Running test suite: Debugger.scriptParsed.sourceURL-directives
+-- Running test case: TestExpressionsForSourceURL
+Found Script with sourceURL 'test1.js'
+Found Script with sourceURL 'test2.js'
+Found Script with sourceURL 'test3.js'
+Found Script with sourceURL 'test4.js'
+Found Script with sourceURL 'test5.js'
+Found Script with sourceURL 'test6.js'
+Found Script with sourceURL 'test7.js'
+Found Script with sourceURL 'test8.js'
+Found Script with sourceURL 'test9.js'
+
+-- Running test case: TestExpressionsForSourceMappingURL
+Found Script with sourceMappingURL 'test1.js'
+Found Script with sourceMappingURL 'test2.js'
+Found Script with sourceMappingURL 'test3.js'
+Found Script with sourceMappingURL 'test4.js'
+Found Script with sourceMappingURL 'test5.js'
+Found Script with sourceMappingURL 'test6.js'
+Found Script with sourceMappingURL 'test7.js'
+Found Script with sourceMappingURL 'test8.js'
+Found Script with sourceMappingURL 'test9.js'
+
</ins></span></pre></div>
<a id="branchessafari601branchLayoutTestsinspectordebuggersourceURLshtml"></a>
<div class="addfile"><h4>Added: branches/safari-601-branch/LayoutTests/inspector/debugger/sourceURLs.html (0 => 193261)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-601-branch/LayoutTests/inspector/debugger/sourceURLs.html                                (rev 0)
+++ branches/safari-601-branch/LayoutTests/inspector/debugger/sourceURLs.html        2015-12-03 19:03:08 UTC (rev 193261)
</span><span class="lines">@@ -0,0 +1,207 @@
</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;
+function test()
+{
+    let suite = ProtocolTest.createAsyncSuite(&quot;Debugger.scriptParsed.sourceURL-directives&quot;);
+
+    // Because InspectorTest output causes scripts to be parsed
+    // we cannot check sourceURL per evaluation easily. Instead
+    // just run a bunch of tests for valid and invalid directives
+    // and check that the output only includes the valid results.
+
+    let expressions = [];
+    let sourceURLExpectations = [];
+    let sourceMappingURLExpectations = [];
+
+    function addInvalidTestCase(args) {
+        let {expression} = args;
+        expressions.push(expression);
+    }
+
+    function addValidTestCase(args) {
+        let {expression, expected} = args;
+        expressions.push(expression);
+        sourceURLExpectations.push(expected);
+        sourceMappingURLExpectations.push(expected);
+    }
+
+    suite.addTestCase({
+        name: &quot;TestExpressionsForSourceURL&quot;,
+        test: (resolve, reject) =&gt; {
+            for (let expression of expressions)
+                ProtocolTest.evaluateInPage(expression);
+
+            InspectorProtocol.eventHandler[&quot;Debugger.scriptParsed&quot;] = function(messageObject) {
+                // Ignore named inspector internal scripts.
+                if (messageObject.params.url.startsWith(&quot;__WebInspector&quot;))
+                    return;
+
+                // Has a sourceURL, must be one of the valid ones.
+                if (messageObject.params.hasSourceURL) {
+                    let sourceURL = messageObject.params.url;
+                    ProtocolTest.log(`Found Script with sourceURL '${sourceURL}'`);
+                    ProtocolTest.assert(sourceURLExpectations[0] === sourceURL, &quot;Did not expect to see sourceURL: &quot; + sourceURL);
+                    sourceURLExpectations.shift();
+                    if (!sourceURLExpectations.length)
+                        resolve();
+                }
+            }
+        }
+    });
+
+    suite.addTestCase({
+        name: &quot;TestExpressionsForSourceMappingURL&quot;,
+        test: (resolve, reject) =&gt; {
+            // Rewrite the &quot;sourceURL&quot; to &quot;sourceMappingURL&quot; in the original expressions.
+            for (let expression of expressions)
+                ProtocolTest.evaluateInPage(expression.replace(/sourceURL/g, &quot;sourceMappingURL&quot;));
+
+            InspectorProtocol.eventHandler[&quot;Debugger.scriptParsed&quot;] = function(messageObject) {
+                // Has a sourceMapURL, must be one of the valid ones.
+                if (messageObject.params.sourceMapURL) {
+                    let sourceMappingURL = messageObject.params.sourceMapURL;
+                    ProtocolTest.log(`Found Script with sourceMappingURL '${sourceMappingURL}'`);
+                    ProtocolTest.assert(sourceMappingURLExpectations[0] === sourceMappingURL, &quot;Did not expect to see sourceMappingURL: &quot; + sourceMappingURL);
+                    sourceMappingURLExpectations.shift();
+                    if (!sourceMappingURLExpectations.length)
+                        resolve();
+                }
+            }
+        }
+    });
+
+    // ------
+
+    addInvalidTestCase({
+        description: &quot;Evaluation without a SourceURL.&quot;,
+        expression: &quot;eval('1')&quot;,
+    });
+
+    addInvalidTestCase({
+        description: &quot;SourceURL missing '#'.&quot;,
+        expression: &quot;eval('// sourceURL=invalid.js')&quot;,
+    });
+
+    addInvalidTestCase({
+        description: &quot;SourceURL missing space after '#'.&quot;,
+        expression: &quot;eval('//#sourceURL=invalid.js')&quot;,
+    });
+
+    addInvalidTestCase({
+        description: &quot;SourceURL with space before '#'.&quot;,
+        expression: &quot;eval('// #sourceURL=invalid.js')&quot;,
+    });
+
+    addInvalidTestCase({
+        description: &quot;SourceURL with multiple spaces after '#'.&quot;,
+        expression: &quot;eval('//#  sourceURL=invalid.js')&quot;,
+    });
+
+    addInvalidTestCase({
+        description: &quot;SourceURL with space between name and '='.&quot;,
+        expression: &quot;eval('//# sourceURL =invalid.js')&quot;,
+    });
+
+    addInvalidTestCase({
+        description: &quot;SourceURL with quotes in value.&quot;,
+        expression: &quot;eval('//# sourceURL=\\\'invalid.js\\\'')&quot;,
+    });
+
+    addInvalidTestCase({
+        description: &quot;SourceURL value must be a single non-whitespace enclosed value.&quot;,
+        expression: &quot;eval('//# sourceURL=invalid.js a')&quot;,
+    });
+
+    addInvalidTestCase({
+        description: &quot;Unknown directive.&quot;,
+        expression: &quot;eval('//# unknown=invalid.js')&quot;,
+    });
+
+    addInvalidTestCase({
+        description: &quot;Missing parts.&quot;,
+        expression: &quot;eval('//#')&quot;,
+    });
+
+    addInvalidTestCase({
+        description: &quot;Missing parts.&quot;,
+        expression: &quot;eval('//# ')&quot;,
+    });
+
+    addInvalidTestCase({
+        description: &quot;Missing parts.&quot;,
+        expression: &quot;eval('//# source')&quot;,
+    });
+
+    addInvalidTestCase({
+        description: &quot;Missing parts.&quot;,
+        expression: &quot;eval('//# sourceURL=')&quot;,
+    });
+
+    // ------
+
+    addValidTestCase({
+        description: &quot;SourceURL basic form.&quot;,
+        expression: &quot;eval('//# sourceURL=test1.js')&quot;,
+        expected: &quot;test1.js&quot;,
+    });
+
+    addValidTestCase({
+        description: &quot;SourceURL extra leading whitespace.&quot;,
+        expression: &quot;eval('//# sourceURL=   test2.js')&quot;,
+        expected: &quot;test2.js&quot;,
+    });
+
+    addValidTestCase({
+        description: &quot;SourceURL extra trailing whitespace.&quot;,
+        expression: &quot;eval('//# sourceURL=test3.js    ')&quot;,
+        expected: &quot;test3.js&quot;,
+    });
+
+    addValidTestCase({
+        description: &quot;SourceURL extra leading and trailing whitespace.&quot;,
+        expression: &quot;eval('//# sourceURL=   test4.js   ')&quot;,
+        expected: &quot;test4.js&quot;,
+    });
+
+    addValidTestCase({
+        description: &quot;SourceURL with tabs.&quot;,
+        expression: &quot;eval('//#\\tsourceURL=test5.js')&quot;,
+        expected: &quot;test5.js&quot;,
+    });
+
+    addValidTestCase({
+        description: &quot;SourceURLs not at the start of a line.&quot;,
+        expression: &quot;eval('1 //# sourceURL=test6.js')&quot;,
+        expected: &quot;test6.js&quot;,
+    });
+
+    addValidTestCase({
+        description: &quot;SourceURL with deprecated '@' instead of '#'.&quot;,
+        expression: &quot;eval('//@ sourceURL=test7.js   ')&quot;,
+        expected: &quot;test7.js&quot;,
+    });
+
+    addValidTestCase({
+        description: &quot;SourceURLs not on the first line.&quot;,
+        expression: &quot;eval('\\n\\n//# sourceURL=test8.js')&quot;,
+        expected: &quot;test8.js&quot;,
+    });
+
+    addValidTestCase({
+        description: &quot;Multiple SourceURLs will return the first.&quot;,
+        expression: &quot;eval('//# sourceURL=test9.js\\n//# sourceURL=second.js')&quot;,
+        expected: &quot;test9.js&quot;,
+    });
+
+    InspectorProtocol.sendCommand(&quot;Debugger.enable&quot;, {});
+    suite.runTestCasesAndFinish();
+}
+&lt;/script&gt;
+&lt;/head&gt;
+&lt;body onload=&quot;runTest()&quot;&gt;
+&lt;p&gt;Tests for the Debugger.scriptParsed sourceURL and sourceMappingURL comment directive parsing.&lt;/p&gt;
+&lt;/body&gt;
+&lt;/html&gt;
</ins></span></pre></div>
<a id="branchessafari601branchSourceJavaScriptCoreChangeLog"></a>
<div class="modfile"><h4>Modified: branches/safari-601-branch/Source/JavaScriptCore/ChangeLog (193260 => 193261)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-601-branch/Source/JavaScriptCore/ChangeLog        2015-12-03 19:02:58 UTC (rev 193260)
+++ branches/safari-601-branch/Source/JavaScriptCore/ChangeLog        2015-12-03 19:03:08 UTC (rev 193261)
</span><span class="lines">@@ -1,5 +1,58 @@
</span><span class="cx"> 2015-12-02  Timothy Hatcher  &lt;timothy@apple.com&gt;
</span><span class="cx"> 
</span><ins>+        Merge r191355. rdar://problem/23221163
+
+    2015-10-20  Joseph Pecoraro  &lt;pecoraro@apple.com&gt;
+
+            Web Inspector: JavaScriptCore should parse sourceURL and sourceMappingURL directives
+            https://bugs.webkit.org/show_bug.cgi?id=150096
+
+            Reviewed by Geoffrey Garen.
+
+            * inspector/ContentSearchUtilities.cpp:
+            (Inspector::ContentSearchUtilities::scriptCommentPattern): Deleted.
+            (Inspector::ContentSearchUtilities::findScriptSourceURL): Deleted.
+            (Inspector::ContentSearchUtilities::findScriptSourceMapURL): Deleted.
+            * inspector/ContentSearchUtilities.h:
+            No longer need to search script content.
+
+            * inspector/ScriptDebugServer.cpp:
+            (Inspector::ScriptDebugServer::dispatchDidParseSource):
+            Carry over the sourceURL and sourceMappingURL from the SourceProvider.
+
+            * inspector/agents/InspectorDebuggerAgent.cpp:
+            (Inspector::InspectorDebuggerAgent::sourceMapURLForScript):
+            (Inspector::InspectorDebuggerAgent::didParseSource):
+            No longer do content searching.
+
+            * parser/Lexer.cpp:
+            (JSC::Lexer&lt;T&gt;::setCode):
+            (JSC::Lexer&lt;T&gt;::skipWhitespace):
+            (JSC::Lexer&lt;T&gt;::parseCommentDirective):
+            (JSC::Lexer&lt;T&gt;::parseCommentDirectiveValue):
+            (JSC::Lexer&lt;T&gt;::consume):
+            (JSC::Lexer&lt;T&gt;::lex):
+            * parser/Lexer.h:
+            (JSC::Lexer::sourceURL):
+            (JSC::Lexer::sourceMappingURL):
+            (JSC::Lexer::sourceProvider): Deleted.
+            Give lexer the ability to detect script comment directives.
+            This just consumes characters in single line comments and
+            ultimately sets the sourceURL or sourceMappingURL found.
+
+            * parser/Parser.h:
+            (JSC::Parser&lt;LexerType&gt;::parse):
+            * parser/SourceProvider.h:
+            (JSC::SourceProvider::url):
+            (JSC::SourceProvider::sourceURL):
+            (JSC::SourceProvider::sourceMappingURL):
+            (JSC::SourceProvider::setSourceURL):
+            (JSC::SourceProvider::setSourceMappingURL):
+            After parsing a script, update the Source Provider with the
+            value of directives that may have been found in the script.
+
+2015-12-02  Timothy Hatcher  &lt;timothy@apple.com&gt;
+
</ins><span class="cx">         Merge r190542. rdar://problem/23221163
</span><span class="cx"> 
</span><span class="cx">     2015-10-02  Matt Baker  &lt;mattbaker@apple.com&gt;
</span></span></pre></div>
<a id="branchessafari601branchSourceJavaScriptCoreinspectorContentSearchUtilitiescpp"></a>
<div class="modfile"><h4>Modified: branches/safari-601-branch/Source/JavaScriptCore/inspector/ContentSearchUtilities.cpp (193260 => 193261)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-601-branch/Source/JavaScriptCore/inspector/ContentSearchUtilities.cpp        2015-12-03 19:02:58 UTC (rev 193260)
+++ branches/safari-601-branch/Source/JavaScriptCore/inspector/ContentSearchUtilities.cpp        2015-12-03 19:03:08 UTC (rev 193261)
</span><span class="lines">@@ -166,12 +166,6 @@
</span><span class="cx">     return result;
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-static String scriptCommentPattern(const String&amp; name)
-{
-    // &quot;//# &lt;name&gt;=&lt;value&gt;&quot; and deprecated &quot;//@&quot;
-    return &quot;//[#@][\040\t]&quot; + name + &quot;=[\040\t]*([^\\s\'\&quot;]*)[\040\t]*$&quot;;
-}
-
</del><span class="cx"> static String stylesheetCommentPattern(const String&amp; name)
</span><span class="cx"> {
</span><span class="cx">     // &quot;/*# &lt;name&gt;=&lt;value&gt; */&quot; and deprecated &quot;/*@&quot;
</span><span class="lines">@@ -199,16 +193,6 @@
</span><span class="cx">     return content.substring(matches[2], matches[3] - matches[2]);
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-String findScriptSourceURL(const String&amp; content)
-{
-    return findMagicComment(content, scriptCommentPattern(ASCIILiteral(&quot;sourceURL&quot;)));
-}
-
-String findScriptSourceMapURL(const String&amp; content)
-{
-    return findMagicComment(content, scriptCommentPattern(ASCIILiteral(&quot;sourceMappingURL&quot;)));
-}
-
</del><span class="cx"> String findStylesheetSourceMapURL(const String&amp; content)
</span><span class="cx"> {
</span><span class="cx">     return findMagicComment(content, stylesheetCommentPattern(ASCIILiteral(&quot;sourceMappingURL&quot;)));
</span></span></pre></div>
<a id="branchessafari601branchSourceJavaScriptCoreinspectorContentSearchUtilitiesh"></a>
<div class="modfile"><h4>Modified: branches/safari-601-branch/Source/JavaScriptCore/inspector/ContentSearchUtilities.h (193260 => 193261)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-601-branch/Source/JavaScriptCore/inspector/ContentSearchUtilities.h        2015-12-03 19:02:58 UTC (rev 193260)
+++ branches/safari-601-branch/Source/JavaScriptCore/inspector/ContentSearchUtilities.h        2015-12-03 19:03:08 UTC (rev 193261)
</span><span class="lines">@@ -48,8 +48,6 @@
</span><span class="cx"> JS_EXPORT_PRIVATE TextPosition textPositionFromOffset(size_t offset, const Vector&lt;size_t&gt;&amp; lineEndings);
</span><span class="cx"> JS_EXPORT_PRIVATE std::unique_ptr&lt;Vector&lt;size_t&gt;&gt; lineEndings(const String&amp;);
</span><span class="cx"> 
</span><del>-JS_EXPORT_PRIVATE String findScriptSourceURL(const String&amp; content);
-JS_EXPORT_PRIVATE String findScriptSourceMapURL(const String&amp; content);
</del><span class="cx"> JS_EXPORT_PRIVATE String findStylesheetSourceMapURL(const String&amp; content);
</span><span class="cx"> 
</span><span class="cx"> } // namespace ContentSearchUtilities
</span></span></pre></div>
<a id="branchessafari601branchSourceJavaScriptCoreinspectorScriptDebugServercpp"></a>
<div class="modfile"><h4>Modified: branches/safari-601-branch/Source/JavaScriptCore/inspector/ScriptDebugServer.cpp (193260 => 193261)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-601-branch/Source/JavaScriptCore/inspector/ScriptDebugServer.cpp        2015-12-03 19:02:58 UTC (rev 193260)
+++ branches/safari-601-branch/Source/JavaScriptCore/inspector/ScriptDebugServer.cpp        2015-12-03 19:03:08 UTC (rev 193261)
</span><span class="lines">@@ -207,6 +207,8 @@
</span><span class="cx">     script.startLine = sourceProvider-&gt;startPosition().m_line.zeroBasedInt();
</span><span class="cx">     script.startColumn = sourceProvider-&gt;startPosition().m_column.zeroBasedInt();
</span><span class="cx">     script.isContentScript = isContentScript;
</span><ins>+    script.sourceURL = sourceProvider-&gt;sourceURL();
+    script.sourceMappingURL = sourceProvider-&gt;sourceMappingURL();
</ins><span class="cx"> 
</span><span class="cx">     int sourceLength = script.source.length();
</span><span class="cx">     int lineCount = 1;
</span></span></pre></div>
<a id="branchessafari601branchSourceJavaScriptCoreinspectoragentsInspectorDebuggerAgentcpp"></a>
<div class="modfile"><h4>Modified: branches/safari-601-branch/Source/JavaScriptCore/inspector/agents/InspectorDebuggerAgent.cpp (193260 => 193261)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-601-branch/Source/JavaScriptCore/inspector/agents/InspectorDebuggerAgent.cpp        2015-12-03 19:02:58 UTC (rev 193260)
+++ branches/safari-601-branch/Source/JavaScriptCore/inspector/agents/InspectorDebuggerAgent.cpp        2015-12-03 19:03:08 UTC (rev 193261)
</span><span class="lines">@@ -606,20 +606,16 @@
</span><span class="cx"> 
</span><span class="cx"> String InspectorDebuggerAgent::sourceMapURLForScript(const Script&amp; script)
</span><span class="cx"> {
</span><del>-    return ContentSearchUtilities::findScriptSourceMapURL(script.source);
</del><ins>+    return script.sourceMappingURL;
</ins><span class="cx"> }
</span><span class="cx"> 
</span><del>-void InspectorDebuggerAgent::didParseSource(JSC::SourceID sourceID, const Script&amp; inScript)
</del><ins>+void InspectorDebuggerAgent::didParseSource(JSC::SourceID sourceID, const Script&amp; script)
</ins><span class="cx"> {
</span><del>-    Script script = inScript;
-    if (script.startLine &lt;= 0 &amp;&amp; !script.startColumn)
-        script.sourceURL = ContentSearchUtilities::findScriptSourceURL(script.source);
-    script.sourceMappingURL = sourceMapURLForScript(script);
-
</del><span class="cx">     bool hasSourceURL = !script.sourceURL.isEmpty();
</span><span class="cx">     String scriptURL = hasSourceURL ? script.sourceURL : script.url;
</span><span class="cx">     bool* hasSourceURLParam = hasSourceURL ? &amp;hasSourceURL : nullptr;
</span><del>-    String* sourceMapURLParam = script.sourceMappingURL.isNull() ? nullptr : &amp;script.sourceMappingURL;
</del><ins>+    String sourceMappingURL = sourceMapURLForScript(script);
+    String* sourceMapURLParam = sourceMappingURL.isNull() ? nullptr : &amp;sourceMappingURL;
</ins><span class="cx">     const bool* isContentScript = script.isContentScript ? &amp;script.isContentScript : nullptr;
</span><span class="cx">     String scriptIDStr = String::number(sourceID);
</span><span class="cx">     m_frontendDispatcher-&gt;scriptParsed(scriptIDStr, scriptURL, script.startLine, script.startColumn, script.endLine, script.endColumn, isContentScript, sourceMapURLParam, hasSourceURLParam);
</span></span></pre></div>
<a id="branchessafari601branchSourceJavaScriptCoreparserLexercpp"></a>
<div class="modfile"><h4>Modified: branches/safari-601-branch/Source/JavaScriptCore/parser/Lexer.cpp (193260 => 193261)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-601-branch/Source/JavaScriptCore/parser/Lexer.cpp        2015-12-03 19:02:58 UTC (rev 193260)
+++ branches/safari-601-branch/Source/JavaScriptCore/parser/Lexer.cpp        2015-12-03 19:03:08 UTC (rev 193261)
</span><span class="lines">@@ -25,23 +25,21 @@
</span><span class="cx"> #include &quot;config.h&quot;
</span><span class="cx"> #include &quot;Lexer.h&quot;
</span><span class="cx"> 
</span><ins>+#include &quot;BuiltinNames.h&quot;
+#include &quot;Identifier.h&quot;
+#include &quot;JSCInlines.h&quot;
</ins><span class="cx"> #include &quot;JSFunctionInlines.h&quot;
</span><del>-
-#include &quot;BuiltinNames.h&quot;
</del><span class="cx"> #include &quot;JSGlobalObjectFunctions.h&quot;
</span><del>-#include &quot;Identifier.h&quot;
</del><ins>+#include &quot;KeywordLookup.h&quot;
+#include &quot;Lexer.lut.h&quot;
</ins><span class="cx"> #include &quot;Nodes.h&quot;
</span><del>-#include &quot;JSCInlines.h&quot;
-#include &lt;wtf/dtoa.h&gt;
</del><ins>+#include &quot;Parser.h&quot;
</ins><span class="cx"> #include &lt;ctype.h&gt;
</span><span class="cx"> #include &lt;limits.h&gt;
</span><span class="cx"> #include &lt;string.h&gt;
</span><span class="cx"> #include &lt;wtf/Assertions.h&gt;
</span><ins>+#include &lt;wtf/dtoa.h&gt;
</ins><span class="cx"> 
</span><del>-#include &quot;KeywordLookup.h&quot;
-#include &quot;Lexer.lut.h&quot;
-#include &quot;Parser.h&quot;
-
</del><span class="cx"> namespace JSC {
</span><span class="cx"> 
</span><span class="cx"> Keywords::Keywords(VM&amp; vm)
</span><span class="lines">@@ -566,6 +564,8 @@
</span><span class="cx">     m_atLineStart = true;
</span><span class="cx">     m_lineStart = m_code;
</span><span class="cx">     m_lexErrorMessage = String();
</span><ins>+    m_sourceURLDirective = String();
+    m_sourceMappingURLDirective = String();
</ins><span class="cx">     
</span><span class="cx">     m_buffer8.reserveInitialCapacity(initialReadBufferCapacity);
</span><span class="cx">     m_buffer16.reserveInitialCapacity((m_codeEnd - m_code) / 2);
</span><span class="lines">@@ -689,6 +689,13 @@
</span><span class="cx">     return m_lastToken == CONTINUE || m_lastToken == BREAK || m_lastToken == RETURN || m_lastToken == THROW;
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+template &lt;typename T&gt;
+ALWAYS_INLINE void Lexer&lt;T&gt;::skipWhitespace()
+{
+    while (isWhiteSpace(m_current))
+        shift();
+}
+
</ins><span class="cx"> static NEVER_INLINE bool isNonLatin1IdentStart(UChar c)
</span><span class="cx"> {
</span><span class="cx">     return U_GET_GC_MASK(c) &amp; U_GC_L_MASK;
</span><span class="lines">@@ -1706,6 +1713,60 @@
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> template &lt;typename T&gt;
</span><ins>+ALWAYS_INLINE void Lexer&lt;T&gt;::parseCommentDirective()
+{
+    // sourceURL and sourceMappingURL directives.
+    if (!consume(&quot;source&quot;))
+        return;
+
+    if (consume(&quot;URL=&quot;)) {
+        if (!m_sourceURLDirective.isEmpty())
+            return;
+        m_sourceURLDirective = parseCommentDirectiveValue();
+        return;
+    }
+
+    if (consume(&quot;MappingURL=&quot;)) {
+        if (!m_sourceMappingURLDirective.isEmpty())
+            return;
+        m_sourceMappingURLDirective = parseCommentDirectiveValue();
+        return;
+    }
+}
+
+template &lt;typename T&gt;
+ALWAYS_INLINE String Lexer&lt;T&gt;::parseCommentDirectiveValue()
+{
+    skipWhitespace();
+    const T* stringStart = currentSourcePtr();
+    while (!isWhiteSpace(m_current) &amp;&amp; !isLineTerminator(m_current) &amp;&amp; m_current != '&quot;' &amp;&amp; m_current != '\'' &amp;&amp; !atEnd())
+        shift();
+    const T* stringEnd = currentSourcePtr();
+    skipWhitespace();
+
+    if (!isLineTerminator(m_current) &amp;&amp; !atEnd())
+        return String();
+
+    append8(stringStart, stringEnd - stringStart);
+    String result = String(m_buffer8.data(), m_buffer8.size());
+    m_buffer8.shrink(0);
+    return result;
+}
+
+template &lt;typename T&gt;
+template &lt;unsigned length&gt;
+ALWAYS_INLINE bool Lexer&lt;T&gt;::consume(const char (&amp;input)[length])
+{
+    unsigned lengthToCheck = length - 1; // Ignore the ending NULL byte in the string literal.
+
+    unsigned i = 0;
+    for (; i &lt; lengthToCheck &amp;&amp; m_current == input[i]; i++)
+        shift();
+
+    return i == lengthToCheck;
+}
+
+template &lt;typename T&gt;
</ins><span class="cx"> bool Lexer&lt;T&gt;::nextTokenIsColon()
</span><span class="cx"> {
</span><span class="cx">     const T* code = m_code;
</span><span class="lines">@@ -1742,8 +1803,7 @@
</span><span class="cx">     m_terminator = false;
</span><span class="cx"> 
</span><span class="cx"> start:
</span><del>-    while (isWhiteSpace(m_current))
-        shift();
</del><ins>+    skipWhitespace();
</ins><span class="cx"> 
</span><span class="cx">     if (atEnd())
</span><span class="cx">         return EOFTOK;
</span><span class="lines">@@ -1901,7 +1961,7 @@
</span><span class="cx">         shift();
</span><span class="cx">         if (m_current == '/') {
</span><span class="cx">             shift();
</span><del>-            goto inSingleLineComment;
</del><ins>+            goto inSingleLineCommentCheckForDirectives;
</ins><span class="cx">         }
</span><span class="cx">         if (m_current == '*') {
</span><span class="cx">             shift();
</span><span class="lines">@@ -2207,6 +2267,15 @@
</span><span class="cx">     m_atLineStart = false;
</span><span class="cx">     goto returnToken;
</span><span class="cx"> 
</span><ins>+inSingleLineCommentCheckForDirectives:
+    // Script comment directives like &quot;//# sourceURL=test.js&quot;.
+    if (UNLIKELY((m_current == '#' || m_current == '@') &amp;&amp; isWhiteSpace(peek(1)))) {
+        shift();
+        shift();
+        parseCommentDirective();
+    }
+    // Fall through to complete single line comment parsing.
+
</ins><span class="cx"> inSingleLineComment:
</span><span class="cx">     while (!isLineTerminator(m_current)) {
</span><span class="cx">         if (atEnd())
</span></span></pre></div>
<a id="branchessafari601branchSourceJavaScriptCoreparserLexerh"></a>
<div class="modfile"><h4>Modified: branches/safari-601-branch/Source/JavaScriptCore/parser/Lexer.h (193260 => 193261)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-601-branch/Source/JavaScriptCore/parser/Lexer.h        2015-12-03 19:02:58 UTC (rev 193260)
+++ branches/safari-601-branch/Source/JavaScriptCore/parser/Lexer.h        2015-12-03 19:03:08 UTC (rev 193261)
</span><span class="lines">@@ -114,6 +114,8 @@
</span><span class="cx">     // Functions for use after parsing.
</span><span class="cx">     bool sawError() const { return m_error; }
</span><span class="cx">     String getErrorMessage() const { return m_lexErrorMessage; }
</span><ins>+    String sourceURL() const { return m_sourceURLDirective; }
+    String sourceMappingURL() const { return m_sourceMappingURLDirective; }
</ins><span class="cx">     void clear();
</span><span class="cx">     void setOffset(int offset, int lineStartOffset)
</span><span class="cx">     {
</span><span class="lines">@@ -140,8 +142,6 @@
</span><span class="cx">         m_terminator = terminator;
</span><span class="cx">     }
</span><span class="cx"> 
</span><del>-    SourceProvider* sourceProvider() const { return m_source-&gt;provider(); }
-
</del><span class="cx">     JSTokenType lexExpectIdentifier(JSToken*, unsigned, bool strictMode);
</span><span class="cx"> 
</span><span class="cx"> private:
</span><span class="lines">@@ -178,6 +178,8 @@
</span><span class="cx">     ALWAYS_INLINE const Identifier* makeEmptyIdentifier();
</span><span class="cx"> 
</span><span class="cx">     ALWAYS_INLINE bool lastTokenWasRestrKeyword() const;
</span><ins>+    
+    ALWAYS_INLINE void skipWhitespace();
</ins><span class="cx"> 
</span><span class="cx">     template &lt;int shiftAmount&gt; void internalShift();
</span><span class="cx">     template &lt;bool shouldCreateIdentifier&gt; ALWAYS_INLINE JSTokenType parseKeyword(JSTokenData*);
</span><span class="lines">@@ -204,6 +206,12 @@
</span><span class="cx">     ALWAYS_INLINE bool parseNumberAfterExponentIndicator();
</span><span class="cx">     ALWAYS_INLINE bool parseMultilineComment();
</span><span class="cx"> 
</span><ins>+    ALWAYS_INLINE void parseCommentDirective();
+    ALWAYS_INLINE String parseCommentDirectiveValue();
+
+    template &lt;unsigned length&gt;
+    ALWAYS_INLINE bool consume(const char (&amp;input)[length]);
+
</ins><span class="cx">     static const size_t initialReadBufferCapacity = 32;
</span><span class="cx"> 
</span><span class="cx">     int m_lineNumber;
</span><span class="lines">@@ -229,6 +237,9 @@
</span><span class="cx">     bool m_error;
</span><span class="cx">     String m_lexErrorMessage;
</span><span class="cx"> 
</span><ins>+    String m_sourceURLDirective;
+    String m_sourceMappingURLDirective;
+
</ins><span class="cx">     T m_current;
</span><span class="cx"> 
</span><span class="cx">     IdentifierArena* m_arena;
</span></span></pre></div>
<a id="branchessafari601branchSourceJavaScriptCoreparserParserh"></a>
<div class="modfile"><h4>Modified: branches/safari-601-branch/Source/JavaScriptCore/parser/Parser.h (193260 => 193261)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-601-branch/Source/JavaScriptCore/parser/Parser.h        2015-12-03 19:02:58 UTC (rev 193260)
+++ branches/safari-601-branch/Source/JavaScriptCore/parser/Parser.h        2015-12-03 19:03:08 UTC (rev 193261)
</span><span class="lines">@@ -1026,6 +1026,9 @@
</span><span class="cx">                                     m_numConstants);
</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><ins>+
+        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>
<a id="branchessafari601branchSourceJavaScriptCoreparserSourceProviderh"></a>
<div class="modfile"><h4>Modified: branches/safari-601-branch/Source/JavaScriptCore/parser/SourceProvider.h (193260 => 193261)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-601-branch/Source/JavaScriptCore/parser/SourceProvider.h        2015-12-03 19:02:58 UTC (rev 193260)
+++ branches/safari-601-branch/Source/JavaScriptCore/parser/SourceProvider.h        2015-12-03 19:03:08 UTC (rev 193261)
</span><span class="lines">@@ -49,7 +49,10 @@
</span><span class="cx">             return source().substringSharingImpl(start, end - start);
</span><span class="cx">         }
</span><span class="cx"> 
</span><del>-        const String&amp; url() { return m_url; }
</del><ins>+        const String&amp; url() const { return m_url; }
+        const String&amp; sourceURL() const { return m_sourceURLDirective; }
+        const String&amp; sourceMappingURL() const { return m_sourceMappingURLDirective; }
+
</ins><span class="cx">         TextPosition startPosition() const { return m_startPosition; }
</span><span class="cx">         intptr_t asID()
</span><span class="cx">         {
</span><span class="lines">@@ -62,11 +65,17 @@
</span><span class="cx">         void setValid() { m_validated = true; }
</span><span class="cx"> 
</span><span class="cx">     private:
</span><ins>+        template &lt;typename T&gt; friend class Parser;
</ins><span class="cx"> 
</span><ins>+        void setSourceURLDirective(const String&amp; sourceURL) { m_sourceURLDirective = sourceURL; }
+        void setSourceMappingURLDirective(const String&amp; sourceMappingURL) { m_sourceMappingURLDirective = sourceMappingURL; }
+
</ins><span class="cx">         JS_EXPORT_PRIVATE void getID();
</span><span class="cx">         Vector&lt;size_t&gt;&amp; lineStarts();
</span><span class="cx"> 
</span><span class="cx">         String m_url;
</span><ins>+        String m_sourceURLDirective;
+        String m_sourceMappingURLDirective;
</ins><span class="cx">         TextPosition m_startPosition;
</span><span class="cx">         bool m_validated : 1;
</span><span class="cx">         uintptr_t m_id : sizeof(uintptr_t) * 8 - 1;
</span></span></pre></div>
<a id="branchessafari601branchSourceWebInspectorUIChangeLog"></a>
<div class="modfile"><h4>Modified: branches/safari-601-branch/Source/WebInspectorUI/ChangeLog (193260 => 193261)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-601-branch/Source/WebInspectorUI/ChangeLog        2015-12-03 19:02:58 UTC (rev 193260)
+++ branches/safari-601-branch/Source/WebInspectorUI/ChangeLog        2015-12-03 19:03:08 UTC (rev 193261)
</span><span class="lines">@@ -1,5 +1,22 @@
</span><span class="cx"> 2015-12-02  Timothy Hatcher  &lt;timothy@apple.com&gt;
</span><span class="cx"> 
</span><ins>+        Merge r191355. rdar://problem/23221163
+
+    2015-10-20  Joseph Pecoraro  &lt;pecoraro@apple.com&gt;
+
+            Web Inspector: JavaScriptCore should parse sourceURL and sourceMappingURL directives
+            https://bugs.webkit.org/show_bug.cgi?id=150096
+
+            Reviewed by Geoffrey Garen.
+
+            * UserInterface/Test/InspectorProtocol.js:
+            (InspectorProtocol._sendMessage):
+            (InspectorProtocol.dispatchMessageFromBackend):
+            This is only used for tests, so avoid console.log
+            and just dump directly to the system console.
+
+2015-12-02  Timothy Hatcher  &lt;timothy@apple.com&gt;
+
</ins><span class="cx">         Merge r191281. rdar://problem/23221163
</span><span class="cx"> 
</span><span class="cx">     2015-10-19  James Craig  &lt;jcraig@apple.com&gt;
</span></span></pre>
</div>
</div>

</body>
</html>