<!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>[209492] 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/209492">209492</a></dd>
<dt>Author</dt> <dd>joepeck@webkit.org</dd>
<dt>Date</dt> <dd>2016-12-07 16:04:13 -0800 (Wed, 07 Dec 2016)</dd>
</dl>

<h3>Log Message</h3>
<pre>Web Inspector: Add ability to distinguish if a Script was parsed as a module
https://bugs.webkit.org/show_bug.cgi?id=164900
&lt;rdar://problem/29323817&gt;

Reviewed by Timothy Hatcher.

Source/JavaScriptCore:

* inspector/agents/InspectorDebuggerAgent.cpp:
(Inspector::InspectorDebuggerAgent::didParseSource):
* inspector/protocol/Debugger.json:
Add an optional event parameter to distinguish if a script was a module or not.

Source/WebInspectorUI:

* UserInterface/Models/Script.js:
(WebInspector.Script.prototype.get sourceType):
New property of Scripts. SourceType is either Program or Module.

* UserInterface/Controllers/DebuggerManager.js:
(WebInspector.DebuggerManager.prototype.scriptDidParse):
* UserInterface/Protocol/DebuggerObserver.js:
(WebInspector.DebuggerObserver.prototype.scriptParsed):
Convert incoming module boolean into SourceType when creating new Scripts.

* UserInterface/Models/ScriptSyntaxTree.js:
(WebInspector.ScriptSyntaxTree):
(WebInspector.ScriptSyntaxTree.prototype._recurse):
(WebInspector.ScriptSyntaxTree.prototype._createInternalSyntaxTree):
Update the generic AST for new module specific Esprima types.

* UserInterface/Views/SourceCodeTextEditor.js:
(WebInspector.SourceCodeTextEditor.prototype.textEditorScriptSourceType):
* UserInterface/Views/TextEditor.js:
(WebInspector.TextEditor.prototype._startWorkerPrettyPrint):
For pretty printing correctly state if this is a module or not for Esprima.

LayoutTests:

* inspector/model/parse-script-syntax-tree-expected.txt:
* inspector/model/parse-script-syntax-tree.html:
* inspector/model/resources/module.js: Added.
(import.string_appeared_here.myModule):
* inspector/model/resources/other-module.js: Added.
(myOtherModule):
* inspector/model/resources/program.js: Added.
(myProgram):
* inspector/model/script-sourceType-expected.txt: Added.
* inspector/model/script-sourceType.html: Added.</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkLayoutTestsChangeLog">trunk/LayoutTests/ChangeLog</a></li>
<li><a href="#trunkLayoutTestsinspectormodelparsescriptsyntaxtreeexpectedtxt">trunk/LayoutTests/inspector/model/parse-script-syntax-tree-expected.txt</a></li>
<li><a href="#trunkLayoutTestsinspectormodelparsescriptsyntaxtreehtml">trunk/LayoutTests/inspector/model/parse-script-syntax-tree.html</a></li>
<li><a href="#trunkSourceJavaScriptCoreChangeLog">trunk/Source/JavaScriptCore/ChangeLog</a></li>
<li><a href="#trunkSourceJavaScriptCoreinspectoragentsInspectorDebuggerAgentcpp">trunk/Source/JavaScriptCore/inspector/agents/InspectorDebuggerAgent.cpp</a></li>
<li><a href="#trunkSourceJavaScriptCoreinspectorprotocolDebuggerjson">trunk/Source/JavaScriptCore/inspector/protocol/Debugger.json</a></li>
<li><a href="#trunkSourceWebInspectorUIChangeLog">trunk/Source/WebInspectorUI/ChangeLog</a></li>
<li><a href="#trunkSourceWebInspectorUIUserInterfaceControllersDebuggerManagerjs">trunk/Source/WebInspectorUI/UserInterface/Controllers/DebuggerManager.js</a></li>
<li><a href="#trunkSourceWebInspectorUIUserInterfaceModelsScriptjs">trunk/Source/WebInspectorUI/UserInterface/Models/Script.js</a></li>
<li><a href="#trunkSourceWebInspectorUIUserInterfaceModelsScriptSyntaxTreejs">trunk/Source/WebInspectorUI/UserInterface/Models/ScriptSyntaxTree.js</a></li>
<li><a href="#trunkSourceWebInspectorUIUserInterfaceProtocolDebuggerObserverjs">trunk/Source/WebInspectorUI/UserInterface/Protocol/DebuggerObserver.js</a></li>
<li><a href="#trunkSourceWebInspectorUIUserInterfaceViewsSourceCodeTextEditorjs">trunk/Source/WebInspectorUI/UserInterface/Views/SourceCodeTextEditor.js</a></li>
<li><a href="#trunkSourceWebInspectorUIUserInterfaceViewsTextEditorjs">trunk/Source/WebInspectorUI/UserInterface/Views/TextEditor.js</a></li>
</ul>

