<!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>[191135] 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/191135">191135</a></dd>
<dt>Author</dt> <dd>commit-queue@webkit.org</dd>
<dt>Date</dt> <dd>2015-10-15 13:50:02 -0700 (Thu, 15 Oct 2015)</dd>
</dl>
<h3>Log Message</h3>
<pre>Web Inspector: JavaScriptCore should parse sourceURL and sourceMappingURL directives
https://bugs.webkit.org/show_bug.cgi?id=150096
Patch by Joseph Pecoraro <pecoraro@apple.com> on 2015-10-15
Reviewed by Geoffrey Garen.
Source/JavaScriptCore:
* 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<T>::setCode):
(JSC::Lexer<T>::skipWhitespace):
(JSC::Lexer<T>::parseCommentDirective):
(JSC::Lexer<T>::parseCommentDirectiveValue):
(JSC::Lexer<T>::consume):
(JSC::Lexer<T>::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<LexerType>::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.
Source/WebInspectorUI:
* 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.
LayoutTests:
* inspector/debugger/sourceURLs-expected.txt: Added.
* inspector/debugger/sourceURLs.html: Added.
sourceURL and sourceMappingURL detection.</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="#trunkSourceJavaScriptCoreinspectorContentSearchUtilitiescpp">trunk/Source/JavaScriptCore/inspector/ContentSearchUtilities.cpp</a></li>
<li><a href="#trunkSourceJavaScriptCoreinspectorContentSearchUtilitiesh">trunk/Source/JavaScriptCore/inspector/ContentSearchUtilities.h</a></li>
<li><a href="#trunkSourceJavaScriptCoreinspectorScriptDebugServercpp">trunk/Source/JavaScriptCore/inspector/ScriptDebugServer.cpp</a></li>
<li><a href="#trunkSourceJavaScriptCoreinspectoragentsInspectorDebuggerAgentcpp">trunk/Source/JavaScriptCore/inspector/agents/InspectorDebuggerAgent.cpp</a></li>
<li><a href="#trunkSourceJavaScriptCoreparserLexercpp">trunk/Source/JavaScriptCore/parser/Lexer.cpp</a></li>
<li><a href="#trunkSourceJavaScriptCoreparserLexerh">trunk/Source/JavaScriptCore/parser/Lexer.h</a></li>
<li><a href="#trunkSourceJavaScriptCoreparserParserh">trunk/Source/JavaScriptCore/parser/Parser.h</a></li>
<li><a href="#trunkSourceJavaScriptCoreparserSourceProviderh">trunk/Source/JavaScriptCore/parser/SourceProvider.h</a></li>
<li><a href="#trunkSourceWebInspectorUIChangeLog">trunk/Source/WebInspectorUI/ChangeLog</a></li>
<li><a href="#trunkSourceWebInspectorUIUserInterfaceTestInspectorProtocoljs">trunk/Source/WebInspectorUI/UserInterface/Test/InspectorProtocol.js</a></li>
</ul>
<h3>Added Paths</h3>
<ul>
<li><a href="#trunkLayoutTestsinspectordebuggersourceURLsexpectedtxt">trunk/LayoutTests/inspector/debugger/sourceURLs-expected.txt</a></li>
<li><a href="#trunkLayoutTestsinspectordebuggersourceURLshtml">trunk/LayoutTests/inspector/debugger/sourceURLs.html</a></li>
</ul>
</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkLayoutTestsChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/ChangeLog (191134 => 191135)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/ChangeLog        2015-10-15 20:34:10 UTC (rev 191134)
+++ trunk/LayoutTests/ChangeLog        2015-10-15 20:50:02 UTC (rev 191135)
</span><span class="lines">@@ -1,3 +1,14 @@
</span><ins>+2015-10-15 Joseph Pecoraro <pecoraro@apple.com>
+
+ 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.
+
</ins><span class="cx"> 2015-10-15 Dean Jackson <dino@apple.com>
</span><span class="cx">
</span><span class="cx"> CSSKeyframesRule::appendRule is deprecated, but is actually the spec
</span></span></pre></div>
<a id="trunkLayoutTestsinspectordebuggersourceURLsexpectedtxt"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/inspector/debugger/sourceURLs-expected.txt (0 => 191135)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/inspector/debugger/sourceURLs-expected.txt         (rev 0)
+++ trunk/LayoutTests/inspector/debugger/sourceURLs-expected.txt        2015-10-15 20:50:02 UTC (rev 191135)
</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="trunkLayoutTestsinspectordebuggersourceURLshtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/inspector/debugger/sourceURLs.html (0 => 191135)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/inspector/debugger/sourceURLs.html         (rev 0)
+++ trunk/LayoutTests/inspector/debugger/sourceURLs.html        2015-10-15 20:50:02 UTC (rev 191135)
</span><span class="lines">@@ -0,0 +1,207 @@
</span><ins>+<!DOCTYPE html>
+<html>
+<head>
+<script src="../../http/tests/inspector/resources/protocol-test.js"></script>
+<script>
+function test()
+{
+ let suite = ProtocolTest.createAsyncSuite("Debugger.scriptParsed.sourceURL-directives");
+
+ // 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: "TestExpressionsForSourceURL",
+ test: (resolve, reject) => {
+ for (let expression of expressions)
+ ProtocolTest.evaluateInPage(expression);
+
+ InspectorProtocol.eventHandler["Debugger.scriptParsed"] = function(messageObject) {
+ // Ignore named inspector internal scripts.
+ if (messageObject.params.url.startsWith("__WebInspector"))
+ 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, "Did not expect to see sourceURL: " + sourceURL);
+ sourceURLExpectations.shift();
+ if (!sourceURLExpectations.length)
+ resolve();
+ }
+ }
+ }
+ });
+
+ suite.addTestCase({
+ name: "TestExpressionsForSourceMappingURL",
+ test: (resolve, reject) => {
+ // Rewrite the "sourceURL" to "sourceMappingURL" in the original expressions.
+ for (let expression of expressions)
+ ProtocolTest.evaluateInPage(expression.replace(/sourceURL/g, "sourceMappingURL"));
+
+ InspectorProtocol.eventHandler["Debugger.scriptParsed"] = 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, "Did not expect to see sourceMappingURL: " + sourceMappingURL);
+ sourceMappingURLExpectations.shift();
+ if (!sourceMappingURLExpectations.length)
+ resolve();
+ }
+ }
+ }
+ });
+
+ // ------
+
+ addInvalidTestCase({
+ description: "Evaluation without a SourceURL.",
+ expression: "eval('1')",
+ });
+
+ addInvalidTestCase({
+ description: "SourceURL missing '#'.",
+ expression: "eval('// sourceURL=invalid.js')",
+ });
+
+ addInvalidTestCase({
+ description: "SourceURL missing space after '#'.",
+ expression: "eval('//#sourceURL=invalid.js')",
+ });
+
+ addInvalidTestCase({
+ description: "SourceURL with space before '#'.",
+ expression: "eval('// #sourceURL=invalid.js')",
+ });
+
+ addInvalidTestCase({
+ description: "SourceURL with multiple spaces after '#'.",
+ expression: "eval('//# sourceURL=invalid.js')",
+ });
+
+ addInvalidTestCase({
+ description: "SourceURL with space between name and '='.",
+ expression: "eval('//# sourceURL =invalid.js')",
+ });
+
+ addInvalidTestCase({
+ description: "SourceURL with quotes in value.",
+ expression: "eval('//# sourceURL=\\\'invalid.js\\\'')",
+ });
+
+ addInvalidTestCase({
+ description: "SourceURL value must be a single non-whitespace enclosed value.",
+ expression: "eval('//# sourceURL=invalid.js a')",
+ });
+
+ addInvalidTestCase({
+ description: "Unknown directive.",
+ expression: "eval('//# unknown=invalid.js')",
+ });
+
+ addInvalidTestCase({
+ description: "Missing parts.",
+ expression: "eval('//#')",
+ });
+
+ addInvalidTestCase({
+ description: "Missing parts.",
+ expression: "eval('//# ')",
+ });
+
+ addInvalidTestCase({
+ description: "Missing parts.",
+ expression: "eval('//# source')",
+ });
+
+ addInvalidTestCase({
+ description: "Missing parts.",
+ expression: "eval('//# sourceURL=')",
+ });
+
+ // ------
+
+ addValidTestCase({
+ description: "SourceURL basic form.",
+ expression: "eval('//# sourceURL=test1.js')",
+ expected: "test1.js",
+ });
+
+ addValidTestCase({
+ description: "SourceURL extra leading whitespace.",
+ expression: "eval('//# sourceURL= test2.js')",
+ expected: "test2.js",
+ });
+
+ addValidTestCase({
+ description: "SourceURL extra trailing whitespace.",
+ expression: "eval('//# sourceURL=test3.js ')",
+ expected: "test3.js",
+ });
+
+ addValidTestCase({
+ description: "SourceURL extra leading and trailing whitespace.",
+ expression: "eval('//# sourceURL= test4.js ')",
+ expected: "test4.js",
+ });
+
+ addValidTestCase({
+ description: "SourceURL with tabs.",
+ expression: "eval('//#\\tsourceURL=test5.js')",
+ expected: "test5.js",
+ });
+
+ addValidTestCase({
+ description: "SourceURLs not at the start of a line.",
+ expression: "eval('1 //# sourceURL=test6.js')",
+ expected: "test6.js",
+ });
+
+ addValidTestCase({
+ description: "SourceURL with deprecated '@' instead of '#'.",
+ expression: "eval('//@ sourceURL=test7.js ')",
+ expected: "test7.js",
+ });
+
+ addValidTestCase({
+ description: "SourceURLs not on the first line.",
+ expression: "eval('\\n\\n//# sourceURL=test8.js')",
+ expected: "test8.js",
+ });
+
+ addValidTestCase({
+ description: "Multiple SourceURLs will return the first.",
+ expression: "eval('//# sourceURL=test9.js\\n//# sourceURL=second.js')",
+ expected: "test9.js",
+ });
+
+ InspectorProtocol.sendCommand("Debugger.enable", {});
+ suite.runTestCasesAndFinish();
+}
+</script>
+</head>
+<body onload="runTest()">
+<p>Tests for the Debugger.scriptParsed sourceURL and sourceMappingURL comment directive parsing.</p>
+</body>
+</html>
</ins></span></pre></div>
<a id="trunkSourceJavaScriptCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/ChangeLog (191134 => 191135)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/ChangeLog        2015-10-15 20:34:10 UTC (rev 191134)
+++ trunk/Source/JavaScriptCore/ChangeLog        2015-10-15 20:50:02 UTC (rev 191135)
</span><span class="lines">@@ -1,3 +1,52 @@
</span><ins>+2015-10-15 Joseph Pecoraro <pecoraro@apple.com>
+
+ 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<T>::setCode):
+ (JSC::Lexer<T>::skipWhitespace):
+ (JSC::Lexer<T>::parseCommentDirective):
+ (JSC::Lexer<T>::parseCommentDirectiveValue):
+ (JSC::Lexer<T>::consume):
+ (JSC::Lexer<T>::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<LexerType>::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.
+
</ins><span class="cx"> 2015-10-15 Filip Pizlo <fpizlo@apple.com>
</span><span class="cx">
</span><span class="cx"> InferredTypeTable should ref its keys
</span></span></pre></div>
<a id="trunkSourceJavaScriptCoreinspectorContentSearchUtilitiescpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/inspector/ContentSearchUtilities.cpp (191134 => 191135)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/inspector/ContentSearchUtilities.cpp        2015-10-15 20:34:10 UTC (rev 191134)
+++ trunk/Source/JavaScriptCore/inspector/ContentSearchUtilities.cpp        2015-10-15 20:50:02 UTC (rev 191135)
</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& name)
-{
- // "//# <name>=<value>" and deprecated "//@"
- return "//[#@][\040\t]" + name + "=[\040\t]*([^\\s\'\"]*)[\040\t]*$";
-}
-
</del><span class="cx"> static String stylesheetCommentPattern(const String& name)
</span><span class="cx"> {
</span><span class="cx"> // "/*# <name>=<value> */" and deprecated "/*@"
</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& content)
-{
- return findMagicComment(content, scriptCommentPattern(ASCIILiteral("sourceURL")));
-}
-
-String findScriptSourceMapURL(const String& content)
-{
- return findMagicComment(content, scriptCommentPattern(ASCIILiteral("sourceMappingURL")));
-}
-
</del><span class="cx"> String findStylesheetSourceMapURL(const String& content)
</span><span class="cx"> {
</span><span class="cx"> return findMagicComment(content, stylesheetCommentPattern(ASCIILiteral("sourceMappingURL")));
</span></span></pre></div>
<a id="trunkSourceJavaScriptCoreinspectorContentSearchUtilitiesh"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/inspector/ContentSearchUtilities.h (191134 => 191135)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/inspector/ContentSearchUtilities.h        2015-10-15 20:34:10 UTC (rev 191134)
+++ trunk/Source/JavaScriptCore/inspector/ContentSearchUtilities.h        2015-10-15 20:50:02 UTC (rev 191135)
</span><span class="lines">@@ -48,8 +48,6 @@
</span><span class="cx"> JS_EXPORT_PRIVATE TextPosition textPositionFromOffset(size_t offset, const Vector<size_t>& lineEndings);
</span><span class="cx"> JS_EXPORT_PRIVATE std::unique_ptr<Vector<size_t>> lineEndings(const String&);
</span><span class="cx">
</span><del>-JS_EXPORT_PRIVATE String findScriptSourceURL(const String& content);
-JS_EXPORT_PRIVATE String findScriptSourceMapURL(const String& content);
</del><span class="cx"> JS_EXPORT_PRIVATE String findStylesheetSourceMapURL(const String& content);
</span><span class="cx">
</span><span class="cx"> } // namespace ContentSearchUtilities
</span></span></pre></div>
<a id="trunkSourceJavaScriptCoreinspectorScriptDebugServercpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/inspector/ScriptDebugServer.cpp (191134 => 191135)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/inspector/ScriptDebugServer.cpp        2015-10-15 20:34:10 UTC (rev 191134)
+++ trunk/Source/JavaScriptCore/inspector/ScriptDebugServer.cpp        2015-10-15 20:50:02 UTC (rev 191135)
</span><span class="lines">@@ -207,6 +207,8 @@
</span><span class="cx"> script.startLine = sourceProvider->startPosition().m_line.zeroBasedInt();
</span><span class="cx"> script.startColumn = sourceProvider->startPosition().m_column.zeroBasedInt();
</span><span class="cx"> script.isContentScript = isContentScript;
</span><ins>+ script.sourceURL = sourceProvider->sourceURL();
+ script.sourceMappingURL = sourceProvider->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="trunkSourceJavaScriptCoreinspectoragentsInspectorDebuggerAgentcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/inspector/agents/InspectorDebuggerAgent.cpp (191134 => 191135)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/inspector/agents/InspectorDebuggerAgent.cpp        2015-10-15 20:34:10 UTC (rev 191134)
+++ trunk/Source/JavaScriptCore/inspector/agents/InspectorDebuggerAgent.cpp        2015-10-15 20:50:02 UTC (rev 191135)
</span><span class="lines">@@ -604,20 +604,16 @@
</span><span class="cx">
</span><span class="cx"> String InspectorDebuggerAgent::sourceMapURLForScript(const Script& 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& inScript)
</del><ins>+void InspectorDebuggerAgent::didParseSource(JSC::SourceID sourceID, const Script& script)
</ins><span class="cx"> {
</span><del>- Script script = inScript;
- if (script.startLine <= 0 && !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 ? &hasSourceURL : nullptr;
</span><del>- String* sourceMapURLParam = script.sourceMappingURL.isNull() ? nullptr : &script.sourceMappingURL;
</del><ins>+ String sourceMappingURL = sourceMapURLForScript(script);
+ String* sourceMapURLParam = sourceMappingURL.isNull() ? nullptr : &sourceMappingURL;
</ins><span class="cx"> const bool* isContentScript = script.isContentScript ? &script.isContentScript : nullptr;
</span><span class="cx"> String scriptIDStr = String::number(sourceID);
</span><span class="cx"> m_frontendDispatcher->scriptParsed(scriptIDStr, scriptURL, script.startLine, script.startColumn, script.endLine, script.endColumn, isContentScript, sourceMapURLParam, hasSourceURLParam);
</span></span></pre></div>
<a id="trunkSourceJavaScriptCoreparserLexercpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/parser/Lexer.cpp (191134 => 191135)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/parser/Lexer.cpp        2015-10-15 20:34:10 UTC (rev 191134)
+++ trunk/Source/JavaScriptCore/parser/Lexer.cpp        2015-10-15 20:50:02 UTC (rev 191135)
</span><span class="lines">@@ -25,23 +25,21 @@
</span><span class="cx"> #include "config.h"
</span><span class="cx"> #include "Lexer.h"
</span><span class="cx">
</span><ins>+#include "BuiltinNames.h"
+#include "Identifier.h"
+#include "JSCInlines.h"
</ins><span class="cx"> #include "JSFunctionInlines.h"
</span><del>-
-#include "BuiltinNames.h"
</del><span class="cx"> #include "JSGlobalObjectFunctions.h"
</span><del>-#include "Identifier.h"
</del><ins>+#include "KeywordLookup.h"
+#include "Lexer.lut.h"
</ins><span class="cx"> #include "Nodes.h"
</span><del>-#include "JSCInlines.h"
-#include <wtf/dtoa.h>
</del><ins>+#include "Parser.h"
</ins><span class="cx"> #include <ctype.h>
</span><span class="cx"> #include <limits.h>
</span><span class="cx"> #include <string.h>
</span><span class="cx"> #include <wtf/Assertions.h>
</span><ins>+#include <wtf/dtoa.h>
</ins><span class="cx">
</span><del>-#include "KeywordLookup.h"
-#include "Lexer.lut.h"
-#include "Parser.h"
-
</del><span class="cx"> namespace JSC {
</span><span class="cx">
</span><span class="cx"> bool isLexerKeyword(const Identifier& identifier)
</span><span class="lines">@@ -565,6 +563,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_sourceURL = String();
+ m_sourceMappingURL = 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">@@ -688,6 +688,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 <typename T>
+ALWAYS_INLINE void Lexer<T>::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) & U_GC_L_MASK;
</span><span class="lines">@@ -1705,6 +1712,58 @@
</span><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> template <typename T>
</span><ins>+ALWAYS_INLINE void Lexer<T>::parseCommentDirective()
+{
+ // sourceURL and sourceMappingURL directives.
+ if (!consume("source"))
+ return;
+
+ if (consume("URL=")) {
+ if (!m_sourceURL.isEmpty())
+ return;
+ m_sourceURL = parseCommentDirectiveValue();
+ return;
+ }
+
+ if (consume("MappingURL=")) {
+ if (!m_sourceMappingURL.isEmpty())
+ return;
+ m_sourceMappingURL = parseCommentDirectiveValue();
+ return;
+ }
+}
+
+template <typename T>
+ALWAYS_INLINE String Lexer<T>::parseCommentDirectiveValue()
+{
+ skipWhitespace();
+ const T* stringStart = currentSourcePtr();
+ while (!isWhiteSpace(m_current) && !isLineTerminator(m_current) && m_current != '"' && m_current != '\'' && !atEnd())
+ shift();
+ const T* stringEnd = currentSourcePtr();
+ skipWhitespace();
+
+ if (!isLineTerminator(m_current) && !atEnd())
+ return String();
+
+ append8(stringStart, stringEnd - stringStart);
+ return String(m_buffer8.data(), m_buffer8.size());
+}
+
+template <typename T>
+template <unsigned length>
+ALWAYS_INLINE bool Lexer<T>::consume(const char (&input)[length])
+{
+ unsigned lengthToCheck = length - 1; // Ignore the ending NUL byte in the string literal.
+
+ unsigned i = 0;
+ for (; i < lengthToCheck && m_current == input[i]; i++)
+ shift();
+
+ return i == lengthToCheck;
+}
+
+template <typename T>
</ins><span class="cx"> bool Lexer<T>::nextTokenIsColon()
</span><span class="cx"> {
</span><span class="cx"> const T* code = m_code;
</span><span class="lines">@@ -1739,8 +1798,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">@@ -1898,7 +1956,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">@@ -2203,6 +2261,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 "//# sourceURL=test.js".
+ if (UNLIKELY((m_current == '#' || m_current == '@') && 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="trunkSourceJavaScriptCoreparserLexerh"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/parser/Lexer.h (191134 => 191135)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/parser/Lexer.h        2015-10-15 20:34:10 UTC (rev 191134)
+++ trunk/Source/JavaScriptCore/parser/Lexer.h        2015-10-15 20:50:02 UTC (rev 191135)
</span><span class="lines">@@ -88,6 +88,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_sourceURL; }
+ String sourceMappingURL() const { return m_sourceMappingURL; }
</ins><span class="cx"> void clear();
</span><span class="cx"> void setOffset(int offset, int lineStartOffset)
</span><span class="cx"> {
</span><span class="lines">@@ -114,8 +116,6 @@
</span><span class="cx"> m_terminator = terminator;
</span><span class="cx"> }
</span><span class="cx">
</span><del>- SourceProvider* sourceProvider() const { return m_source->provider(); }
-
</del><span class="cx"> JSTokenType lexExpectIdentifier(JSToken*, unsigned, bool strictMode);
</span><span class="cx">
</span><span class="cx"> private:
</span><span class="lines">@@ -152,6 +152,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 <int shiftAmount> void internalShift();
</span><span class="cx"> template <bool shouldCreateIdentifier> ALWAYS_INLINE JSTokenType parseKeyword(JSTokenData*);
</span><span class="lines">@@ -178,6 +180,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 <unsigned length>
+ ALWAYS_INLINE bool consume(const char (&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">@@ -203,6 +211,9 @@
</span><span class="cx"> bool m_error;
</span><span class="cx"> String m_lexErrorMessage;
</span><span class="cx">
</span><ins>+ String m_sourceURL;
+ String m_sourceMappingURL;
+
</ins><span class="cx"> T m_current;
</span><span class="cx">
</span><span class="cx"> IdentifierArena* m_arena;
</span></span></pre></div>
<a id="trunkSourceJavaScriptCoreparserParserh"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/parser/Parser.h (191134 => 191135)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/parser/Parser.h        2015-10-15 20:34:10 UTC (rev 191134)
+++ trunk/Source/JavaScriptCore/parser/Parser.h        2015-10-15 20:50:02 UTC (rev 191135)
</span><span class="lines">@@ -1329,6 +1329,9 @@
</span><span class="cx"> m_numConstants);
</span><span class="cx"> result->setLoc(m_source->firstLine(), m_lexer->lineNumber(), m_lexer->currentOffset(), m_lexer->currentLineStartOffset());
</span><span class="cx"> result->setEndOffset(m_lexer->currentOffset());
</span><ins>+
+ m_source->provider()->setSourceURL(m_lexer->sourceURL());
+ m_source->provider()->setSourceMappingURL(m_lexer->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="trunkSourceJavaScriptCoreparserSourceProviderh"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/parser/SourceProvider.h (191134 => 191135)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/parser/SourceProvider.h        2015-10-15 20:34:10 UTC (rev 191134)
+++ trunk/Source/JavaScriptCore/parser/SourceProvider.h        2015-10-15 20:50:02 UTC (rev 191135)
</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& url() { return m_url; }
</del><ins>+ const String& url() const { return m_url; }
+ const String& sourceURL() const { return m_sourceURL; }
+ const String& sourceMappingURL() const { return m_sourceMappingURL; }
+
</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 <typename T> friend class Parser;
</ins><span class="cx">
</span><ins>+ void setSourceURL(const String& sourceURL) { m_sourceURL = sourceURL; }
+ void setSourceMappingURL(const String& sourceMappingURL) { m_sourceMappingURL = sourceMappingURL; }
+
</ins><span class="cx"> JS_EXPORT_PRIVATE void getID();
</span><span class="cx"> Vector<size_t>& lineStarts();
</span><span class="cx">
</span><span class="cx"> String m_url;
</span><ins>+ String m_sourceURL;
+ String m_sourceMappingURL;
</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="trunkSourceWebInspectorUIChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebInspectorUI/ChangeLog (191134 => 191135)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebInspectorUI/ChangeLog        2015-10-15 20:34:10 UTC (rev 191134)
+++ trunk/Source/WebInspectorUI/ChangeLog        2015-10-15 20:50:02 UTC (rev 191135)
</span><span class="lines">@@ -1,3 +1,16 @@
</span><ins>+2015-10-15 Joseph Pecoraro <pecoraro@apple.com>
+
+ 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.
+
</ins><span class="cx"> 2015-10-13 João Oliveira <hello@jxs.pt>
</span><span class="cx">
</span><span class="cx"> Web Inspector: Console SearchBar should work more like ContentBrowser FindBanner
</span></span></pre></div>
<a id="trunkSourceWebInspectorUIUserInterfaceTestInspectorProtocoljs"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebInspectorUI/UserInterface/Test/InspectorProtocol.js (191134 => 191135)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebInspectorUI/UserInterface/Test/InspectorProtocol.js        2015-10-15 20:34:10 UTC (rev 191134)
+++ trunk/Source/WebInspectorUI/UserInterface/Test/InspectorProtocol.js        2015-10-15 20:50:02 UTC (rev 191135)
</span><span class="lines">@@ -89,7 +89,7 @@
</span><span class="cx"> let messageString = typeof messageObject !== "string" ? JSON.stringify(messageObject) : messageObject;
</span><span class="cx">
</span><span class="cx"> if (ProtocolTest.dumpInspectorProtocolMessages)
</span><del>- console.log(`frontend: ${messageString}`);
</del><ins>+ InspectorFrontendHost.unbufferedLog(`frontend: ${messageString}`);
</ins><span class="cx">
</span><span class="cx"> InspectorFrontendHost.sendMessageToBackend(messageString);
</span><span class="cx"> }
</span><span class="lines">@@ -134,7 +134,7 @@
</span><span class="cx"> // This matches the debug dumping in InspectorBackend, which is bypassed
</span><span class="cx"> // by InspectorProtocol. Return messages should be dumped by InspectorBackend.
</span><span class="cx"> if (ProtocolTest.dumpInspectorProtocolMessages)
</span><del>- console.log("backend: " + JSON.stringify(messageObject));
</del><ins>+ InspectorFrontendHost.unbufferedLog("backend: " + JSON.stringify(messageObject));
</ins><span class="cx">
</span><span class="cx"> // If the message has an id, then it is a reply to a command.
</span><span class="cx"> let messageId = messageObject.id;
</span></span></pre>
</div>
</div>
</body>
</html>