<!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>[200533] 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/200533">200533</a></dd>
<dt>Author</dt> <dd>commit-queue@webkit.org</dd>
<dt>Date</dt> <dd>2016-05-06 16:32:28 -0700 (Fri, 06 May 2016)</dd>
</dl>

<h3>Log Message</h3>
<pre>Web Inspector: Console: Variables defined with let/const aren't accessible outside of console's scope
https://bugs.webkit.org/show_bug.cgi?id=150752
&lt;rdar://problem/23343385&gt;

Patch by Joseph Pecoraro &lt;pecoraro@apple.com&gt; on 2016-05-06
Reviewed by Mark Lam.

Source/JavaScriptCore:

This approach allows Web Inspector to hang a &quot;Scope Extension&quot;, a
WithObjectScope, off the GlobalObject. When resolving identifiers
in fails to resolve anything in the normal scope chain, consult
the scope extension.

This allows us to eliminate the `with (commandLineAPI) { ... }`
block in global console evaluations, and instead makes it a full
program evaluation, with the commandLineAPI available and safely
shadowed by actual variables as expected.

* inspector/InjectedScriptSource.js:
(InjectedScript.prototype._evaluateOn):
Use the new evaluateWithScopeExtension and provide the CommandLineAPI
object as the scope extension object.

(BasicCommandLineAPI):
(BasicCommandLineAPI.inScopeVariables): Deleted.
Simplify now that we don't need to check for variable shadowing ourselves.

* inspector/JSInjectedScriptHost.cpp:
(Inspector::JSInjectedScriptHost::evaluateWithScopeExtension):
* inspector/JSInjectedScriptHost.h:
* inspector/JSInjectedScriptHostPrototype.cpp:
(Inspector::JSInjectedScriptHostPrototype::finishCreation):
(Inspector::jsInjectedScriptHostPrototypeFunctionEvaluateWithScopeExtension):
Provide a new InjectedScriptHost method to evaluate a program
with a scope extension.

* runtime/Completion.cpp:
(JSC::evaluateWithScopeExtension):
* runtime/Completion.h:
General JSC::evaluate function to evaluate a program with a scope extension.

* runtime/JSGlobalObject.cpp:
(JSC::JSGlobalObject::setGlobalScopeExtension):
(JSC::JSGlobalObject::clearGlobalScopeExtension):
(JSC::JSGlobalObject::visitChildren):
* runtime/JSGlobalObject.h:
(JSC::JSGlobalObject::globalScopeExtension):
Hang a scope extension off the global object.

* runtime/JSScope.cpp:
(JSC::JSScope::resolve):
Consult the scope extension when resolve fails to find anything normally.

Source/WebCore:

Test: inspector/runtime/evaluate-CommandLineAPI.html

* inspector/CommandLineAPIModuleSource.js:
(bind):
(this.member.toString):
(CommandLineAPI):
(CommandLineAPIImpl.prototype):
(slice): Deleted.
(bound): Deleted.
(bound.toString): Deleted.
(inScopeVariables): Deleted.
(customToStringMethod): Deleted.
Simplify now that we don't need to do our own variable shadow checking.

LayoutTests:

* inspector/runtime/evaluate-CommandLineAPI-expected.txt: Added.
* inspector/runtime/evaluate-CommandLineAPI.html: Added.
New test covering the different cases of global evaluation with the
CommandLineAPI as a scope extension.

* http/tests/inspector/console/cross-domain-inspected-node-access-expected.txt:
* inspector/console/command-line-api-expected.txt:
* inspector/debugger/js-stacktrace-expected.txt:
* inspector/debugger/js-stacktrace.html:
* inspector/model/stack-trace-expected.txt:
* platform/mac/inspector/model/remote-object-expected.txt:
Update expectations now that global evaluations are treated as
program's [global code] and not evals [eval code]. Also some
line number changes.</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkLayoutTestsChangeLog">trunk/LayoutTests/ChangeLog</a></li>
<li><a href="#trunkLayoutTestshttptestsinspectorconsolecrossdomaininspectednodeaccessexpectedtxt">trunk/LayoutTests/http/tests/inspector/console/cross-domain-inspected-node-access-expected.txt</a></li>
<li><a href="#trunkLayoutTestsinspectorconsolecommandlineapiexpectedtxt">trunk/LayoutTests/inspector/console/command-line-api-expected.txt</a></li>
<li><a href="#trunkLayoutTestsinspectordebuggerjsstacktraceexpectedtxt">trunk/LayoutTests/inspector/debugger/js-stacktrace-expected.txt</a></li>
<li><a href="#trunkLayoutTestsinspectordebuggerjsstacktracehtml">trunk/LayoutTests/inspector/debugger/js-stacktrace.html</a></li>
<li><a href="#trunkLayoutTestsinspectormodelstacktraceexpectedtxt">trunk/LayoutTests/inspector/model/stack-trace-expected.txt</a></li>
<li><a href="#trunkLayoutTestsplatformmacinspectormodelremoteobjectexpectedtxt">trunk/LayoutTests/platform/mac/inspector/model/remote-object-expected.txt</a></li>
<li><a href="#trunkSourceJavaScriptCoreChangeLog">trunk/Source/JavaScriptCore/ChangeLog</a></li>
<li><a href="#trunkSourceJavaScriptCoreinspectorInjectedScriptSourcejs">trunk/Source/JavaScriptCore/inspector/InjectedScriptSource.js</a></li>
<li><a href="#trunkSourceJavaScriptCoreinspectorJSInjectedScriptHostcpp">trunk/Source/JavaScriptCore/inspector/JSInjectedScriptHost.cpp</a></li>
<li><a href="#trunkSourceJavaScriptCoreinspectorJSInjectedScriptHosth">trunk/Source/JavaScriptCore/inspector/JSInjectedScriptHost.h</a></li>
<li><a href="#trunkSourceJavaScriptCoreinspectorJSInjectedScriptHostPrototypecpp">trunk/Source/JavaScriptCore/inspector/JSInjectedScriptHostPrototype.cpp</a></li>
<li><a href="#trunkSourceJavaScriptCoreruntimeCompletioncpp">trunk/Source/JavaScriptCore/runtime/Completion.cpp</a></li>
<li><a href="#trunkSourceJavaScriptCoreruntimeCompletionh">trunk/Source/JavaScriptCore/runtime/Completion.h</a></li>
<li><a href="#trunkSourceJavaScriptCoreruntimeJSGlobalObjectcpp">trunk/Source/JavaScriptCore/runtime/JSGlobalObject.cpp</a></li>
<li><a href="#trunkSourceJavaScriptCoreruntimeJSGlobalObjecth">trunk/Source/JavaScriptCore/runtime/JSGlobalObject.h</a></li>
<li><a href="#trunkSourceJavaScriptCoreruntimeJSScopecpp">trunk/Source/JavaScriptCore/runtime/JSScope.cpp</a></li>
<li><a href="#trunkSourceWebCoreChangeLog">trunk/Source/WebCore/ChangeLog</a></li>
<li><a href="#trunkSourceWebCoreinspectorCommandLineAPIModuleSourcejs">trunk/Source/WebCore/inspector/CommandLineAPIModuleSource.js</a></li>
</ul>