<h3>Added Paths</h3>
<ul>
<li><a href="#trunkLayoutTestsinspectormodelresourcesmodulejs">trunk/LayoutTests/inspector/model/resources/module.js</a></li>
<li><a href="#trunkLayoutTestsinspectormodelresourcesothermodulejs">trunk/LayoutTests/inspector/model/resources/other-module.js</a></li>
<li><a href="#trunkLayoutTestsinspectormodelresourcesprogramjs">trunk/LayoutTests/inspector/model/resources/program.js</a></li>
<li><a href="#trunkLayoutTestsinspectormodelscriptsourceTypeexpectedtxt">trunk/LayoutTests/inspector/model/script-sourceType-expected.txt</a></li>
<li><a href="#trunkLayoutTestsinspectormodelscriptsourceTypehtml">trunk/LayoutTests/inspector/model/script-sourceType.html</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkLayoutTestsChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/ChangeLog (209491 => 209492)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/ChangeLog        2016-12-08 00:04:07 UTC (rev 209491)
+++ trunk/LayoutTests/ChangeLog        2016-12-08 00:04:13 UTC (rev 209492)
</span><span class="lines">@@ -1,5 +1,24 @@
</span><span class="cx"> 2016-12-07  Joseph Pecoraro  &lt;pecoraro@apple.com&gt;
</span><span class="cx"> 
</span><ins>+        Web Inspector: Add ability to distinguish if a Script was parsed as a module
+        https://bugs.webkit.org/show_bug.cgi?id=164900
+        &lt;rdar://problem/29323817&gt;
+
+        Reviewed by Timothy Hatcher.
+
+        * inspector/model/parse-script-syntax-tree-expected.txt:
+        * inspector/model/parse-script-syntax-tree.html:
+        * inspector/model/resources/module.js: Added.
+        (import.string_appeared_here.myModule):
+        * inspector/model/resources/other-module.js: Added.
+        (myOtherModule):
+        * inspector/model/resources/program.js: Added.
+        (myProgram):
+        * inspector/model/script-sourceType-expected.txt: Added.
+        * inspector/model/script-sourceType.html: Added.
+
+2016-12-07  Joseph Pecoraro  &lt;pecoraro@apple.com&gt;
+
</ins><span class="cx">         Web Inspector: Update Esprima to support new features / syntax (**, async/await, trailing comma)
</span><span class="cx">         https://bugs.webkit.org/show_bug.cgi?id=164830
</span><span class="cx">         &lt;rdar://problem/29293814&gt;
</span></span></pre></div>
<a id="trunkLayoutTestsinspectormodelparsescriptsyntaxtreeexpectedtxt"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/inspector/model/parse-script-syntax-tree-expected.txt (209491 => 209492)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/inspector/model/parse-script-syntax-tree-expected.txt        2016-12-08 00:04:07 UTC (rev 209491)
+++ trunk/LayoutTests/inspector/model/parse-script-syntax-tree-expected.txt        2016-12-08 00:04:13 UTC (rev 209492)
</span><span class="lines">@@ -45,6 +45,12 @@
</span><span class="cx"> passed ArrowFunctionExpression
</span><span class="cx"> passed Async Functions
</span><span class="cx"> passed AwaitExpression
</span><ins>+passed ImportDeclaration, ImportSpecifier
+passed ImportDefaultSpecifier
+passed ImportNamespaceSpecifier
+passed ExportNamedDeclaration, ExportSpecifier
+passed ExportDefaultDeclaration
+passed ExportAllDeclaration
</ins><span class="cx"> passed computed method on object literal
</span><span class="cx"> passed method on object literal
</span><span class="cx"> passed computed method property on object literal
</span></span></pre></div>
<a id="trunkLayoutTestsinspectormodelparsescriptsyntaxtreehtml"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/inspector/model/parse-script-syntax-tree.html (209491 => 209492)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/inspector/model/parse-script-syntax-tree.html        2016-12-08 00:04:07 UTC (rev 209491)
+++ trunk/LayoutTests/inspector/model/parse-script-syntax-tree.html        2016-12-08 00:04:13 UTC (rev 209492)
</span><span class="lines">@@ -5,11 +5,13 @@
</span><span class="cx"> &lt;script&gt;
</span><span class="cx"> function test()
</span><span class="cx"> {
</span><del>-    function makeNode(text, isExpression)
</del><ins>+    function makeNode(text, isExpression, isModule)
</ins><span class="cx">     {
</span><del>-        var script = new WebInspector.Script(1, new WebInspector.TextRange(0, text.length));
-        var scriptSyntaxTree = new WebInspector.ScriptSyntaxTree(text, script);
-        var syntaxTree = scriptSyntaxTree._syntaxTree;
</del><ins>+        const target = null, url = null;
+        let sourceType = isModule ? WebInspector.Script.SourceType.Module : WebInspector.Script.SourceType.Program;
+        let script = new WebInspector.Script(target, 1, new WebInspector.TextRange(0, text.length), url, sourceType);
+        let scriptSyntaxTree = new WebInspector.ScriptSyntaxTree(text, script);
+        let syntaxTree = scriptSyntaxTree._syntaxTree;
</ins><span class="cx"> 
</span><span class="cx">         InspectorTest.assert(scriptSyntaxTree.parsedSuccessfully, &quot;ScriptSyntaxTree should be able to parse: \&quot;&quot; + text + &quot;\&quot;&quot;);
</span><span class="cx">         InspectorTest.assert(syntaxTree.type === WebInspector.ScriptSyntaxTree.NodeType.Program, &quot;Should be program.&quot;);
</span><span class="lines">@@ -17,12 +19,22 @@
</span><span class="cx">         if (isExpression) {
</span><span class="cx">             InspectorTest.assert(syntaxTree.body[0].type === WebInspector.ScriptSyntaxTree.NodeType.ExpressionStatement);
</span><span class="cx">             return syntaxTree.body[0].expression;
</span><del>-        } else
</del><ins>+        } else if (isModule) {
+            InspectorTest.assert(syntaxTree.sourceType === &quot;module&quot;);
</ins><span class="cx">             return syntaxTree.body[0];
</span><ins>+        } else {
+            InspectorTest.assert(syntaxTree.sourceType === &quot;script&quot;);
+            return syntaxTree.body[0];
+        }
</ins><span class="cx">     }
</span><span class="cx"> 
</span><del>-    var node = null;
</del><ins>+    function makeNodeForModule(text)
+    {
+        return makeNode(text, false, true);
+    }
</ins><span class="cx"> 
</span><ins>+    let node = null;
+
</ins><span class="cx">     node = makeNode(&quot;x = 20;&quot;, true);
</span><span class="cx">     InspectorTest.assert(node.type === WebInspector.ScriptSyntaxTree.NodeType.AssignmentExpression);
</span><span class="cx">     InspectorTest.assert(node.left);
</span><span class="lines">@@ -52,7 +64,7 @@
</span><span class="cx">     InspectorTest.assert(node.elements[0].type === WebInspector.ScriptSyntaxTree.NodeType.Literal);
</span><span class="cx">     InspectorTest.assert(node.elements[1].type === WebInspector.ScriptSyntaxTree.NodeType.Literal);
</span><span class="cx">     InspectorTest.log(&quot;passed ArrayExpression&quot;);
</span><del>-    
</del><ins>+
</ins><span class="cx">     node = makeNode(&quot;{foo();}&quot;, false);
</span><span class="cx">     InspectorTest.assert(node.type === WebInspector.ScriptSyntaxTree.NodeType.BlockStatement);
</span><span class="cx">     InspectorTest.assert(node.body);
</span><span class="lines">@@ -112,7 +124,7 @@
</span><span class="cx">     InspectorTest.assert(node.consequent.type === WebInspector.ScriptSyntaxTree.NodeType.Identifier);
</span><span class="cx">     InspectorTest.assert(node.alternate.type === WebInspector.ScriptSyntaxTree.NodeType.Identifier);
</span><span class="cx">     InspectorTest.log(&quot;passed ConditionalExpression&quot;);
</span><del>-    
</del><ins>+
</ins><span class="cx">     node = makeNode(&quot;label:while(true) {continue label;}&quot;, false);
</span><span class="cx">     InspectorTest.assert(node.body.body.body[0].type === WebInspector.ScriptSyntaxTree.NodeType.ContinueStatement);
</span><span class="cx">     InspectorTest.assert(node.body.body.body[0].label.type === WebInspector.ScriptSyntaxTree.NodeType.Identifier);
</span><span class="lines">@@ -321,7 +333,7 @@
</span><span class="cx">     InspectorTest.assert(node.right.properties[0].key.type === WebInspector.ScriptSyntaxTree.NodeType.Literal);
</span><span class="cx">     InspectorTest.log(&quot;passed Property&quot;);
</span><span class="cx"> 
</span><del>-    node = makeNode(&quot;function foo(...things) { return things; }&quot;, false);    
</del><ins>+    node = makeNode(&quot;function foo(...things) { return things; }&quot;, false);
</ins><span class="cx">     InspectorTest.assert(node.params.length === 1);
</span><span class="cx">     InspectorTest.assert(node.params[0].type === WebInspector.ScriptSyntaxTree.NodeType.RestElement);
</span><span class="cx">     InspectorTest.assert(node.params[0].argument.type === WebInspector.ScriptSyntaxTree.NodeType.Identifier);
</span><span class="lines">@@ -550,6 +562,66 @@
</span><span class="cx">     InspectorTest.assert(node.body.body[0].expression.argument.value === 1);
</span><span class="cx">     InspectorTest.log(&quot;passed AwaitExpression&quot;);
</span><span class="cx"> 
</span><ins>+
+    // Modules
+
+    node = makeNodeForModule(`import {a,b as x,c} from &quot;module.js&quot;`);
+    InspectorTest.assert(node.type === WebInspector.ScriptSyntaxTree.NodeType.ImportDeclaration);
+    InspectorTest.assert(node.source.value === &quot;module.js&quot;);
+    InspectorTest.assert(node.specifiers.length === 3);
+    InspectorTest.assert(node.specifiers[0].type === WebInspector.ScriptSyntaxTree.NodeType.ImportSpecifier);
+    InspectorTest.assert(node.specifiers[0].local.name === &quot;a&quot;);
+    InspectorTest.assert(node.specifiers[0].imported.name === &quot;a&quot;);
+    InspectorTest.assert(node.specifiers[1].type === WebInspector.ScriptSyntaxTree.NodeType.ImportSpecifier);
+    InspectorTest.assert(node.specifiers[1].local.name === &quot;x&quot;);
+    InspectorTest.assert(node.specifiers[1].imported.name === &quot;b&quot;);
+    InspectorTest.assert(node.specifiers[2].type === WebInspector.ScriptSyntaxTree.NodeType.ImportSpecifier);
+    InspectorTest.assert(node.specifiers[2].local.name === &quot;c&quot;);
+    InspectorTest.assert(node.specifiers[2].imported.name === &quot;c&quot;);
+    InspectorTest.log(&quot;passed ImportDeclaration, ImportSpecifier&quot;);
+
+    node = makeNodeForModule(`import x from &quot;module.js&quot;`);
+    InspectorTest.assert(node.type === WebInspector.ScriptSyntaxTree.NodeType.ImportDeclaration);
+    InspectorTest.assert(node.source.value === &quot;module.js&quot;);
+    InspectorTest.assert(node.specifiers.length === 1);
+    InspectorTest.assert(node.specifiers[0].type === WebInspector.ScriptSyntaxTree.NodeType.ImportDefaultSpecifier);
+    InspectorTest.log(&quot;passed ImportDefaultSpecifier&quot;);
+
+    node = makeNodeForModule(`import * as A from &quot;module.js&quot;`);
+    InspectorTest.assert(node.type === WebInspector.ScriptSyntaxTree.NodeType.ImportDeclaration);
+    InspectorTest.assert(node.source.value === &quot;module.js&quot;);
+    InspectorTest.assert(node.specifiers.length === 1);
+    InspectorTest.assert(node.specifiers[0].type === WebInspector.ScriptSyntaxTree.NodeType.ImportNamespaceSpecifier);
+    InspectorTest.assert(node.specifiers[0].local.name === &quot;A&quot;);
+    InspectorTest.log(&quot;passed ImportNamespaceSpecifier&quot;);
+
+    node = makeNodeForModule(`export {a, b as x, c}`);
+    InspectorTest.assert(node.type === WebInspector.ScriptSyntaxTree.NodeType.ExportNamedDeclaration);
+    InspectorTest.assert(node.specifiers.length === 3);
+    InspectorTest.assert(node.specifiers[0].type === WebInspector.ScriptSyntaxTree.NodeType.ExportSpecifier);
+    InspectorTest.assert(node.specifiers[0].local.name === &quot;a&quot;);
+    InspectorTest.assert(node.specifiers[0].exported.name === &quot;a&quot;);
+    InspectorTest.assert(node.specifiers[1].type === WebInspector.ScriptSyntaxTree.NodeType.ExportSpecifier);
+    InspectorTest.assert(node.specifiers[1].local.name === &quot;b&quot;);
+    InspectorTest.assert(node.specifiers[1].exported.name === &quot;x&quot;);
+    InspectorTest.assert(node.specifiers[2].type === WebInspector.ScriptSyntaxTree.NodeType.ExportSpecifier);
+    InspectorTest.assert(node.specifiers[2].local.name === &quot;c&quot;);
+    InspectorTest.assert(node.specifiers[2].exported.name === &quot;c&quot;);
+    InspectorTest.log(&quot;passed ExportNamedDeclaration, ExportSpecifier&quot;);
+
+    node = makeNodeForModule(`export default x`);
+    InspectorTest.assert(node.type === WebInspector.ScriptSyntaxTree.NodeType.ExportDefaultDeclaration);
+    InspectorTest.assert(node.declaration.name === &quot;x&quot;);
+    InspectorTest.log(&quot;passed ExportDefaultDeclaration&quot;);
+
+    node = makeNodeForModule(`export * from &quot;module.js&quot;`);
+    InspectorTest.assert(node.type === WebInspector.ScriptSyntaxTree.NodeType.ExportAllDeclaration);
+    InspectorTest.assert(node.source.value === &quot;module.js&quot;);
+    InspectorTest.log(&quot;passed ExportAllDeclaration&quot;);
+
+
+    // Divots
+
</ins><span class="cx">     node = makeNode(&quot;var o = {['c']() { }};&quot;, false);
</span><span class="cx">     //                        ^
</span><span class="cx">     //                 type profiling return divot.
</span></span></pre></div>
<a id="trunkLayoutTestsinspectormodelresourcesmodulejs"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/inspector/model/resources/module.js (0 => 209492)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/inspector/model/resources/module.js                                (rev 0)
+++ trunk/LayoutTests/inspector/model/resources/module.js        2016-12-08 00:04:13 UTC (rev 209492)
</span><span class="lines">@@ -0,0 +1,3 @@
</span><ins>+import &quot;./other-module.js&quot;
+
+function myModule() {}
</ins></span></pre></div>
<a id="trunkLayoutTestsinspectormodelresourcesothermodulejs"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/inspector/model/resources/other-module.js (0 => 209492)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/inspector/model/resources/other-module.js                                (rev 0)
+++ trunk/LayoutTests/inspector/model/resources/other-module.js        2016-12-08 00:04:13 UTC (rev 209492)
</span><span class="lines">@@ -0,0 +1 @@
</span><ins>+function myOtherModule() {}
</ins></span></pre></div>
<a id="trunkLayoutTestsinspectormodelresourcesprogramjs"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/inspector/model/resources/program.js (0 => 209492)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/inspector/model/resources/program.js                                (rev 0)
+++ trunk/LayoutTests/inspector/model/resources/program.js        2016-12-08 00:04:13 UTC (rev 209492)
</span><span class="lines">@@ -0,0 +1 @@
</span><ins>+function myProgram() {}
</ins></span></pre></div>
<a id="trunkLayoutTestsinspectormodelscriptsourceTypeexpectedtxt"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/inspector/model/script-sourceType-expected.txt (0 => 209492)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/inspector/model/script-sourceType-expected.txt                                (rev 0)
+++ trunk/LayoutTests/inspector/model/script-sourceType-expected.txt        2016-12-08 00:04:13 UTC (rev 209492)
</span><span class="lines">@@ -0,0 +1,11 @@
</span><ins>+Tests for WebInspector.Script.SourceType.
+
+
+== Running test suite: WebInspector.Script.SourceType
+-- Running test case: WebInspector.Script.SourceType.Program
+PASS: &lt;script&gt; should be SourceType.Program.
+
+-- Running test case: WebInspector.Script.SourceType.Module
+PASS: imported module should be SourceType.Module.
+PASS: &lt;script type=&quot;module&quot;&gt; should be SourceType.Module.
+
</ins></span></pre></div>
<a id="trunkLayoutTestsinspectormodelscriptsourceTypehtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/inspector/model/script-sourceType.html (0 => 209492)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/inspector/model/script-sourceType.html                                (rev 0)
+++ trunk/LayoutTests/inspector/model/script-sourceType.html        2016-12-08 00:04:13 UTC (rev 209492)
</span><span class="lines">@@ -0,0 +1,69 @@
</span><ins>+&lt;!DOCTYPE html&gt;
+&lt;html&gt;
+&lt;head&gt;
+&lt;script src=&quot;../../http/tests/inspector/resources/inspector-test.js&quot;&gt;&lt;/script&gt;
+&lt;script&gt;
+function triggerProgramScript() {
+    let script = document.createElement(&quot;script&quot;);
+    script.src = &quot;resources/program.js&quot;;
+    document.body.appendChild(script);
+}
+
+function triggerModuleScript() {
+    let script = document.createElement(&quot;script&quot;);
+    script.type = &quot;module&quot;;
+    script.src = &quot;resources/module.js&quot;;
+    document.body.appendChild(script);
+}
+
+function test()
+{
+    let suite = InspectorTest.createAsyncSuite(&quot;WebInspector.Script.SourceType&quot;);
+
+    suite.addTestCase({
+        name: &quot;WebInspector.Script.SourceType.Program&quot;,
+        description: &quot;Normal &lt;script src&gt; should be Program.&quot;,
+        test(resolve, reject) {
+            InspectorTest.evaluateInPage(&quot;triggerProgramScript()&quot;);
+            let listener = WebInspector.debuggerManager.addEventListener(WebInspector.DebuggerManager.Event.ScriptAdded, (event) =&gt; {
+                let script = event.data.script;
+                if (!/program.js$/.test(script.url))
+                    return;
+
+                WebInspector.debuggerManager.removeEventListener(WebInspector.DebuggerManager.Event.ScriptAdded, listener);
+                InspectorTest.expectEqual(script.sourceType, WebInspector.Script.SourceType.Program, `&lt;script&gt; should be SourceType.Program.`);
+                resolve();
+            });
+        }
+    });
+
+    suite.addTestCase({
+        name: &quot;WebInspector.Script.SourceType.Module&quot;,
+        description: &quot;Module &lt;script type=module&gt; should be Module.&quot;,
+        test(resolve, reject) {
+            InspectorTest.evaluateInPage(&quot;triggerModuleScript()&quot;);
+            let listener = WebInspector.debuggerManager.addEventListener(WebInspector.DebuggerManager.Event.ScriptAdded, (event) =&gt; {
+                let script = event.data.script;
+                if (!/module.js$/.test(script.url))
+                    return;
+
+                if (/other-module.js$/.test(script.url)) {
+                    InspectorTest.expectEqual(script.sourceType, WebInspector.Script.SourceType.Module, `imported module should be SourceType.Module.`);
+                    return;
+                }
+
+                WebInspector.debuggerManager.removeEventListener(WebInspector.DebuggerManager.Event.ScriptAdded, listener);
+                InspectorTest.expectEqual(script.sourceType, WebInspector.Script.SourceType.Module, `&lt;script type=&quot;module&quot;&gt; should be SourceType.Module.`);
+                resolve();
+            });
+        }
+    });
+
+    suite.runTestCasesAndFinish();
+}
+&lt;/script&gt;
+&lt;/head&gt;
+&lt;body onload=&quot;runTest()&quot;&gt;
+&lt;p&gt;Tests for WebInspector.Script.SourceType.&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 (209491 => 209492)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/ChangeLog        2016-12-08 00:04:07 UTC (rev 209491)
+++ trunk/Source/JavaScriptCore/ChangeLog        2016-12-08 00:04:13 UTC (rev 209492)
</span><span class="lines">@@ -1,3 +1,16 @@
</span><ins>+2016-12-07  Joseph Pecoraro  &lt;pecoraro@apple.com&gt;
+
+        Web Inspector: Add ability to distinguish if a Script was parsed as a module
+        https://bugs.webkit.org/show_bug.cgi?id=164900
+        &lt;rdar://problem/29323817&gt;
+
+        Reviewed by Timothy Hatcher.
+
+        * inspector/agents/InspectorDebuggerAgent.cpp:
+        (Inspector::InspectorDebuggerAgent::didParseSource):
+        * inspector/protocol/Debugger.json:
+        Add an optional event parameter to distinguish if a script was a module or not.
+
</ins><span class="cx"> 2016-12-07  Simon Fraser  &lt;simon.fraser@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         Add system trace points for JavaScript VM entry/exit
</span></span></pre></div>
<a id="trunkSourceJavaScriptCoreinspectoragentsInspectorDebuggerAgentcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/inspector/agents/InspectorDebuggerAgent.cpp (209491 => 209492)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/inspector/agents/InspectorDebuggerAgent.cpp        2016-12-08 00:04:07 UTC (rev 209491)
+++ trunk/Source/JavaScriptCore/inspector/agents/InspectorDebuggerAgent.cpp        2016-12-08 00:04:13 UTC (rev 209492)
</span><span class="lines">@@ -887,11 +887,12 @@
</span><span class="cx">     String sourceURL = script.sourceURL;
</span><span class="cx">     String sourceMappingURL = sourceMapURLForScript(script);
</span><span class="cx"> 
</span><ins>+    const bool isModule = script.sourceProvider-&gt;sourceType() == JSC::SourceProviderSourceType::Module;
</ins><span class="cx">     const bool* isContentScript = script.isContentScript ? &amp;script.isContentScript : nullptr;
</span><span class="cx">     String* sourceURLParam = hasSourceURL ? &amp;sourceURL : nullptr;
</span><span class="cx">     String* sourceMapURLParam = sourceMappingURL.isEmpty() ? nullptr : &amp;sourceMappingURL;
</span><span class="cx"> 
</span><del>-    m_frontendDispatcher-&gt;scriptParsed(scriptIDStr, script.url, script.startLine, script.startColumn, script.endLine, script.endColumn, isContentScript, sourceURLParam, sourceMapURLParam);
</del><ins>+    m_frontendDispatcher-&gt;scriptParsed(scriptIDStr, script.url, script.startLine, script.startColumn, script.endLine, script.endColumn, isContentScript, sourceURLParam, sourceMapURLParam, isModule ? &amp;isModule : nullptr);
</ins><span class="cx"> 
</span><span class="cx">     m_scripts.set(sourceID, script);
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceJavaScriptCoreinspectorprotocolDebuggerjson"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/inspector/protocol/Debugger.json (209491 => 209492)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/inspector/protocol/Debugger.json        2016-12-08 00:04:07 UTC (rev 209491)
+++ trunk/Source/JavaScriptCore/inspector/protocol/Debugger.json        2016-12-08 00:04:13 UTC (rev 209492)
</span><span class="lines">@@ -304,7 +304,8 @@
</span><span class="cx">                 { &quot;name&quot;: &quot;endColumn&quot;, &quot;type&quot;: &quot;integer&quot;, &quot;description&quot;: &quot;Length of the last line of the script.&quot; },
</span><span class="cx">                 { &quot;name&quot;: &quot;isContentScript&quot;, &quot;type&quot;: &quot;boolean&quot;, &quot;optional&quot;: true, &quot;description&quot;: &quot;Determines whether this script is a user extension script.&quot; },
</span><span class="cx">                 { &quot;name&quot;: &quot;sourceURL&quot;, &quot;type&quot;: &quot;string&quot;, &quot;optional&quot;: true, &quot;description&quot;: &quot;sourceURL name of the script (if any).&quot; },
</span><del>-                { &quot;name&quot;: &quot;sourceMapURL&quot;, &quot;type&quot;: &quot;string&quot;, &quot;optional&quot;: true, &quot;description&quot;: &quot;URL of source map associated with script (if any).&quot; }
</del><ins>+                { &quot;name&quot;: &quot;sourceMapURL&quot;, &quot;type&quot;: &quot;string&quot;, &quot;optional&quot;: true, &quot;description&quot;: &quot;URL of source map associated with script (if any).&quot; },
+                { &quot;name&quot;: &quot;module&quot;, &quot;type&quot;: &quot;boolean&quot;, &quot;optional&quot;: true, &quot;description&quot;: &quot;True if this script was parsed as a module.&quot; }
</ins><span class="cx">             ],
</span><span class="cx">             &quot;description&quot;: &quot;Fired when virtual machine parses script. This event is also fired for all known and uncollected scripts upon enabling debugger.&quot;
</span><span class="cx">         },
</span></span></pre></div>
<a id="trunkSourceWebInspectorUIChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebInspectorUI/ChangeLog (209491 => 209492)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebInspectorUI/ChangeLog        2016-12-08 00:04:07 UTC (rev 209491)
+++ trunk/Source/WebInspectorUI/ChangeLog        2016-12-08 00:04:13 UTC (rev 209492)
</span><span class="lines">@@ -1,5 +1,35 @@
</span><span class="cx"> 2016-12-07  Joseph Pecoraro  &lt;pecoraro@apple.com&gt;
</span><span class="cx"> 
</span><ins>+        Web Inspector: Add ability to distinguish if a Script was parsed as a module
+        https://bugs.webkit.org/show_bug.cgi?id=164900
+        &lt;rdar://problem/29323817&gt;
+
+        Reviewed by Timothy Hatcher.
+
+        * UserInterface/Models/Script.js:
+        (WebInspector.Script.prototype.get sourceType):
+        New property of Scripts. SourceType is either Program or Module.
+
+        * UserInterface/Controllers/DebuggerManager.js:
+        (WebInspector.DebuggerManager.prototype.scriptDidParse):
+        * UserInterface/Protocol/DebuggerObserver.js:
+        (WebInspector.DebuggerObserver.prototype.scriptParsed):
+        Convert incoming module boolean into SourceType when creating new Scripts.
+
+        * UserInterface/Models/ScriptSyntaxTree.js:
+        (WebInspector.ScriptSyntaxTree):
+        (WebInspector.ScriptSyntaxTree.prototype._recurse):
+        (WebInspector.ScriptSyntaxTree.prototype._createInternalSyntaxTree):
+        Update the generic AST for new module specific Esprima types.
+
+        * UserInterface/Views/SourceCodeTextEditor.js:
+        (WebInspector.SourceCodeTextEditor.prototype.textEditorScriptSourceType):
+        * UserInterface/Views/TextEditor.js:
+        (WebInspector.TextEditor.prototype._startWorkerPrettyPrint):
+        For pretty printing correctly state if this is a module or not for Esprima.
+
+2016-12-07  Joseph Pecoraro  &lt;pecoraro@apple.com&gt;
+
</ins><span class="cx">         Web Inspector: Update Esprima to support new features / syntax (**, async/await, trailing comma)
</span><span class="cx">         https://bugs.webkit.org/show_bug.cgi?id=164830
</span><span class="cx">         &lt;rdar://problem/29293814&gt;
</span></span></pre></div>
<a id="trunkSourceWebInspectorUIUserInterfaceControllersDebuggerManagerjs"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebInspectorUI/UserInterface/Controllers/DebuggerManager.js (209491 => 209492)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebInspectorUI/UserInterface/Controllers/DebuggerManager.js        2016-12-08 00:04:07 UTC (rev 209491)
+++ trunk/Source/WebInspectorUI/UserInterface/Controllers/DebuggerManager.js        2016-12-08 00:04:13 UTC (rev 209492)
</span><span class="lines">@@ -671,7 +671,7 @@
</span><span class="cx">         InspectorFrontendHost.beep();
</span><span class="cx">     }
</span><span class="cx"> 
</span><del>-    scriptDidParse(target, scriptIdentifier, url, startLine, startColumn, endLine, endColumn, isContentScript, sourceURL, sourceMapURL)
</del><ins>+    scriptDidParse(target, scriptIdentifier, url, startLine, startColumn, endLine, endColumn, isModule, isContentScript, sourceURL, sourceMapURL)
</ins><span class="cx">     {
</span><span class="cx">         // Called from WebInspector.DebuggerObserver.
</span><span class="cx"> 
</span><span class="lines">@@ -690,7 +690,9 @@
</span><span class="cx">         if (!WebInspector.isDebugUIEnabled() &amp;&amp; isWebKitInternalScript(sourceURL))
</span><span class="cx">             return;
</span><span class="cx"> 
</span><del>-        let script = new WebInspector.Script(target, scriptIdentifier, new WebInspector.TextRange(startLine, startColumn, endLine, endColumn), url, isContentScript, sourceURL, sourceMapURL);
</del><ins>+        let range = new WebInspector.TextRange(startLine, startColumn, endLine, endColumn);
+        let sourceType = isModule ? WebInspector.Script.SourceType.Module : WebInspector.Script.SourceType.Program;
+        let script = new WebInspector.Script(target, scriptIdentifier, range, url, sourceType, isContentScript, sourceURL, sourceMapURL);
</ins><span class="cx"> 
</span><span class="cx">         targetData.addScript(script);
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebInspectorUIUserInterfaceModelsScriptjs"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebInspectorUI/UserInterface/Models/Script.js (209491 => 209492)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebInspectorUI/UserInterface/Models/Script.js        2016-12-08 00:04:07 UTC (rev 209491)
+++ trunk/Source/WebInspectorUI/UserInterface/Models/Script.js        2016-12-08 00:04:13 UTC (rev 209492)
</span><span class="lines">@@ -25,7 +25,7 @@
</span><span class="cx"> 
</span><span class="cx"> WebInspector.Script = class Script extends WebInspector.SourceCode
</span><span class="cx"> {
</span><del>-    constructor(target, id, range, url, injected, sourceURL, sourceMapURL)
</del><ins>+    constructor(target, id, range, url, sourceType, injected, sourceURL, sourceMapURL)
</ins><span class="cx">     {
</span><span class="cx">         super();
</span><span class="cx"> 
</span><span class="lines">@@ -37,6 +37,7 @@
</span><span class="cx">         this._id = id || null;
</span><span class="cx">         this._range = range || null;
</span><span class="cx">         this._url = url || null;
</span><ins>+        this._sourceType = sourceType || WebInspector.Script.SourceType.Program;
</ins><span class="cx">         this._sourceURL = sourceURL || null;
</span><span class="cx">         this._sourceMappingURL = sourceMapURL || null;
</span><span class="cx">         this._injected = injected || false;
</span><span class="lines">@@ -77,26 +78,15 @@
</span><span class="cx"> 
</span><span class="cx">     // Public
</span><span class="cx"> 
</span><del>-    get target()
-    {
-        return this._target;
-    }
</del><ins>+    get target() { return this._target; }
+    get id() { return this._id; }
+    get range() { return this._range; }
+    get url() { return this._url; }
+    get sourceType() { return this._sourceType; }
+    get sourceURL() { return this._sourceURL; }
+    get sourceMappingURL() { return this._sourceMappingURL; }
+    get injected() { return this._injected; }
</ins><span class="cx"> 
</span><del>-    get id()
-    {
-        return this._id;
-    }
-
-    get range()
-    {
-        return this._range;
-    }
-
-    get url()
-    {
-        return this._url;
-    }
-
</del><span class="cx">     get contentIdentifier()
</span><span class="cx">     {
</span><span class="cx">         if (this._url)
</span><span class="lines">@@ -119,16 +109,6 @@
</span><span class="cx">         return this._sourceURL;
</span><span class="cx">     }
</span><span class="cx"> 
</span><del>-    get sourceURL()
-    {
-        return this._sourceURL;
-    }
-
-    get sourceMappingURL()
-    {
-        return this._sourceMappingURL;
-    }
-
</del><span class="cx">     get urlComponents()
</span><span class="cx">     {
</span><span class="cx">         if (!this._urlComponents)
</span><span class="lines">@@ -179,11 +159,6 @@
</span><span class="cx">         return null;
</span><span class="cx">     }
</span><span class="cx"> 
</span><del>-    get injected()
-    {
-        return this._injected;
-    }
-
</del><span class="cx">     get dynamicallyAddedScriptElement()
</span><span class="cx">     {
</span><span class="cx">         return this._dynamicallyAddedScriptElement;
</span><span class="lines">@@ -315,6 +290,11 @@
</span><span class="cx">     }
</span><span class="cx"> };
</span><span class="cx"> 
</span><ins>+WebInspector.Script.SourceType = {
+    Program: &quot;script-source-type-program&quot;,
+    Module: &quot;script-source-type-module&quot;,
+};
+
</ins><span class="cx"> WebInspector.Script.TypeIdentifier = &quot;script&quot;;
</span><span class="cx"> WebInspector.Script.URLCookieKey = &quot;script-url&quot;;
</span><span class="cx"> WebInspector.Script.DisplayNameCookieKey = &quot;script-display-name&quot;;
</span></span></pre></div>
<a id="trunkSourceWebInspectorUIUserInterfaceModelsScriptSyntaxTreejs"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebInspectorUI/UserInterface/Models/ScriptSyntaxTree.js (209491 => 209492)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebInspectorUI/UserInterface/Models/ScriptSyntaxTree.js        2016-12-08 00:04:07 UTC (rev 209491)
+++ trunk/Source/WebInspectorUI/UserInterface/Models/ScriptSyntaxTree.js        2016-12-08 00:04:13 UTC (rev 209492)
</span><span class="lines">@@ -34,7 +34,8 @@
</span><span class="cx">         this._script = script;
</span><span class="cx"> 
</span><span class="cx">         try {
</span><del>-            var esprimaSyntaxTree = esprima.parse(sourceText, {range: true});
</del><ins>+            let sourceType = this._script.sourceType === WebInspector.Script.SourceType.Module ? &quot;module&quot; : &quot;script&quot;;
+            let esprimaSyntaxTree = esprima.parse(sourceText, {range: true, sourceType});
</ins><span class="cx">             this._syntaxTree = this._createInternalSyntaxTree(esprimaSyntaxTree);
</span><span class="cx">             this._parsedSuccessfully = true;
</span><span class="cx">         } catch (error) {
</span><span class="lines">@@ -487,6 +488,39 @@
</span><span class="cx">         case WebInspector.ScriptSyntaxTree.NodeType.YieldExpression:
</span><span class="cx">             this._recurse(node.argument, callback, state);
</span><span class="cx">             break;
</span><ins>+
+        // Modules.
+
+        case WebInspector.ScriptSyntaxTree.NodeType.ExportAllDeclaration:
+            this._recurse(node.source, callback, state);
+            break;
+        case WebInspector.ScriptSyntaxTree.NodeType.ExportNamedDeclaration:
+            this._recurse(node.declaration, callback, state);
+            this._recurseArray(node.specifiers, callback, state);
+            this._recurse(node.source, callback, state);
+            break;
+        case WebInspector.ScriptSyntaxTree.NodeType.ExportDefaultDeclaration:
+            this._recurse(node.declaration, callback, state);
+            break;
+        case WebInspector.ScriptSyntaxTree.NodeType.ExportSpecifier:
+            this._recurse(node.local, callback, state);
+            this._recurse(node.exported, callback, state);
+            break;
+        case WebInspector.ScriptSyntaxTree.NodeType.ImportDeclaration:
+            this._recurseArray(node.specifiers, callback, state);
+            this._recurse(node.source, callback, state);
+            break;
+        case WebInspector.ScriptSyntaxTree.NodeType.ImportDefaultSpecifier:
+            this._recurse(node.local, callback, state);
+            break;
+        case WebInspector.ScriptSyntaxTree.NodeType.ImportNamespaceSpecifier:
+            this._recurse(node.local, callback, state);
+            break;
+        case WebInspector.ScriptSyntaxTree.NodeType.ImportSpecifier:
+            this._recurse(node.imported, callback, state);
+            this._recurse(node.local, callback, state);
+            break;
+
</ins><span class="cx">         // All the leaf nodes go here.
</span><span class="cx">         case WebInspector.ScriptSyntaxTree.NodeType.DebuggerStatement:
</span><span class="cx">         case WebInspector.ScriptSyntaxTree.NodeType.EmptyStatement:
</span><span class="lines">@@ -938,6 +972,63 @@
</span><span class="cx">                 delegate: node.delegate
</span><span class="cx">             };
</span><span class="cx">             break;
</span><ins>+
+        // Modules.
+
+        case &quot;ExportAllDeclaration&quot;:
+            result = {
+                type: WebInspector.ScriptSyntaxTree.NodeType.ExportAllDeclaration,
+                source: this._createInternalSyntaxTree(node.source),
+            };
+            break;
+        case &quot;ExportNamedDeclaration&quot;:
+            result = {
+                type: WebInspector.ScriptSyntaxTree.NodeType.ExportNamedDeclaration,
+                declaration: this._createInternalSyntaxTree(node.declaration),
+                specifiers: node.specifiers.map(this._createInternalSyntaxTree, this),
+                source: this._createInternalSyntaxTree(node.source),
+            };
+            break;
+        case &quot;ExportDefaultDeclaration&quot;:
+            result = {
+                type: WebInspector.ScriptSyntaxTree.NodeType.ExportDefaultDeclaration,
+                declaration: this._createInternalSyntaxTree(node.declaration),
+            };
+            break;
+        case &quot;ExportSpecifier&quot;:
+            result = {
+                type: WebInspector.ScriptSyntaxTree.NodeType.ExportSpecifier,
+                local: this._createInternalSyntaxTree(node.local),
+                exported: this._createInternalSyntaxTree(node.exported),
+            };
+            break;
+        case &quot;ImportDeclaration&quot;:
+            result = {
+                type: WebInspector.ScriptSyntaxTree.NodeType.ImportDeclaration,
+                specifiers: node.specifiers.map(this._createInternalSyntaxTree, this),
+                source: this._createInternalSyntaxTree(node.source),
+            };
+            break;
+        case &quot;ImportDefaultSpecifier&quot;:
+            result = {
+                type: WebInspector.ScriptSyntaxTree.NodeType.ImportDefaultSpecifier,
+                local: this._createInternalSyntaxTree(node.local),
+            };
+            break;
+        case &quot;ImportNamespaceSpecifier&quot;:
+            result = {
+                type: WebInspector.ScriptSyntaxTree.NodeType.ImportNamespaceSpecifier,
+                local: this._createInternalSyntaxTree(node.local),
+            };
+            break;
+        case &quot;ImportSpecifier&quot;:
+            result = {
+                type: WebInspector.ScriptSyntaxTree.NodeType.ImportSpecifier,
+                imported: this._createInternalSyntaxTree(node.imported),
+                local: this._createInternalSyntaxTree(node.local),
+            };
+            break;
+
</ins><span class="cx">         default:
</span><span class="cx">             console.error(&quot;Unsupported Syntax Tree Node: &quot; + node.type, node);
</span><span class="cx">             return null;
</span><span class="lines">@@ -977,6 +1068,10 @@
</span><span class="cx">     DebuggerStatement: Symbol(&quot;debugger-statement&quot;),
</span><span class="cx">     DoWhileStatement: Symbol(&quot;do-while-statement&quot;),
</span><span class="cx">     EmptyStatement: Symbol(&quot;empty-statement&quot;),
</span><ins>+    ExportAllDeclaration: Symbol(&quot;export-all-declaration&quot;),
+    ExportDefaultDeclaration: Symbol(&quot;export-default-declaration&quot;),
+    ExportNamedDeclaration: Symbol(&quot;export-named-declaration&quot;),
+    ExportSpecifier: Symbol(&quot;export-specifier&quot;),
</ins><span class="cx">     ExpressionStatement: Symbol(&quot;expression-statement&quot;),
</span><span class="cx">     ForInStatement: Symbol(&quot;for-in-statement&quot;),
</span><span class="cx">     ForOfStatement: Symbol(&quot;for-of-statement&quot;),
</span><span class="lines">@@ -985,6 +1080,10 @@
</span><span class="cx">     FunctionExpression: Symbol(&quot;function-expression&quot;),
</span><span class="cx">     Identifier: Symbol(&quot;identifier&quot;),
</span><span class="cx">     IfStatement: Symbol(&quot;if-statement&quot;),
</span><ins>+    ImportDeclaration: Symbol(&quot;import-declaration&quot;),
+    ImportDefaultSpecifier: Symbol(&quot;import-default-specifier&quot;),
+    ImportNamespaceSpecifier: Symbol(&quot;import-namespace-specifier&quot;),
+    ImportSpecifier: Symbol(&quot;import-specifier&quot;),
</ins><span class="cx">     LabeledStatement: Symbol(&quot;labeled-statement&quot;),
</span><span class="cx">     Literal: Symbol(&quot;literal&quot;),
</span><span class="cx">     LogicalExpression: Symbol(&quot;logical-expression&quot;),
</span></span></pre></div>
<a id="trunkSourceWebInspectorUIUserInterfaceProtocolDebuggerObserverjs"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebInspectorUI/UserInterface/Protocol/DebuggerObserver.js (209491 => 209492)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebInspectorUI/UserInterface/Protocol/DebuggerObserver.js        2016-12-08 00:04:07 UTC (rev 209491)
+++ trunk/Source/WebInspectorUI/UserInterface/Protocol/DebuggerObserver.js        2016-12-08 00:04:13 UTC (rev 209492)
</span><span class="lines">@@ -37,7 +37,7 @@
</span><span class="cx">         WebInspector.debuggerManager.reset();
</span><span class="cx">     }
</span><span class="cx"> 
</span><del>-    scriptParsed(scriptId, url, startLine, startColumn, endLine, endColumn, isContentScript, sourceURL, sourceMapURL)
</del><ins>+    scriptParsed(scriptId, url, startLine, startColumn, endLine, endColumn, isContentScript, sourceURL, sourceMapURL, isModule)
</ins><span class="cx">     {
</span><span class="cx">         if (this._legacyScriptParsed) {
</span><span class="cx">             // COMPATIBILITY (iOS 9): Debugger.scriptParsed had slightly different arguments.
</span><span class="lines">@@ -46,11 +46,11 @@
</span><span class="cx">             let legacySourceMapURL = arguments[7];
</span><span class="cx">             let hasSourceURL = arguments[8];
</span><span class="cx">             let legacySourceURL = hasSourceURL ? url : undefined;
</span><del>-            WebInspector.debuggerManager.scriptDidParse(this.target, scriptId, url, startLine, startColumn, endLine, endColumn, isContentScript, legacySourceURL, legacySourceMapURL);
</del><ins>+            WebInspector.debuggerManager.scriptDidParse(this.target, scriptId, url, startLine, startColumn, endLine, endColumn, isModule, isContentScript, legacySourceURL, legacySourceMapURL);
</ins><span class="cx">             return;
</span><span class="cx">         }
</span><span class="cx"> 
</span><del>-        WebInspector.debuggerManager.scriptDidParse(this.target, scriptId, url, startLine, startColumn, endLine, endColumn, isContentScript, sourceURL, sourceMapURL);
</del><ins>+        WebInspector.debuggerManager.scriptDidParse(this.target, scriptId, url, startLine, startColumn, endLine, endColumn, isModule, isContentScript, sourceURL, sourceMapURL);
</ins><span class="cx">     }
</span><span class="cx"> 
</span><span class="cx">     scriptFailedToParse(url, scriptSource, startLine, errorLine, errorMessage)
</span></span></pre></div>
<a id="trunkSourceWebInspectorUIUserInterfaceViewsSourceCodeTextEditorjs"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebInspectorUI/UserInterface/Views/SourceCodeTextEditor.js (209491 => 209492)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebInspectorUI/UserInterface/Views/SourceCodeTextEditor.js        2016-12-08 00:04:07 UTC (rev 209491)
+++ trunk/Source/WebInspectorUI/UserInterface/Views/SourceCodeTextEditor.js        2016-12-08 00:04:13 UTC (rev 209492)
</span><span class="lines">@@ -1183,6 +1183,12 @@
</span><span class="cx">         return this._sourceCode.url;
</span><span class="cx">     }
</span><span class="cx"> 
</span><ins>+    textEditorScriptSourceType(textEditor)
+    {
+        let script = this._getAssociatedScript();
+        return script ? script.sourceType : WebInspector.Script.SourceType.Program;
+    }
+
</ins><span class="cx">     textEditorShouldHideLineNumber(textEditor, lineNumber)
</span><span class="cx">     {
</span><span class="cx">         return lineNumber in this._invalidLineNumbers;
</span></span></pre></div>
<a id="trunkSourceWebInspectorUIUserInterfaceViewsTextEditorjs"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebInspectorUI/UserInterface/Views/TextEditor.js (209491 => 209492)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebInspectorUI/UserInterface/Views/TextEditor.js        2016-12-08 00:04:07 UTC (rev 209491)
+++ trunk/Source/WebInspectorUI/UserInterface/Views/TextEditor.js        2016-12-08 00:04:13 UTC (rev 209492)
</span><span class="lines">@@ -839,8 +839,8 @@
</span><span class="cx">         let indentString = WebInspector.indentString();
</span><span class="cx">         const includeSourceMapData = true;
</span><span class="cx"> 
</span><del>-        // FIXME: Properly pass if this is a module or script.
-        const isModule = false;
</del><ins>+        let sourceType = this._delegate.textEditorScriptSourceType(this);
+        const isModule = sourceType === WebInspector.Script.SourceType.Module;
</ins><span class="cx"> 
</span><span class="cx">         let workerProxy = WebInspector.FormatterWorkerProxy.singleton();
</span><span class="cx">         workerProxy.formatJavaScript(sourceText, isModule, indentString, includeSourceMapData, ({formattedText, sourceMapData}) =&gt; {
</span></span></pre>
</div>
</div>

</body>
</html>