<h3>Added Paths</h3>
<ul>
<li><a href="#trunkLayoutTestsinspectorruntimeevaluateCommandLineAPIexpectedtxt">trunk/LayoutTests/inspector/runtime/evaluate-CommandLineAPI-expected.txt</a></li>
<li><a href="#trunkLayoutTestsinspectorruntimeevaluateCommandLineAPIhtml">trunk/LayoutTests/inspector/runtime/evaluate-CommandLineAPI.html</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkLayoutTestsChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/ChangeLog (200532 => 200533)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/ChangeLog        2016-05-06 23:21:16 UTC (rev 200532)
+++ trunk/LayoutTests/ChangeLog        2016-05-06 23:32:28 UTC (rev 200533)
</span><span class="lines">@@ -1,3 +1,26 @@
</span><ins>+2016-05-06  Joseph Pecoraro  &lt;pecoraro@apple.com&gt;
+
+        Web Inspector: Console: Variables defined with let/const aren't accessible outside of console's scope
+        https://bugs.webkit.org/show_bug.cgi?id=150752
+        &lt;rdar://problem/23343385&gt;
+
+        Reviewed by Mark Lam.
+
+        * inspector/runtime/evaluate-CommandLineAPI-expected.txt: Added.
+        * inspector/runtime/evaluate-CommandLineAPI.html: Added.
+        New test covering the different cases of global evaluation with the
+        CommandLineAPI as a scope extension.
+
+        * http/tests/inspector/console/cross-domain-inspected-node-access-expected.txt:
+        * inspector/console/command-line-api-expected.txt:
+        * inspector/debugger/js-stacktrace-expected.txt:
+        * inspector/debugger/js-stacktrace.html:
+        * inspector/model/stack-trace-expected.txt:
+        * platform/mac/inspector/model/remote-object-expected.txt:
+        Update expectations now that global evaluations are treated as
+        program's [global code] and not evals [eval code]. Also some
+        line number changes.
+
</ins><span class="cx"> 2016-05-06  Tim Horton  &lt;timothy_horton@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         &lt;attachment&gt; element should understand UTIs
</span></span></pre></div>
<a id="trunkLayoutTestshttptestsinspectorconsolecrossdomaininspectednodeaccessexpectedtxt"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/http/tests/inspector/console/cross-domain-inspected-node-access-expected.txt (200532 => 200533)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/http/tests/inspector/console/cross-domain-inspected-node-access-expected.txt        2016-05-06 23:21:16 UTC (rev 200532)
+++ trunk/LayoutTests/http/tests/inspector/console/cross-domain-inspected-node-access-expected.txt        2016-05-06 23:32:28 UTC (rev 200533)
</span><span class="lines">@@ -1,5 +1,5 @@
</span><del>-CONSOLE MESSAGE: line 57: Blocked a frame with origin &quot;http://127.0.0.1:8000&quot; from accessing a frame with origin &quot;http://localhost:8000&quot;. Protocols, domains, and ports must match.
-CONSOLE MESSAGE: line 57: Blocked a frame with origin &quot;http://localhost:8000&quot; from accessing a frame with origin &quot;http://127.0.0.1:8000&quot;. Protocols, domains, and ports must match.
</del><ins>+CONSOLE MESSAGE: line 42: Blocked a frame with origin &quot;http://127.0.0.1:8000&quot; from accessing a frame with origin &quot;http://localhost:8000&quot;. Protocols, domains, and ports must match.
+CONSOLE MESSAGE: line 42: Blocked a frame with origin &quot;http://localhost:8000&quot; from accessing a frame with origin &quot;http://127.0.0.1:8000&quot;. Protocols, domains, and ports must match.
</ins><span class="cx"> Test that code evaluated in the main frame cannot access $0 that resolves to a node in a frame from a different domain. Bug 105423.
</span><span class="cx"> 
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkLayoutTestsinspectorconsolecommandlineapiexpectedtxt"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/inspector/console/command-line-api-expected.txt (200532 => 200533)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/inspector/console/command-line-api-expected.txt        2016-05-06 23:21:16 UTC (rev 200532)
+++ trunk/LayoutTests/inspector/console/command-line-api-expected.txt        2016-05-06 23:32:28 UTC (rev 200533)
</span><span class="lines">@@ -1,4 +1,4 @@
</span><del>-CONSOLE MESSAGE: line 27: The console function $() has changed from $=getElementById(id) to $=querySelector(selector). You might try $(&quot;#%s&quot;)
</del><ins>+CONSOLE MESSAGE: line 12: The console function $() has changed from $=getElementById(id) to $=querySelector(selector). You might try $(&quot;#%s&quot;)
</ins><span class="cx"> Tests that command line api works.
</span><span class="cx"> 
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkLayoutTestsinspectordebuggerjsstacktraceexpectedtxt"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/inspector/debugger/js-stacktrace-expected.txt (200532 => 200533)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/inspector/debugger/js-stacktrace-expected.txt        2016-05-06 23:21:16 UTC (rev 200532)
+++ trunk/LayoutTests/inspector/debugger/js-stacktrace-expected.txt        2016-05-06 23:32:28 UTC (rev 200533)
</span><span class="lines">@@ -19,7 +19,7 @@
</span><span class="cx">     {
</span><span class="cx">         &quot;lineNumber&quot;: 0,
</span><span class="cx">         &quot;columnNumber&quot;: 14,
</span><del>-        &quot;functionName&quot;: &quot;Eval Code&quot;,
</del><ins>+        &quot;functionName&quot;: &quot;Global Code&quot;,
</ins><span class="cx">         &quot;nativeCode&quot;: false,
</span><span class="cx">         &quot;programCode&quot;: true
</span><span class="cx">     }
</span><span class="lines">@@ -40,7 +40,7 @@
</span><span class="cx">         &quot;columnNumber&quot;: 21
</span><span class="cx">     },
</span><span class="cx">     {
</span><del>-        &quot;functionName&quot;: &quot;eval code&quot;,
</del><ins>+        &quot;functionName&quot;: &quot;global code&quot;,
</ins><span class="cx">         &quot;url&quot;: &quot;&quot;,
</span><span class="cx">         &quot;lineNumber&quot;: 0,
</span><span class="cx">         &quot;columnNumber&quot;: 0
</span><span class="lines">@@ -73,7 +73,7 @@
</span><span class="cx">     {
</span><span class="cx">         &quot;lineNumber&quot;: 0,
</span><span class="cx">         &quot;columnNumber&quot;: 28,
</span><del>-        &quot;functionName&quot;: &quot;Eval Code&quot;,
</del><ins>+        &quot;functionName&quot;: &quot;Global Code&quot;,
</ins><span class="cx">         &quot;nativeCode&quot;: false,
</span><span class="cx">         &quot;programCode&quot;: true
</span><span class="cx">     }
</span><span class="lines">@@ -100,7 +100,7 @@
</span><span class="cx">         &quot;columnNumber&quot;: 20
</span><span class="cx">     },
</span><span class="cx">     {
</span><del>-        &quot;functionName&quot;: &quot;eval code&quot;,
</del><ins>+        &quot;functionName&quot;: &quot;global code&quot;,
</ins><span class="cx">         &quot;url&quot;: &quot;&quot;,
</span><span class="cx">         &quot;lineNumber&quot;: 0,
</span><span class="cx">         &quot;columnNumber&quot;: 0
</span></span></pre></div>
<a id="trunkLayoutTestsinspectordebuggerjsstacktracehtml"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/inspector/debugger/js-stacktrace.html (200532 => 200533)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/inspector/debugger/js-stacktrace.html        2016-05-06 23:21:16 UTC (rev 200532)
+++ trunk/LayoutTests/inspector/debugger/js-stacktrace.html        2016-05-06 23:32:28 UTC (rev 200533)
</span><span class="lines">@@ -67,7 +67,7 @@
</span><span class="cx">         if (error)
</span><span class="cx">             InspectorTest.log(error);
</span><span class="cx"> 
</span><del>-        var stackTrace = stripPayloadAfterEval(WebInspector.StackTrace._parseStackTrace(result.value));
</del><ins>+        var stackTrace = stripPayloadAfterGlobalCode(WebInspector.StackTrace._parseStackTrace(result.value));
</ins><span class="cx">         stackTrace = stripFilePaths(stackTrace);
</span><span class="cx"> 
</span><span class="cx">         InspectorTest.log(JSON.stringify(stackTrace, null, 4));
</span><span class="lines">@@ -80,7 +80,7 @@
</span><span class="cx">         if (error)
</span><span class="cx">             InspectorTest.log(error);
</span><span class="cx"> 
</span><del>-        var stackTrace = stripPayloadAfterEval(WebInspector.StackTrace._parseStackTrace(result.value));
</del><ins>+        var stackTrace = stripPayloadAfterGlobalCode(WebInspector.StackTrace._parseStackTrace(result.value));
</ins><span class="cx">         stackTrace = stripFilePaths(stackTrace);
</span><span class="cx"> 
</span><span class="cx">         InspectorTest.log(JSON.stringify(stackTrace, null, 4));
</span><span class="lines">@@ -93,7 +93,7 @@
</span><span class="cx">         if (error)
</span><span class="cx">             InspectorTest.log(error);
</span><span class="cx"> 
</span><del>-        var stackTrace = stripPayloadAfterEval(WebInspector.StackTrace._parseStackTrace(result.value));
</del><ins>+        var stackTrace = stripPayloadAfterGlobalCode(WebInspector.StackTrace._parseStackTrace(result.value));
</ins><span class="cx">         stackTrace = stripFilePaths(stackTrace);
</span><span class="cx"> 
</span><span class="cx">         InspectorTest.log(JSON.stringify(stackTrace, null, 4));
</span><span class="lines">@@ -120,12 +120,12 @@
</span><span class="cx">         return stackTrace.slice(0, index);
</span><span class="cx">     }
</span><span class="cx"> 
</span><del>-    function stripPayloadAfterEval(payload)
</del><ins>+    function stripPayloadAfterGlobalCode(payload)
</ins><span class="cx">     {
</span><span class="cx">         var index = 0;
</span><span class="cx">         for (var frame of payload) {
</span><span class="cx">             index++;
</span><del>-            if (frame.functionName === &quot;eval code&quot;)
</del><ins>+            if (frame.functionName === &quot;global code&quot;)
</ins><span class="cx">                 break;
</span><span class="cx">         }
</span><span class="cx">         return payload.slice(0, index);
</span></span></pre></div>
<a id="trunkLayoutTestsinspectormodelstacktraceexpectedtxt"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/inspector/model/stack-trace-expected.txt (200532 => 200533)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/inspector/model/stack-trace-expected.txt        2016-05-06 23:21:16 UTC (rev 200532)
+++ trunk/LayoutTests/inspector/model/stack-trace-expected.txt        2016-05-06 23:32:28 UTC (rev 200533)
</span><span class="lines">@@ -15,8 +15,8 @@
</span><span class="cx">   4: Global Code (inline-script.js:2) - nativeCode (false) programCode (true)
</span><span class="cx">   5: appendChild - nativeCode (true) programCode (false)
</span><span class="cx">   6: triggerConsoleMessage (stack-trace.html:9) - nativeCode (false) programCode (false)
</span><del>-  7: Eval Code (Anonymous Script 2 (line 1)) - nativeCode (false) programCode (true)
-  8: eval - nativeCode (true) programCode (false)
</del><ins>+  7: Global Code (Anonymous Script 2 (line 1)) - nativeCode (false) programCode (true)
+  8: evaluateWithScopeExtension - nativeCode (true) programCode (false)
</ins><span class="cx">   9: _evaluateOn - nativeCode (true) programCode (false)
</span><span class="cx">   10: _evaluateAndWrap - nativeCode (true) programCode (false)
</span><span class="cx">   11: evaluate - nativeCode (true) programCode (false)
</span></span></pre></div>
<a id="trunkLayoutTestsinspectorruntimeevaluateCommandLineAPIexpectedtxt"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/inspector/runtime/evaluate-CommandLineAPI-expected.txt (0 => 200533)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/inspector/runtime/evaluate-CommandLineAPI-expected.txt                                (rev 0)
+++ trunk/LayoutTests/inspector/runtime/evaluate-CommandLineAPI-expected.txt        2016-05-06 23:32:28 UTC (rev 200533)
</span><span class="lines">@@ -0,0 +1,36 @@
</span><ins>+Tests for the Runtime.evaluate with the Command Line API.
+
+
+== Running test suite: Runtime.evaluate.CommandLineAPI
+-- Running test case: AccessCommandLineAPI
+PASS: CommandLineAPI `keys` can be accessed.
+PASS: CommandLineAPI `keys` should work with a simple object.
+
+-- Running test case: AccessGlobalVariable
+PASS: Should be able to access var in global scope.
+PASS: Should be able to access let in global scope.
+PASS: Should be able to access const in global scope.
+
+-- Running test case: CreateGlobalVariable
+PASS: Should be able to access created var in global scope.
+PASS: Should be able to access created let in global scope.
+PASS: Should be able to access created const in global scope.
+
+-- Running test case: CreateGlobalClass
+PASS: Should be able to access class created in earlier evaluation.
+
+-- Running test case: ExpectedExceptionCreatingDuplicateLexicalGlobalVariables
+PASS: Should be an exception defining a lexical global multiple times.
+
+-- Running test case: NonStrictAndStrictEvaluations
+PASS: Non-strict evaluation. Should be able to access arguments.callee.
+PASS: Script evaluation. Should not be able to access arguments.callee.
+
+-- Running test case: CommandLineAPIDoesNotShadowVariables
+PASS: `keys` is currently CommandLineAPI function.
+PASS: Creating global `keys` variable should be okay.
+PASS: Global `keys` variable should not be shadowed by CommandLineAPI function.
+
+-- Running test case: CommandLineAPIDoesNotShadowGlobalObjectProperties
+PASS: `values` should be `window.values` and not shadowed by CommandLineAPI `values` function.
+
</ins></span></pre></div>
<a id="trunkLayoutTestsinspectorruntimeevaluateCommandLineAPIhtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/inspector/runtime/evaluate-CommandLineAPI.html (0 => 200533)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/inspector/runtime/evaluate-CommandLineAPI.html                                (rev 0)
+++ trunk/LayoutTests/inspector/runtime/evaluate-CommandLineAPI.html        2016-05-06 23:32:28 UTC (rev 200533)
</span><span class="lines">@@ -0,0 +1,179 @@
</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;
+var varGlobalVariable = 1;
+let letGlobalVariable = 2;
+const constGlobalVariable = 3;
+
+function test()
+{
+    const objectGroup = &quot;test&quot;;
+    const includeCommandLineAPI = true;
+    const returnByValue = true;
+
+    function testEvaluate(expression, callback) {
+        RuntimeAgent.evaluate.invoke({expression, objectGroup, includeCommandLineAPI, returnByValue}, (error, resultValue, wasThrown) =&gt; {
+            InspectorTest.assert(!error, &quot;Should not be a protocol error.&quot;);
+            InspectorTest.assert(!wasThrown, &quot;Should not be a runtime error.&quot;);
+            if (callback)
+                callback(resultValue.value);
+        });
+    }
+
+    function testEvaluateThrow(expression, callback) {
+        RuntimeAgent.evaluate.invoke({expression, objectGroup, includeCommandLineAPI, returnByValue}, (error, resultValue, wasThrown) =&gt; {
+            InspectorTest.assert(!error, &quot;Should not be a protocol error.&quot;);
+            InspectorTest.assert(wasThrown, &quot;Should be a runtime error.&quot;);
+            if (callback)
+                callback(wasThrown);
+        });
+    }
+
+    let suite = InspectorTest.createAsyncSuite(&quot;Runtime.evaluate.CommandLineAPI&quot;);
+
+    suite.addTestCase({
+        name: &quot;AccessCommandLineAPI&quot;,
+        description: &quot;Test evaluate can access CommandLineAPI methods.&quot;,
+        test: (resolve, reject) =&gt; {
+            testEvaluate(&quot;keys.toString()&quot;, (resultValue) =&gt; {
+                InspectorTest.expectThat(resultValue.includes(&quot;[Command Line API]&quot;), &quot;CommandLineAPI `keys` can be accessed.&quot;);
+            });
+            testEvaluate(&quot;keys({a:1, b:2})&quot;, (resultValue) =&gt; {
+                InspectorTest.expectThat(resultValue.length === 2 &amp;&amp; resultValue[0] === &quot;a&quot; &amp;&amp; resultValue[1] === &quot;b&quot;, &quot;CommandLineAPI `keys` should work with a simple object.&quot;);
+                resolve();
+            });
+        }
+    });
+
+    suite.addTestCase({
+        name: &quot;AccessGlobalVariable&quot;,
+        description: &quot;Test evaluate can access global variables.&quot;,
+        test: (resolve, reject) =&gt; {
+            testEvaluate(&quot;varGlobalVariable&quot;, (resultValue) =&gt; {
+                InspectorTest.expectThat(resultValue === 1, &quot;Should be able to access var in global scope.&quot;);
+            });
+            testEvaluate(&quot;letGlobalVariable&quot;, (resultValue) =&gt; {
+                InspectorTest.expectThat(resultValue === 2, &quot;Should be able to access let in global scope.&quot;);
+            });
+            testEvaluate(&quot;constGlobalVariable&quot;, (resultValue) =&gt; {
+                InspectorTest.expectThat(resultValue === 3, &quot;Should be able to access const in global scope.&quot;);
+                resolve();
+            });
+        }
+    });
+
+    suite.addTestCase({
+        name: &quot;CreateGlobalVariable&quot;,
+        description: &quot;Test evaluate can create global variables.&quot;,
+        test: (resolve, reject) =&gt; {
+            testEvaluate(`
+                var createdVarGlobalVariable = 1;
+                let createdLetGlobalVariable = 2;
+                const createdConstGlobalVariable = 3;
+            `);
+            testEvaluate(&quot;createdVarGlobalVariable&quot;, (resultValue) =&gt; {
+                InspectorTest.expectThat(resultValue === 1, &quot;Should be able to access created var in global scope.&quot;);
+            });
+            testEvaluate(&quot;createdLetGlobalVariable&quot;, (resultValue) =&gt; {
+                InspectorTest.expectThat(resultValue === 2, &quot;Should be able to access created let in global scope.&quot;);
+            });
+            testEvaluate(&quot;createdConstGlobalVariable&quot;, (resultValue) =&gt; {
+                InspectorTest.expectThat(resultValue === 3, &quot;Should be able to access created const in global scope.&quot;);
+                resolve();
+            });
+        }
+    });
+
+    suite.addTestCase({
+        name: &quot;CreateGlobalClass&quot;,
+        description: &quot;Test evaluate can create a class.&quot;,
+        test: (resolve, reject) =&gt; {
+            testEvaluate(`
+                class Foo {
+                    static staticMethod() {
+                        return 42;
+                    }
+                }
+            `);
+            testEvaluate(&quot;Foo.staticMethod()&quot;, (resultValue) =&gt; {
+                InspectorTest.expectThat(resultValue === 42, &quot;Should be able to access class created in earlier evaluation.&quot;);
+                resolve();
+            });
+        }
+    });
+
+    suite.addTestCase({
+        name: &quot;ExpectedExceptionCreatingDuplicateLexicalGlobalVariables&quot;,
+        description: &quot;Test evaluate produces expected exception creating duplicate lexical global variables across evaluations.&quot;,
+        test: (resolve, reject) =&gt; {
+            testEvaluate(`let duplicateGlobalVariable = 1`);
+            testEvaluateThrow(`let duplicateGlobalVariable = 1`, (wasThrown) =&gt; {
+                InspectorTest.expectThat(wasThrown, &quot;Should be an exception defining a lexical global multiple times.&quot;);
+                resolve();
+            });
+        }
+    });
+
+    suite.addTestCase({
+        name: &quot;NonStrictAndStrictEvaluations&quot;,
+        description: &quot;Test evaluate can run strict and non-strict programs.&quot;,
+        test: (resolve, reject) =&gt; {
+            testEvaluate(`
+                // Not strict, this is okay.
+                (function f() {
+                    return arguments.callee.name;
+                })();
+            `, (resultValue) =&gt; {
+                InspectorTest.expectThat(resultValue === &quot;f&quot;, &quot;Non-strict evaluation. Should be able to access arguments.callee.&quot;);
+            });
+            testEvaluateThrow(`&quot;use strict&quot;;
+                // Strict, this throw an exception.
+                (function() {
+                    return arguments.callee;
+                })();`
+            , (wasThrown) =&gt; {
+                InspectorTest.expectThat(wasThrown, &quot;Script evaluation. Should not be able to access arguments.callee.&quot;);
+                resolve();
+            });
+        }
+    });
+
+    suite.addTestCase({
+        name: &quot;CommandLineAPIDoesNotShadowVariables&quot;,
+        description: &quot;Test CommandLineAPI does not shadow global variables.&quot;,
+        test: (resolve, reject) =&gt; {
+            testEvaluate(&quot;keys.toString()&quot;, (resultValue) =&gt; {
+                InspectorTest.expectThat(resultValue.includes(&quot;[Command Line API]&quot;), &quot;`keys` is currently CommandLineAPI function.&quot;);
+            });
+            testEvaluate(&quot;var keys = 123; keys&quot;, (resultValue) =&gt; {
+                InspectorTest.expectThat(resultValue === 123, &quot;Creating global `keys` variable should be okay.&quot;);
+            });
+            testEvaluate(&quot;keys&quot;, (resultValue) =&gt; {
+                InspectorTest.expectThat(resultValue === 123, &quot;Global `keys` variable should not be shadowed by CommandLineAPI function.&quot;);
+                resolve();
+            });
+        }
+    });
+
+    suite.addTestCase({
+        name: &quot;CommandLineAPIDoesNotShadowGlobalObjectProperties&quot;,
+        description: &quot;Test CommandLineAPI does not shadow global object properties.&quot;,
+        test: (resolve, reject) =&gt; {
+            testEvaluate(&quot;values.toString()&quot;, (resultValue) =&gt; {
+                InspectorTest.expectThat(resultValue === &quot;[object HTMLDivElement]&quot;, &quot;`values` should be `window.values` and not shadowed by CommandLineAPI `values` function.&quot;);
+                resolve();
+            });
+        }
+    });
+
+    suite.runTestCasesAndFinish();
+}
+&lt;/script&gt;
+&lt;/head&gt;
+&lt;body onload=&quot;runTest()&quot;&gt;
+&lt;div id=&quot;values&quot;&gt;&lt;/div&gt; &lt;!-- This introduces the named property `window.values` on the window global object. --&gt;
+&lt;p&gt;Tests for the Runtime.evaluate with the Command Line API.&lt;/p&gt;
+&lt;/body&gt;
+&lt;/html&gt;
</ins></span></pre></div>
<a id="trunkLayoutTestsplatformmacinspectormodelremoteobjectexpectedtxt"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/platform/mac/inspector/model/remote-object-expected.txt (200532 => 200533)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/platform/mac/inspector/model/remote-object-expected.txt        2016-05-06 23:21:16 UTC (rev 200532)
+++ trunk/LayoutTests/platform/mac/inspector/model/remote-object-expected.txt        2016-05-06 23:32:28 UTC (rev 200533)
</span><span class="lines">@@ -2328,7 +2328,7 @@
</span><span class="cx">         &quot;_listeners&quot;: null,
</span><span class="cx">         &quot;_name&quot;: &quot;stack&quot;,
</span><span class="cx">         &quot;_type&quot;: &quot;string&quot;,
</span><del>-        &quot;_value&quot;: &quot;eval code\neval@[native code]\n_evaluateOn\n_evaluateAndWrap\nevaluate&quot;
</del><ins>+        &quot;_value&quot;: &quot;global code\nevaluateWithScopeExtension@[native code]\n_evaluateOn\n_evaluateAndWrap\nevaluate&quot;
</ins><span class="cx">       }
</span><span class="cx">     ],
</span><span class="cx">     &quot;_entries&quot;: null
</span><span class="lines">@@ -2372,7 +2372,7 @@
</span><span class="cx">         &quot;_listeners&quot;: null,
</span><span class="cx">         &quot;_name&quot;: &quot;stack&quot;,
</span><span class="cx">         &quot;_type&quot;: &quot;string&quot;,
</span><del>-        &quot;_value&quot;: &quot;eval@[native code]\neval code\neval@[native code]\n_evaluateOn\n_evaluateAndWrap\nevaluate&quot;
</del><ins>+        &quot;_value&quot;: &quot;eval@[native code]\nglobal code\nevaluateWithScopeEx…ative code]\n_evaluateOn\n_evaluateAndWrap\nevaluate&quot;
</ins><span class="cx">       }
</span><span class="cx">     ],
</span><span class="cx">     &quot;_entries&quot;: null
</span></span></pre></div>
<a id="trunkSourceJavaScriptCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/ChangeLog (200532 => 200533)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/ChangeLog        2016-05-06 23:21:16 UTC (rev 200532)
+++ trunk/Source/JavaScriptCore/ChangeLog        2016-05-06 23:32:28 UTC (rev 200533)
</span><span class="lines">@@ -1,3 +1,56 @@
</span><ins>+2016-05-06  Joseph Pecoraro  &lt;pecoraro@apple.com&gt;
+
+        Web Inspector: Console: Variables defined with let/const aren't accessible outside of console's scope
+        https://bugs.webkit.org/show_bug.cgi?id=150752
+        &lt;rdar://problem/23343385&gt;
+
+        Reviewed by Mark Lam.
+
+        This approach allows Web Inspector to hang a &quot;Scope Extension&quot;, a
+        WithObjectScope, off the GlobalObject. When resolving identifiers
+        in fails to resolve anything in the normal scope chain, consult
+        the scope extension.
+
+        This allows us to eliminate the `with (commandLineAPI) { ... }`
+        block in global console evaluations, and instead makes it a full
+        program evaluation, with the commandLineAPI available and safely
+        shadowed by actual variables as expected.
+
+        * inspector/InjectedScriptSource.js:
+        (InjectedScript.prototype._evaluateOn):
+        Use the new evaluateWithScopeExtension and provide the CommandLineAPI
+        object as the scope extension object.
+
+        (BasicCommandLineAPI):
+        (BasicCommandLineAPI.inScopeVariables): Deleted.
+        Simplify now that we don't need to check for variable shadowing ourselves.
+
+        * inspector/JSInjectedScriptHost.cpp:
+        (Inspector::JSInjectedScriptHost::evaluateWithScopeExtension):
+        * inspector/JSInjectedScriptHost.h:
+        * inspector/JSInjectedScriptHostPrototype.cpp:
+        (Inspector::JSInjectedScriptHostPrototype::finishCreation):
+        (Inspector::jsInjectedScriptHostPrototypeFunctionEvaluateWithScopeExtension):
+        Provide a new InjectedScriptHost method to evaluate a program
+        with a scope extension.
+
+        * runtime/Completion.cpp:
+        (JSC::evaluateWithScopeExtension):
+        * runtime/Completion.h:
+        General JSC::evaluate function to evaluate a program with a scope extension.
+
+        * runtime/JSGlobalObject.cpp:
+        (JSC::JSGlobalObject::setGlobalScopeExtension):
+        (JSC::JSGlobalObject::clearGlobalScopeExtension):
+        (JSC::JSGlobalObject::visitChildren):
+        * runtime/JSGlobalObject.h:
+        (JSC::JSGlobalObject::globalScopeExtension):
+        Hang a scope extension off the global object.
+
+        * runtime/JSScope.cpp:
+        (JSC::JSScope::resolve):
+        Consult the scope extension when resolve fails to find anything normally.
+
</ins><span class="cx"> 2016-05-06  Mark Lam  &lt;mark.lam@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         Add JSC options reportBaselineCompileTimes and reportDFGCompileTimes.
</span></span></pre></div>
<a id="trunkSourceJavaScriptCoreinspectorInjectedScriptSourcejs"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/inspector/InjectedScriptSource.js (200532 => 200533)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/inspector/InjectedScriptSource.js        2016-05-06 23:21:16 UTC (rev 200532)
+++ trunk/Source/JavaScriptCore/inspector/InjectedScriptSource.js        2016-05-06 23:32:28 UTC (rev 200533)
</span><span class="lines">@@ -31,7 +31,8 @@
</span><span class="cx"> 
</span><span class="cx"> (function (InjectedScriptHost, inspectedGlobalObject, injectedScriptId) {
</span><span class="cx"> 
</span><del>-// Protect against Object overwritten by the user code.
</del><ins>+// FIXME: &lt;https://webkit.org/b/152294&gt; Web Inspector: Parse InjectedScriptSource as a built-in to get guaranteed non-user-overriden built-ins
+
</ins><span class="cx"> var Object = {}.constructor;
</span><span class="cx"> 
</span><span class="cx"> function toString(obj)
</span><span class="lines">@@ -519,32 +520,12 @@
</span><span class="cx">             return result;
</span><span class="cx">         }
</span><span class="cx"> 
</span><del>-        // When not evaluating on a call frame we use a 'with' statement to allow var and function statements to leak
-        // into the global scope. This allow them to stick around between evaluations.
-
-        try {
-            if (commandLineAPI) {
-                if (inspectedGlobalObject.console)
-                    inspectedGlobalObject.console.__commandLineAPI = commandLineAPI;
-                else
-                    inspectedGlobalObject.__commandLineAPI = commandLineAPI;
-                expression = &quot;with ((this &amp;&amp; (this.console ? this.console.__commandLineAPI : this.__commandLineAPI)) || {}) { &quot; + expression + &quot;\n}&quot;;
-            }
-
-            var result = evalFunction.call(inspectedGlobalObject, expression);
-
-            if (saveResult)
-                this._saveResult(result);
-
-            return result;
-        } finally {
-            if (commandLineAPI) {
-                if (inspectedGlobalObject.console)
-                    delete inspectedGlobalObject.console.__commandLineAPI;
-                else
-                    delete inspectedGlobalObject.__commandLineAPI;
-            }
-        }
</del><ins>+        // When not evaluating on a call frame, we evaluate as a program
+        // with the Command Line API as a scope extension object.
+        var result = InjectedScriptHost.evaluateWithScopeExtension(expression, commandLineAPI);
+        if (saveResult)
+            this._saveResult(result);
+        return result;
</ins><span class="cx">     },
</span><span class="cx"> 
</span><span class="cx">     wrapCallFrames: function(callFrame)
</span><span class="lines">@@ -1411,38 +1392,16 @@
</span><span class="cx"> 
</span><span class="cx"> function BasicCommandLineAPI(callFrame)
</span><span class="cx"> {
</span><del>-    function inScopeVariables(member)
-    {
-        if (!callFrame)
-            return false;
-
-        var scopeChain = callFrame.scopeChain;
-        for (var i = 0; i &lt; scopeChain.length; ++i) {
-            if (member in scopeChain[i])
-                return true;
-        }
-        return false;
-    }
-
</del><span class="cx">     this.$_ = injectedScript._lastResult;
</span><span class="cx">     this.$exception = injectedScript._exceptionValue;
</span><span class="cx"> 
</span><span class="cx">     // $1-$99
</span><del>-    for (var i = 1; i &lt;= injectedScript._savedResults.length; ++i) {
-        var member = &quot;$&quot; + i;
-        if (member in inspectedGlobalObject)
-            continue;
</del><ins>+    for (var i = 1; i &lt;= injectedScript._savedResults.length; ++i)
</ins><span class="cx">         this.__defineGetter__(&quot;$&quot; + i, bind(injectedScript._savedResult, injectedScript, i));
</span><del>-    }
</del><span class="cx"> 
</span><span class="cx">     // Command Line API methods.
</span><del>-    for (var i = 0; i &lt; BasicCommandLineAPI.methods.length; ++i) {
-        var method = BasicCommandLineAPI.methods[i];
-        var name = method.name;
-        if (name in inspectedGlobalObject || inScopeVariables(name))
-            continue;
-        this[name] = method;
-    }
</del><ins>+    for (var i = 0; i &lt; BasicCommandLineAPI.methods.length; ++i)
+        this[method.name] = method;
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> BasicCommandLineAPI.methods = [
</span></span></pre></div>
<a id="trunkSourceJavaScriptCoreinspectorJSInjectedScriptHostcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/inspector/JSInjectedScriptHost.cpp (200532 => 200533)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/inspector/JSInjectedScriptHost.cpp        2016-05-06 23:21:16 UTC (rev 200532)
+++ trunk/Source/JavaScriptCore/inspector/JSInjectedScriptHost.cpp        2016-05-06 23:32:28 UTC (rev 200533)
</span><span class="lines">@@ -27,6 +27,7 @@
</span><span class="cx"> #include &quot;JSInjectedScriptHost.h&quot;
</span><span class="cx"> 
</span><span class="cx"> #include &quot;BuiltinNames.h&quot;
</span><ins>+#include &quot;Completion.h&quot;
</ins><span class="cx"> #include &quot;DateInstance.h&quot;
</span><span class="cx"> #include &quot;DirectArguments.h&quot;
</span><span class="cx"> #include &quot;Error.h&quot;
</span><span class="lines">@@ -37,6 +38,7 @@
</span><span class="cx"> #include &quot;JSBoundFunction.h&quot;
</span><span class="cx"> #include &quot;JSCInlines.h&quot;
</span><span class="cx"> #include &quot;JSFunction.h&quot;
</span><ins>+#include &quot;JSGlobalObjectFunctions.h&quot;
</ins><span class="cx"> #include &quot;JSInjectedScriptHostPrototype.h&quot;
</span><span class="cx"> #include &quot;JSMap.h&quot;
</span><span class="cx"> #include &quot;JSMapIterator.h&quot;
</span><span class="lines">@@ -48,6 +50,7 @@
</span><span class="cx"> #include &quot;JSTypedArrays.h&quot;
</span><span class="cx"> #include &quot;JSWeakMap.h&quot;
</span><span class="cx"> #include &quot;JSWeakSet.h&quot;
</span><ins>+#include &quot;JSWithScope.h&quot;
</ins><span class="cx"> #include &quot;ObjectConstructor.h&quot;
</span><span class="cx"> #include &quot;ProxyObject.h&quot;
</span><span class="cx"> #include &quot;RegExpObject.h&quot;
</span><span class="lines">@@ -91,6 +94,20 @@
</span><span class="cx">     return globalObject-&gt;evalFunction();
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+JSValue JSInjectedScriptHost::evaluateWithScopeExtension(ExecState* exec)
+{
+    JSValue scriptValue = exec-&gt;argument(0);
+    if (!scriptValue.isString())
+        return throwTypeError(exec, &quot;InjectedScriptHost.evaluateWithScopeExtension first argument must be a string.&quot;);
+
+    String program = scriptValue.toString(exec)-&gt;value(exec);
+    if (exec-&gt;hadException())
+        return jsUndefined();
+
+    JSObject* scopeExtension = exec-&gt;argument(1).getObject();
+    return JSC::evaluateWithScopeExtension(exec, makeSource(program), scopeExtension);
+}
+
</ins><span class="cx"> JSValue JSInjectedScriptHost::internalConstructorName(ExecState* exec)
</span><span class="cx"> {
</span><span class="cx">     if (exec-&gt;argumentCount() &lt; 1)
</span></span></pre></div>
<a id="trunkSourceJavaScriptCoreinspectorJSInjectedScriptHosth"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/inspector/JSInjectedScriptHost.h (200532 => 200533)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/inspector/JSInjectedScriptHost.h        2016-05-06 23:21:16 UTC (rev 200532)
+++ trunk/Source/JavaScriptCore/inspector/JSInjectedScriptHost.h        2016-05-06 23:32:28 UTC (rev 200533)
</span><span class="lines">@@ -60,6 +60,7 @@
</span><span class="cx">     JSC::JSValue evaluate(JSC::ExecState*) const;
</span><span class="cx"> 
</span><span class="cx">     // Functions.
</span><ins>+    JSC::JSValue evaluateWithScopeExtension(JSC::ExecState*);
</ins><span class="cx">     JSC::JSValue internalConstructorName(JSC::ExecState*);
</span><span class="cx">     JSC::JSValue isHTMLAllCollection(JSC::ExecState*);
</span><span class="cx">     JSC::JSValue subtype(JSC::ExecState*);
</span></span></pre></div>
<a id="trunkSourceJavaScriptCoreinspectorJSInjectedScriptHostPrototypecpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/inspector/JSInjectedScriptHostPrototype.cpp (200532 => 200533)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/inspector/JSInjectedScriptHostPrototype.cpp        2016-05-06 23:21:16 UTC (rev 200532)
+++ trunk/Source/JavaScriptCore/inspector/JSInjectedScriptHostPrototype.cpp        2016-05-06 23:32:28 UTC (rev 200533)
</span><span class="lines">@@ -48,6 +48,7 @@
</span><span class="cx"> static EncodedJSValue JSC_HOST_CALL jsInjectedScriptHostPrototypeFunctionWeakSetSize(ExecState*);
</span><span class="cx"> static EncodedJSValue JSC_HOST_CALL jsInjectedScriptHostPrototypeFunctionWeakSetEntries(ExecState*);
</span><span class="cx"> static EncodedJSValue JSC_HOST_CALL jsInjectedScriptHostPrototypeFunctionIteratorEntries(ExecState*);
</span><ins>+static EncodedJSValue JSC_HOST_CALL jsInjectedScriptHostPrototypeFunctionEvaluateWithScopeExtension(ExecState*);
</ins><span class="cx"> 
</span><span class="cx"> static EncodedJSValue JSC_HOST_CALL jsInjectedScriptHostPrototypeAttributeEvaluate(ExecState*);
</span><span class="cx"> 
</span><span class="lines">@@ -69,6 +70,7 @@
</span><span class="cx">     JSC_NATIVE_FUNCTION_WITHOUT_TRANSITION(&quot;weakSetSize&quot;, jsInjectedScriptHostPrototypeFunctionWeakSetSize, DontEnum, 1);
</span><span class="cx">     JSC_NATIVE_FUNCTION_WITHOUT_TRANSITION(&quot;weakSetEntries&quot;, jsInjectedScriptHostPrototypeFunctionWeakSetEntries, DontEnum, 1);
</span><span class="cx">     JSC_NATIVE_FUNCTION_WITHOUT_TRANSITION(&quot;iteratorEntries&quot;, jsInjectedScriptHostPrototypeFunctionIteratorEntries, DontEnum, 1);
</span><ins>+    JSC_NATIVE_FUNCTION_WITHOUT_TRANSITION(&quot;evaluateWithScopeExtension&quot;, jsInjectedScriptHostPrototypeFunctionEvaluateWithScopeExtension, DontEnum, 1);
</ins><span class="cx"> 
</span><span class="cx">     JSC_NATIVE_GETTER(&quot;evaluate&quot;, jsInjectedScriptHostPrototypeAttributeEvaluate, DontEnum | Accessor);
</span><span class="cx"> }
</span><span class="lines">@@ -80,7 +82,6 @@
</span><span class="cx">     if (!castedThis)
</span><span class="cx">         return throwVMTypeError(exec);
</span><span class="cx"> 
</span><del>-    ASSERT_GC_OBJECT_INHERITS(castedThis, JSInjectedScriptHost::info());
</del><span class="cx">     return JSValue::encode(castedThis-&gt;evaluate(exec));
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="lines">@@ -91,7 +92,6 @@
</span><span class="cx">     if (!castedThis)
</span><span class="cx">         return throwVMTypeError(exec);
</span><span class="cx"> 
</span><del>-    ASSERT_GC_OBJECT_INHERITS(castedThis, JSInjectedScriptHost::info());
</del><span class="cx">     return JSValue::encode(castedThis-&gt;internalConstructorName(exec));
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="lines">@@ -102,7 +102,6 @@
</span><span class="cx">     if (!castedThis)
</span><span class="cx">         return throwVMTypeError(exec);
</span><span class="cx"> 
</span><del>-    ASSERT_GC_OBJECT_INHERITS(castedThis, JSInjectedScriptHost::info());
</del><span class="cx">     return JSValue::encode(castedThis-&gt;isHTMLAllCollection(exec));
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="lines">@@ -113,7 +112,6 @@
</span><span class="cx">     if (!castedThis)
</span><span class="cx">         return throwVMTypeError(exec);
</span><span class="cx"> 
</span><del>-    ASSERT_GC_OBJECT_INHERITS(castedThis, JSInjectedScriptHost::info());
</del><span class="cx">     return JSValue::encode(castedThis-&gt;weakMapSize(exec));
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="lines">@@ -124,7 +122,6 @@
</span><span class="cx">     if (!castedThis)
</span><span class="cx">         return throwVMTypeError(exec);
</span><span class="cx"> 
</span><del>-    ASSERT_GC_OBJECT_INHERITS(castedThis, JSInjectedScriptHost::info());
</del><span class="cx">     return JSValue::encode(castedThis-&gt;weakMapEntries(exec));
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="lines">@@ -135,7 +132,6 @@
</span><span class="cx">     if (!castedThis)
</span><span class="cx">         return throwVMTypeError(exec);
</span><span class="cx"> 
</span><del>-    ASSERT_GC_OBJECT_INHERITS(castedThis, JSInjectedScriptHost::info());
</del><span class="cx">     return JSValue::encode(castedThis-&gt;weakSetSize(exec));
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="lines">@@ -146,7 +142,6 @@
</span><span class="cx">     if (!castedThis)
</span><span class="cx">         return throwVMTypeError(exec);
</span><span class="cx"> 
</span><del>-    ASSERT_GC_OBJECT_INHERITS(castedThis, JSInjectedScriptHost::info());
</del><span class="cx">     return JSValue::encode(castedThis-&gt;weakSetEntries(exec));
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="lines">@@ -157,10 +152,19 @@
</span><span class="cx">     if (!castedThis)
</span><span class="cx">         return throwVMTypeError(exec);
</span><span class="cx"> 
</span><del>-    ASSERT_GC_OBJECT_INHERITS(castedThis, JSInjectedScriptHost::info());
</del><span class="cx">     return JSValue::encode(castedThis-&gt;iteratorEntries(exec));
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+EncodedJSValue JSC_HOST_CALL jsInjectedScriptHostPrototypeFunctionEvaluateWithScopeExtension(ExecState* exec)
+{
+    JSValue thisValue = exec-&gt;thisValue();
+    JSInjectedScriptHost* castedThis = jsDynamicCast&lt;JSInjectedScriptHost*&gt;(thisValue);
+    if (!castedThis)
+        return throwVMTypeError(exec);
+
+    return JSValue::encode(castedThis-&gt;evaluateWithScopeExtension(exec));
+}
+
</ins><span class="cx"> EncodedJSValue JSC_HOST_CALL jsInjectedScriptHostPrototypeFunctionSubtype(ExecState* exec)
</span><span class="cx"> {
</span><span class="cx">     JSValue thisValue = exec-&gt;thisValue();
</span><span class="lines">@@ -168,7 +172,6 @@
</span><span class="cx">     if (!castedThis)
</span><span class="cx">         return throwVMTypeError(exec);
</span><span class="cx"> 
</span><del>-    ASSERT_GC_OBJECT_INHERITS(castedThis, JSInjectedScriptHost::info());
</del><span class="cx">     return JSValue::encode(castedThis-&gt;subtype(exec));
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="lines">@@ -179,7 +182,6 @@
</span><span class="cx">     if (!castedThis)
</span><span class="cx">         return throwVMTypeError(exec);
</span><span class="cx"> 
</span><del>-    ASSERT_GC_OBJECT_INHERITS(castedThis, JSInjectedScriptHost::info());
</del><span class="cx">     return JSValue::encode(castedThis-&gt;functionDetails(exec));
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="lines">@@ -190,7 +192,6 @@
</span><span class="cx">     if (!castedThis)
</span><span class="cx">         return throwVMTypeError(exec);
</span><span class="cx"> 
</span><del>-    ASSERT_GC_OBJECT_INHERITS(castedThis, JSInjectedScriptHost::info());
</del><span class="cx">     return JSValue::encode(castedThis-&gt;getInternalProperties(exec));
</span><span class="cx"> }
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceJavaScriptCoreruntimeCompletioncpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/runtime/Completion.cpp (200532 => 200533)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/runtime/Completion.cpp        2016-05-06 23:21:16 UTC (rev 200532)
+++ trunk/Source/JavaScriptCore/runtime/Completion.cpp        2016-05-06 23:32:28 UTC (rev 200533)
</span><span class="lines">@@ -35,6 +35,7 @@
</span><span class="cx"> #include &quot;JSInternalPromiseDeferred.h&quot;
</span><span class="cx"> #include &quot;JSLock.h&quot;
</span><span class="cx"> #include &quot;JSModuleRecord.h&quot;
</span><ins>+#include &quot;JSWithScope.h&quot;
</ins><span class="cx"> #include &quot;ModuleAnalyzer.h&quot;
</span><span class="cx"> #include &quot;ModuleLoaderObject.h&quot;
</span><span class="cx"> #include &quot;Parser.h&quot;
</span><span class="lines">@@ -121,6 +122,28 @@
</span><span class="cx">     return evaluate(exec, source, thisValue, returnedException);
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+JSValue evaluateWithScopeExtension(ExecState* exec, const SourceCode&amp; source, JSObject* scopeExtensionObject)
+{
+    JSGlobalObject* globalObject = exec-&gt;vmEntryGlobalObject();
+
+    if (scopeExtensionObject) {
+        JSScope* ignoredPreviousScope = globalObject-&gt;globalScope();
+        globalObject-&gt;setGlobalScopeExtension(JSWithScope::create(exec-&gt;vm(), globalObject, scopeExtensionObject, ignoredPreviousScope));
+    }
+
+    NakedPtr&lt;Exception&gt; exception;
+    JSValue returnValue = JSC::evaluate(globalObject-&gt;globalExec(), source, globalObject, exception);
+
+    // Don't swallow the exception.
+    if (exception)
+        globalObject-&gt;vm().restorePreviousException(exception);
+
+    if (scopeExtensionObject)
+        globalObject-&gt;clearGlobalScopeExtension();
+
+    return returnValue;
+}
+
</ins><span class="cx"> static Symbol* createSymbolForEntryPointModule(VM&amp; vm)
</span><span class="cx"> {
</span><span class="cx">     // Generate the unique key for the source-provided module.
</span></span></pre></div>
<a id="trunkSourceJavaScriptCoreruntimeCompletionh"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/runtime/Completion.h (200532 => 200533)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/runtime/Completion.h        2016-05-06 23:21:16 UTC (rev 200532)
+++ trunk/Source/JavaScriptCore/runtime/Completion.h        2016-05-06 23:32:28 UTC (rev 200533)
</span><span class="lines">@@ -31,7 +31,7 @@
</span><span class="cx"> 
</span><span class="cx"> class Exception;
</span><span class="cx"> class ExecState;
</span><del>-class JSScope;
</del><ins>+class JSObject;
</ins><span class="cx"> class ParserError;
</span><span class="cx"> class SourceCode;
</span><span class="cx"> class VM;
</span><span class="lines">@@ -55,6 +55,8 @@
</span><span class="cx">     return profiledEvaluate(exec, reason, sourceCode, thisValue, unused);
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+JS_EXPORT_PRIVATE JSValue evaluateWithScopeExtension(ExecState*, const SourceCode&amp;, JSObject* scopeExtension);
+
</ins><span class="cx"> // Load the module source and evaluate it.
</span><span class="cx"> JS_EXPORT_PRIVATE JSInternalPromise* loadAndEvaluateModule(ExecState*, const String&amp; moduleName);
</span><span class="cx"> JS_EXPORT_PRIVATE JSInternalPromise* loadAndEvaluateModule(ExecState*, const SourceCode&amp;);
</span></span></pre></div>
<a id="trunkSourceJavaScriptCoreruntimeJSGlobalObjectcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/runtime/JSGlobalObject.cpp (200532 => 200533)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/runtime/JSGlobalObject.cpp        2016-05-06 23:21:16 UTC (rev 200532)
+++ trunk/Source/JavaScriptCore/runtime/JSGlobalObject.cpp        2016-05-06 23:32:28 UTC (rev 200533)
</span><span class="lines">@@ -875,6 +875,16 @@
</span><span class="cx">     addGlobalVar(propertyName);
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+void JSGlobalObject::setGlobalScopeExtension(JSScope* scope)
+{
+    m_globalScopeExtension.set(vm(), this, scope);
+}
+
+void JSGlobalObject::clearGlobalScopeExtension()
+{
+    m_globalScopeExtension.clear();
+}
+
</ins><span class="cx"> static inline JSObject* lastInPrototypeChain(JSObject* object)
</span><span class="cx"> {
</span><span class="cx">     JSObject* o = object;
</span><span class="lines">@@ -1034,6 +1044,7 @@
</span><span class="cx">     visitor.append(&amp;thisObject-&gt;m_globalThis);
</span><span class="cx"> 
</span><span class="cx">     visitor.append(&amp;thisObject-&gt;m_globalLexicalEnvironment);
</span><ins>+    visitor.append(&amp;thisObject-&gt;m_globalScopeExtension);
</ins><span class="cx">     visitor.append(&amp;thisObject-&gt;m_globalCallee);
</span><span class="cx">     visitor.append(&amp;thisObject-&gt;m_regExpConstructor);
</span><span class="cx">     visitor.append(&amp;thisObject-&gt;m_errorConstructor);
</span></span></pre></div>
<a id="trunkSourceJavaScriptCoreruntimeJSGlobalObjecth"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/runtime/JSGlobalObject.h (200532 => 200533)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/runtime/JSGlobalObject.h        2016-05-06 23:21:16 UTC (rev 200532)
+++ trunk/Source/JavaScriptCore/runtime/JSGlobalObject.h        2016-05-06 23:32:28 UTC (rev 200533)
</span><span class="lines">@@ -217,6 +217,7 @@
</span><span class="cx">     WriteBarrier&lt;JSObject&gt; m_globalThis;
</span><span class="cx"> 
</span><span class="cx">     WriteBarrier&lt;JSGlobalLexicalEnvironment&gt; m_globalLexicalEnvironment;
</span><ins>+    WriteBarrier&lt;JSScope&gt; m_globalScopeExtension;
</ins><span class="cx">     WriteBarrier&lt;JSObject&gt; m_globalCallee;
</span><span class="cx">     WriteBarrier&lt;RegExpConstructor&gt; m_regExpConstructor;
</span><span class="cx">     WriteBarrier&lt;ErrorConstructor&gt; m_errorConstructor;
</span><span class="lines">@@ -455,6 +456,10 @@
</span><span class="cx">     JSScope* globalScope() { return m_globalLexicalEnvironment.get(); }
</span><span class="cx">     JSGlobalLexicalEnvironment* globalLexicalEnvironment() { return m_globalLexicalEnvironment.get(); }
</span><span class="cx"> 
</span><ins>+    JSScope* globalScopeExtension() { return m_globalScopeExtension.get(); }
+    void setGlobalScopeExtension(JSScope*);
+    void clearGlobalScopeExtension();
+
</ins><span class="cx">     // The following accessors return pristine values, even if a script 
</span><span class="cx">     // replaces the global object's associated property.
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceJavaScriptCoreruntimeJSScopecpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/runtime/JSScope.cpp (200532 => 200533)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/runtime/JSScope.cpp        2016-05-06 23:21:16 UTC (rev 200532)
+++ trunk/Source/JavaScriptCore/runtime/JSScope.cpp        2016-05-06 23:32:28 UTC (rev 200533)
</span><span class="lines">@@ -203,8 +203,18 @@
</span><span class="cx">         JSScope* scope = it.scope();
</span><span class="cx">         JSObject* object = it.get();
</span><span class="cx"> 
</span><del>-        if (++it == end) // Global scope.
</del><ins>+        // Global scope.
+        if (++it == end) {
+            JSScope* globalScopeExtension = scope-&gt;globalObject()-&gt;globalScopeExtension();
+            if (UNLIKELY(globalScopeExtension)) {
+                if (object-&gt;hasProperty(exec, ident))
+                    return object;
+                JSObject* extensionScopeObject = JSScope::objectAtScope(globalScopeExtension);
+                if (extensionScopeObject-&gt;hasProperty(exec, ident))
+                    return extensionScopeObject;
+            }
</ins><span class="cx">             return object;
</span><ins>+        }
</ins><span class="cx"> 
</span><span class="cx">         if (object-&gt;hasProperty(exec, ident)) {
</span><span class="cx">             if (!isUnscopable(exec, scope, object, ident))
</span></span></pre></div>
<a id="trunkSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/ChangeLog (200532 => 200533)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/ChangeLog        2016-05-06 23:21:16 UTC (rev 200532)
+++ trunk/Source/WebCore/ChangeLog        2016-05-06 23:32:28 UTC (rev 200533)
</span><span class="lines">@@ -1,3 +1,25 @@
</span><ins>+2016-05-06  Joseph Pecoraro  &lt;pecoraro@apple.com&gt;
+
+        Web Inspector: Console: Variables defined with let/const aren't accessible outside of console's scope
+        https://bugs.webkit.org/show_bug.cgi?id=150752
+        &lt;rdar://problem/23343385&gt;
+
+        Reviewed by Mark Lam.
+
+        Test: inspector/runtime/evaluate-CommandLineAPI.html
+
+        * inspector/CommandLineAPIModuleSource.js:
+        (bind):
+        (this.member.toString):
+        (CommandLineAPI):
+        (CommandLineAPIImpl.prototype):
+        (slice): Deleted.
+        (bound): Deleted.
+        (bound.toString): Deleted.
+        (inScopeVariables): Deleted.
+        (customToStringMethod): Deleted.
+        Simplify now that we don't need to do our own variable shadow checking.
+
</ins><span class="cx"> 2016-05-06  Tim Horton  &lt;timothy_horton@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         &lt;attachment&gt; element should understand UTIs
</span></span></pre></div>
<a id="trunkSourceWebCoreinspectorCommandLineAPIModuleSourcejs"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/inspector/CommandLineAPIModuleSource.js (200532 => 200533)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/inspector/CommandLineAPIModuleSource.js        2016-05-06 23:21:16 UTC (rev 200532)
+++ trunk/Source/WebCore/inspector/CommandLineAPIModuleSource.js        2016-05-06 23:32:28 UTC (rev 200533)
</span><span class="lines">@@ -37,40 +37,13 @@
</span><span class="cx">  */
</span><span class="cx"> (function (InjectedScriptHost, inspectedWindow, injectedScriptId, injectedScript, CommandLineAPIHost) {
</span><span class="cx"> 
</span><del>-/**
- * @param {Arguments} array
- * @param {number=} index
- * @return {Array.&lt;*&gt;}
- */
-function slice(array, index)
-{
-    var result = [];
-    for (var i = index || 0; i &lt; array.length; ++i)
-        result.push(array[i]);
-    return result;
-}
</del><ins>+// FIXME: &lt;https://webkit.org/b/152294&gt; Web Inspector: Parse InjectedScriptSource as a built-in to get guaranteed non-user-overriden built-ins
</ins><span class="cx"> 
</span><del>-/**
- * Please use this bind, not the one from Function.prototype
- * @param {function(...)} func
- * @param {Object} thisObject
- * @param {...number} var_args
- */
-function bind(func, thisObject, var_args)
</del><ins>+function bind(func, thisObject, ...outerArgs)
</ins><span class="cx"> {
</span><del>-    var args = slice(arguments, 2);
-
-    /**
-     * @param {...number} var_args
-     */
-    function bound(var_args)
-    {
-        return func.apply(thisObject, args.concat(slice(arguments)));
</del><ins>+    return function(...innerArgs) {
+        return func.apply(thisObject, outerArgs.concat(innerArgs));
</ins><span class="cx">     }
</span><del>-    bound.toString = function() {
-        return &quot;bound: &quot; + func;
-    };
-    return bound;
</del><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> /**
</span><span class="lines">@@ -80,55 +53,21 @@
</span><span class="cx">  */
</span><span class="cx"> function CommandLineAPI(commandLineAPIImpl, callFrame)
</span><span class="cx"> {
</span><del>-    /**
-     * @param {string} member
-     * @return {boolean}
-     */
-    function inScopeVariables(member)
-    {
-        if (!callFrame)
-            return false;
</del><ins>+    this.$_ = injectedScript._lastResult;
+    this.$exception = injectedScript._exceptionValue;
</ins><span class="cx"> 
</span><del>-        var scopeChain = callFrame.scopeChain;
-        for (var i = 0; i &lt; scopeChain.length; ++i) {
-            if (member in scopeChain[i])
-                return true;
-        }
-        return false;
-    }
-
-    /**
-     * @param {string} name The name of the method for which a toString method should be generated.
-     * @return {function():string}
-     */
-    function customToStringMethod(name)
-    {
-        return function () { return &quot;function &quot; + name + &quot;() { [Command Line API] }&quot;; };
-    }
-
-    for (var i = 0; i &lt; CommandLineAPI.members_.length; ++i) {
-        var member = CommandLineAPI.members_[i];
-        if (member in inspectedWindow || inScopeVariables(member))
-            continue;
-
-        this[member] = bind(commandLineAPIImpl[member], commandLineAPIImpl);
-        this[member].toString = customToStringMethod(member);
-    }
-
</del><span class="cx">     // $0
</span><span class="cx">     this.__defineGetter__(&quot;$0&quot;, bind(commandLineAPIImpl._inspectedObject, commandLineAPIImpl));
</span><span class="cx"> 
</span><span class="cx">     // $1-$99
</span><del>-    for (var i = 1; i &lt;= injectedScript._savedResults.length; ++i) {
-        var member = &quot;$&quot; + i;
-        if (member in inspectedWindow || inScopeVariables(member))
-            continue;
-
</del><ins>+    for (var i = 1; i &lt;= injectedScript._savedResults.length; ++i)
</ins><span class="cx">         this.__defineGetter__(&quot;$&quot; + i, bind(injectedScript._savedResult, injectedScript, i));
</span><del>-    }
</del><span class="cx"> 
</span><del>-    this.$_ = injectedScript._lastResult;
-    this.$exception = injectedScript._exceptionValue;
</del><ins>+    // Command Line API methods.
+    for (let member of CommandLineAPI.members_) {
+        this[member] = bind(commandLineAPIImpl[member], commandLineAPIImpl);
+        this[member].toString = function() { return &quot;function &quot; + member + &quot;() { [Command Line API] }&quot; };
+    }
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> /**
</span><span class="lines">@@ -177,8 +116,8 @@
</span><span class="cx">     $$: function (selector, start)
</span><span class="cx">     {
</span><span class="cx">         if (this._canQuerySelectorOnNode(start))
</span><del>-            return slice(start.querySelectorAll(selector));
-        return slice(inspectedWindow.document.querySelectorAll(selector));
</del><ins>+            return Array.from(start.querySelectorAll(selector));
+        return Array.from(inspectedWindow.document.querySelectorAll(selector));
</ins><span class="cx">     },
</span><span class="cx"> 
</span><span class="cx">     /**
</span></span></pre>
</div>
</div>

</body>
</html>