<!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>[160924] trunk/Source/WebCore</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/160924">160924</a></dd>
<dt>Author</dt> <dd>joepeck@webkit.org</dd>
<dt>Date</dt> <dd>2013-12-20 14:04:28 -0800 (Fri, 20 Dec 2013)</dd>
</dl>

<h3>Log Message</h3>
<pre>Web Inspector: Extract CommandLineAPI into its own InjectedScriptModule
https://bugs.webkit.org/show_bug.cgi?id=126038

Reviewed by Timothy Hatcher.

No tests, no observable change in behavior.

Move the CommandLineAPI source into its own module. Load the module
in InjectedScripts for WebCore::Pages. Not for workers.

Moving CommandLineAPI into it's own module moves it from being inside
the same anonymous function to being evaluated outside the anonymous
function. To connect the two InjectedScript passes itself to the
injected module, and the CommandLineAPI module places its class on the
injectedScript as injectedScript.CommandLineAPI.

This essentially makes the CommandLineAPI module an InjectedScript
extension. InjectedScriptSource checks for the existence of
this.CommandLineAPI to see if the fuller version is available. Otherwise
it falls back to a BasicCommandLineAPI which only exposes &quot;$_&quot;,
which is the &quot;last evaluated result&quot;. That will be useful for JS Contexts
and Workers.

At the same time, this patch makes InjectedScriptModule more generic,
to support being used in a pure JavaScript environment, meaning one
without &quot;window&quot; as the global object.

* CMakeLists.txt:
* DerivedSources.make:
* GNUmakefile.am:
* GNUmakefile.list.am:
* WebCore.vcxproj/WebCore.vcxproj:
* WebCore.vcxproj/WebCore.vcxproj.filters:
* WebCore.xcodeproj/project.pbxproj:
* inspector/InspectorAllInOne.cpp:
Add files. Minify the CommandLineAPIModuleSource in generation.

* inspector/CommandLineAPIModule.h: Added.
* inspector/CommandLineAPIModule.cpp: Added.
(WebCore::CommandLineAPIModule::CommandLineAPIModule):
(WebCore::CommandLineAPIModule::injectIfNeeded):
(WebCore::CommandLineAPIModule::source):
Inject the module that doesn't return an object, its just evaluated code
extending the original InjectedScript.

* inspector/InjectedScriptModule.h:
* inspector/InjectedScriptModule.cpp:
(WebCore::InjectedScriptModule::ensureInjected):
Only ASSERT the result was an object if the Module claims it returns an object.

* inspector/InjectedScriptCanvasModule.h:
(WebCore::InjectedScriptCanvasModule::returnsObject):
Return an object used later to call into the CanvasModule.

* inspector/PageRuntimeAgent.cpp:
(WebCore::PageRuntimeAgent::injectedScriptForEval):
Ensure the CommandLineAPIModule is loaded in the Page's InjectedScript.

* inspector/CommandLineAPIModuleSource.js: Added.
Create the CommandLineAPI class and place it on injectedScript.

* inspector/InjectedScriptSource.js:
(InjectedScript.prototype._evaluateOn):
Inject either the BasicCommandLineAPI or extended CommandLineAPI.
Derive the globalObject dynamically instead of assuming window.
Inject the commandLineAPI on window.console or the globalObject based on context.
Audit and rename uses of &quot;window&quot; to something like globalObject.</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkSourceWebCoreCMakeListstxt">trunk/Source/WebCore/CMakeLists.txt</a></li>
<li><a href="#trunkSourceWebCoreChangeLog">trunk/Source/WebCore/ChangeLog</a></li>
<li><a href="#trunkSourceWebCoreDerivedSourcesmake">trunk/Source/WebCore/DerivedSources.make</a></li>
<li><a href="#trunkSourceWebCoreGNUmakefileam">trunk/Source/WebCore/GNUmakefile.am</a></li>
<li><a href="#trunkSourceWebCoreGNUmakefilelistam">trunk/Source/WebCore/GNUmakefile.list.am</a></li>
<li><a href="#trunkSourceWebCoreWebCorevcxprojWebCorevcxproj">trunk/Source/WebCore/WebCore.vcxproj/WebCore.vcxproj</a></li>
<li><a href="#trunkSourceWebCoreWebCorevcxprojWebCorevcxprojfilters">trunk/Source/WebCore/WebCore.vcxproj/WebCore.vcxproj.filters</a></li>
<li><a href="#trunkSourceWebCoreWebCorexcodeprojprojectpbxproj">trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj</a></li>
<li><a href="#trunkSourceWebCoreinspectorInjectedScriptCanvasModuleh">trunk/Source/WebCore/inspector/InjectedScriptCanvasModule.h</a></li>
<li><a href="#trunkSourceWebCoreinspectorInjectedScriptModulecpp">trunk/Source/WebCore/inspector/InjectedScriptModule.cpp</a></li>
<li><a href="#trunkSourceWebCoreinspectorInjectedScriptModuleh">trunk/Source/WebCore/inspector/InjectedScriptModule.h</a></li>
<li><a href="#trunkSourceWebCoreinspectorInjectedScriptSourcejs">trunk/Source/WebCore/inspector/InjectedScriptSource.js</a></li>
<li><a href="#trunkSourceWebCoreinspectorInspectorAllInOnecpp">trunk/Source/WebCore/inspector/InspectorAllInOne.cpp</a></li>
<li><a href="#trunkSourceWebCoreinspectorPageRuntimeAgentcpp">trunk/Source/WebCore/inspector/PageRuntimeAgent.cpp</a></li>
</ul>

<h3>Added Paths</h3>
<ul>
<li><a href="#trunkSourceWebCoreinspectorCommandLineAPIModulecpp">trunk/Source/WebCore/inspector/CommandLineAPIModule.cpp</a></li>
<li><a href="#trunkSourceWebCoreinspectorCommandLineAPIModuleh">trunk/Source/WebCore/inspector/CommandLineAPIModule.h</a></li>
<li><a href="#trunkSourceWebCoreinspectorCommandLineAPIModuleSourcejs">trunk/Source/WebCore/inspector/CommandLineAPIModuleSource.js</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkSourceWebCoreCMakeListstxt"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/CMakeLists.txt (160923 => 160924)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/CMakeLists.txt        2013-12-20 22:01:27 UTC (rev 160923)
+++ trunk/Source/WebCore/CMakeLists.txt        2013-12-20 22:04:28 UTC (rev 160924)
</span><span class="lines">@@ -1568,6 +1568,7 @@
</span><span class="cx">     html/shadow/SpinButtonElement.cpp
</span><span class="cx">     html/shadow/TextControlInnerElements.cpp
</span><span class="cx"> 
</span><ins>+    inspector/CommandLineAPIModule.cpp
</ins><span class="cx">     inspector/ConsoleMessage.cpp
</span><span class="cx">     inspector/ContentSearchUtils.cpp
</span><span class="cx">     inspector/DOMEditor.cpp
</span><span class="lines">@@ -3084,6 +3085,17 @@
</span><span class="cx"> list(APPEND WebCore_SOURCES ${DERIVED_SOURCES_WEBCORE_DIR}/InjectedScriptSource.h)
</span><span class="cx"> 
</span><span class="cx"> 
</span><ins>+# Generate CommandLineAPIModuleSource.h
+add_custom_command(
+    OUTPUT ${DERIVED_SOURCES_WEBCORE_DIR}/CommandLineAPIModuleSource.h ${DERIVED_SOURCES_WEBCORE_DIR}/CommandLineAPIModuleSource.min.js
+    MAIN_DEPENDENCY inspector/CommandLineAPIModuleSource.js
+    DEPENDS ${WEBCORE_DIR}/inspector/xxd.pl ${WEBCORE_DIR}/inspector/Scripts/jsmin.py
+    COMMAND ${PYTHON_EXECUTABLE} ${WEBCORE_DIR}/inspector/Scripts/jsmin.py &lt; ${WEBCORE_DIR}/inspector/CommandLineAPIModuleSource.js &gt; ${DERIVED_SOURCES_WEBCORE_DIR}/CommandLineAPIModuleSource.min.js
+    COMMAND ${PERL_EXECUTABLE} ${WEBCORE_DIR}/inspector/xxd.pl CommandLineAPIModuleSource_js ${DERIVED_SOURCES_WEBCORE_DIR}/CommandLineAPIModuleSource.min.js ${DERIVED_SOURCES_WEBCORE_DIR}/CommandLineAPIModuleSource.h
+    VERBATIM)
+list(APPEND WebCore_SOURCES ${DERIVED_SOURCES_WEBCORE_DIR}/CommandLineAPIModuleSource.h)
+
+
</ins><span class="cx"> # Generate InjectedScriptCanvasModuleSource.h
</span><span class="cx"> add_custom_command(
</span><span class="cx">     OUTPUT ${DERIVED_SOURCES_WEBCORE_DIR}/InjectedScriptCanvasModuleSource.h ${DERIVED_SOURCES_WEBCORE_DIR}/InjectedScriptCanvasModuleSource.min.js
</span></span></pre></div>
<a id="trunkSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/ChangeLog (160923 => 160924)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/ChangeLog        2013-12-20 22:01:27 UTC (rev 160923)
+++ trunk/Source/WebCore/ChangeLog        2013-12-20 22:04:28 UTC (rev 160924)
</span><span class="lines">@@ -1,3 +1,73 @@
</span><ins>+2013-12-20  Joseph Pecoraro  &lt;pecoraro@apple.com&gt;
+
+        Web Inspector: Extract CommandLineAPI into its own InjectedScriptModule
+        https://bugs.webkit.org/show_bug.cgi?id=126038
+
+        Reviewed by Timothy Hatcher.
+
+        No tests, no observable change in behavior.
+
+        Move the CommandLineAPI source into its own module. Load the module
+        in InjectedScripts for WebCore::Pages. Not for workers.
+
+        Moving CommandLineAPI into it's own module moves it from being inside
+        the same anonymous function to being evaluated outside the anonymous
+        function. To connect the two InjectedScript passes itself to the
+        injected module, and the CommandLineAPI module places its class on the
+        injectedScript as injectedScript.CommandLineAPI.
+
+        This essentially makes the CommandLineAPI module an InjectedScript
+        extension. InjectedScriptSource checks for the existence of
+        this.CommandLineAPI to see if the fuller version is available. Otherwise
+        it falls back to a BasicCommandLineAPI which only exposes &quot;$_&quot;,
+        which is the &quot;last evaluated result&quot;. That will be useful for JS Contexts
+        and Workers.
+
+        At the same time, this patch makes InjectedScriptModule more generic,
+        to support being used in a pure JavaScript environment, meaning one
+        without &quot;window&quot; as the global object.
+
+        * CMakeLists.txt:
+        * DerivedSources.make:
+        * GNUmakefile.am:
+        * GNUmakefile.list.am:
+        * WebCore.vcxproj/WebCore.vcxproj:
+        * WebCore.vcxproj/WebCore.vcxproj.filters:
+        * WebCore.xcodeproj/project.pbxproj:
+        * inspector/InspectorAllInOne.cpp:
+        Add files. Minify the CommandLineAPIModuleSource in generation.
+
+        * inspector/CommandLineAPIModule.h: Added.
+        * inspector/CommandLineAPIModule.cpp: Added.
+        (WebCore::CommandLineAPIModule::CommandLineAPIModule):
+        (WebCore::CommandLineAPIModule::injectIfNeeded):
+        (WebCore::CommandLineAPIModule::source):
+        Inject the module that doesn't return an object, its just evaluated code
+        extending the original InjectedScript.
+
+        * inspector/InjectedScriptModule.h:
+        * inspector/InjectedScriptModule.cpp:
+        (WebCore::InjectedScriptModule::ensureInjected):
+        Only ASSERT the result was an object if the Module claims it returns an object.
+
+        * inspector/InjectedScriptCanvasModule.h:
+        (WebCore::InjectedScriptCanvasModule::returnsObject):
+        Return an object used later to call into the CanvasModule.
+
+        * inspector/PageRuntimeAgent.cpp:
+        (WebCore::PageRuntimeAgent::injectedScriptForEval):
+        Ensure the CommandLineAPIModule is loaded in the Page's InjectedScript.
+
+        * inspector/CommandLineAPIModuleSource.js: Added.
+        Create the CommandLineAPI class and place it on injectedScript.
+
+        * inspector/InjectedScriptSource.js:
+        (InjectedScript.prototype._evaluateOn):
+        Inject either the BasicCommandLineAPI or extended CommandLineAPI.
+        Derive the globalObject dynamically instead of assuming window.
+        Inject the commandLineAPI on window.console or the globalObject based on context.
+        Audit and rename uses of &quot;window&quot; to something like globalObject.
+
</ins><span class="cx"> 2013-12-20  Tim Horton  &lt;timothy_horton@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         WebKit2 View Gestures: Implement smartMagnifyWithEvent: and make it work
</span></span></pre></div>
<a id="trunkSourceWebCoreDerivedSourcesmake"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/DerivedSources.make (160923 => 160924)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/DerivedSources.make        2013-12-20 22:01:27 UTC (rev 160923)
+++ trunk/Source/WebCore/DerivedSources.make        2013-12-20 22:04:28 UTC (rev 160924)
</span><span class="lines">@@ -1119,6 +1119,13 @@
</span><span class="cx">         perl &quot;$(WebCore)/inspector/xxd.pl&quot; InjectedScriptSource_js ./InjectedScriptSource.min.js InjectedScriptSource.h
</span><span class="cx">         rm -f ./InjectedScriptSource.min.js
</span><span class="cx"> 
</span><ins>+all : CommandLineAPIModuleSource.h
+
+CommandLineAPIModuleSource.h : CommandLineAPIModuleSource.js
+        python &quot;$(WebCore)/inspector/Scripts/jsmin.py&quot; &lt;&quot;$(WebCore)/inspector/CommandLineAPIModuleSource.js&quot; &gt; ./CommandLineAPIModuleSource.min.js
+        perl &quot;$(WebCore)/inspector/xxd.pl&quot; CommandLineAPIModuleSource_js ./CommandLineAPIModuleSource.min.js CommandLineAPIModuleSource.h
+        rm -f ./CommandLineAPIModuleSource.min.js
+
</ins><span class="cx"> all : InjectedScriptCanvasModuleSource.h
</span><span class="cx"> 
</span><span class="cx"> InjectedScriptCanvasModuleSource.h : InjectedScriptCanvasModuleSource.js
</span></span></pre></div>
<a id="trunkSourceWebCoreGNUmakefileam"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/GNUmakefile.am (160923 => 160924)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/GNUmakefile.am        2013-12-20 22:01:27 UTC (rev 160923)
+++ trunk/Source/WebCore/GNUmakefile.am        2013-12-20 22:04:28 UTC (rev 160924)
</span><span class="lines">@@ -371,14 +371,18 @@
</span><span class="cx">         $(AM_V_GEN)$(PYTHON) $(WebCore)/inspector/Scripts/inline-and-minify-stylesheets-and-scripts.py $(WebCore)/inspector/InspectorOverlayPage.html $(GENSOURCES_WEBCORE)/InspectorOverlayPage.combined.html
</span><span class="cx">         $(AM_V_GEN)$(PERL) $(WebCore)/inspector/xxd.pl InspectorOverlayPage_html $(GENSOURCES_WEBCORE)/InspectorOverlayPage.combined.html $(GENSOURCES_WEBCORE)/InspectorOverlayPage.h
</span><span class="cx"> 
</span><ins>+DerivedSources/WebCore/InjectedScriptSource.h: $(WebCore)/inspector/InjectedScriptSource.js
+        $(AM_V_GEN)$(PYTHON) $(WebCore)/inspector/Scripts/jsmin.py &lt;$(WebCore)/inspector/InjectedScriptSource.js &gt; $(GENSOURCES_WEBCORE)/InjectedScriptSource.min.js
+        $(AM_V_GEN)$(PERL) $(WebCore)/inspector/xxd.pl InjectedScriptSource_js $(GENSOURCES_WEBCORE)/InjectedScriptSource.min.js $(GENSOURCES_WEBCORE)/InjectedScriptSource.h
+
+DerivedSources/WebCore/CommandLineAPIModuleSource.h: $(WebCore)/inspector/CommandLineAPIModuleSource.js
+        $(AM_V_GEN)$(PYTHON) $(WebCore)/inspector/Scripts/jsmin.py &lt;$(WebCore)/inspector/CommandLineAPIModuleSource.js &gt; $(GENSOURCES_WEBCORE)/CommandLineAPIModuleSource.min.js
+        $(AM_V_GEN)$(PERL) $(WebCore)/inspector/xxd.pl CommandLineAPIModuleSource_js $(GENSOURCES_WEBCORE)/CommandLineAPIModuleSource.min.js $(GENSOURCES_WEBCORE)/CommandLineAPIModuleSource.h
+
</ins><span class="cx"> DerivedSources/WebCore/InjectedScriptCanvasModuleSource.h: $(WebCore)/inspector/InjectedScriptCanvasModuleSource.js
</span><span class="cx">         $(AM_V_GEN)$(PYTHON) $(WebCore)/inspector/Scripts/jsmin.py &lt;$(WebCore)/inspector/InjectedScriptCanvasModuleSource.js &gt; $(GENSOURCES_WEBCORE)/InjectedScriptCanvasModuleSource.min.js
</span><span class="cx">         $(AM_V_GEN)$(PERL) $(WebCore)/inspector/xxd.pl InjectedScriptCanvasModuleSource_js $(GENSOURCES_WEBCORE)/InjectedScriptCanvasModuleSource.min.js $(GENSOURCES_WEBCORE)/InjectedScriptCanvasModuleSource.h
</span><span class="cx"> 
</span><del>-DerivedSources/WebCore/InjectedScriptSource.h: $(WebCore)/inspector/InjectedScriptSource.js
-        $(AM_V_GEN)$(PYTHON) $(WebCore)/inspector/Scripts/jsmin.py &lt;$(WebCore)/inspector/InjectedScriptSource.js &gt; $(GENSOURCES_WEBCORE)/InjectedScriptSource.min.js
-        $(AM_V_GEN)$(PERL) $(WebCore)/inspector/xxd.pl InjectedScriptSource_js $(GENSOURCES_WEBCORE)/InjectedScriptSource.min.js $(GENSOURCES_WEBCORE)/InjectedScriptSource.h
-
</del><span class="cx"> if ENABLE_WEB_AUDIO
</span><span class="cx"> # Installing HRTF database wav files
</span><span class="cx"> audiodir = ${datadir}/webkitgtk-@WEBKITGTK_API_VERSION@/resources/audio/
</span></span></pre></div>
<a id="trunkSourceWebCoreGNUmakefilelistam"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/GNUmakefile.list.am (160923 => 160924)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/GNUmakefile.list.am        2013-12-20 22:01:27 UTC (rev 160923)
+++ trunk/Source/WebCore/GNUmakefile.list.am        2013-12-20 22:04:28 UTC (rev 160924)
</span><span class="lines">@@ -5,6 +5,7 @@
</span><span class="cx">         DerivedSources/WebCore/CSSPropertyNames.cpp \
</span><span class="cx">         DerivedSources/WebCore/CSSValueKeywords.h \
</span><span class="cx">         DerivedSources/WebCore/CSSValueKeywords.cpp \
</span><ins>+        DerivedSources/WebCore/CommandLineAPIModuleSource.h \
</ins><span class="cx">         DerivedSources/WebCore/EventFactory.cpp \
</span><span class="cx">         DerivedSources/WebCore/EventHeaders.h \
</span><span class="cx">         DerivedSources/WebCore/EventInterfaces.h \
</span><span class="lines">@@ -3766,6 +3767,8 @@
</span><span class="cx">         Source/WebCore/icu/unicode/utypes.h \
</span><span class="cx">         Source/WebCore/icu/unicode/uversion.h \
</span><span class="cx">         Source/WebCore/inspector/BindingVisitors.h \
</span><ins>+    Source/WebCore/inspector/CommandLineAPIModule.cpp \
+    Source/WebCore/inspector/CommandLineAPIModule.h \
</ins><span class="cx">         Source/WebCore/inspector/ConsoleAPITypes.h \
</span><span class="cx">         Source/WebCore/inspector/ConsoleMessage.cpp \
</span><span class="cx">         Source/WebCore/inspector/ConsoleMessage.h \
</span></span></pre></div>
<a id="trunkSourceWebCoreWebCorevcxprojWebCorevcxproj"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/WebCore.vcxproj/WebCore.vcxproj (160923 => 160924)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/WebCore.vcxproj/WebCore.vcxproj        2013-12-20 22:01:27 UTC (rev 160923)
+++ trunk/Source/WebCore/WebCore.vcxproj/WebCore.vcxproj        2013-12-20 22:04:28 UTC (rev 160924)
</span><span class="lines">@@ -17558,6 +17558,14 @@
</span><span class="cx">     &lt;ClCompile Include=&quot;..\bridge\runtime_method.cpp&quot; /&gt;
</span><span class="cx">     &lt;ClCompile Include=&quot;..\bridge\runtime_object.cpp&quot; /&gt;
</span><span class="cx">     &lt;ClCompile Include=&quot;..\bridge\runtime_root.cpp&quot; /&gt;
</span><ins>+    &lt;ClCompile Include=&quot;..\inspector\CommandLineAPIModule.cpp&quot;&gt;
+      &lt;ExcludedFromBuild Condition=&quot;'$(Configuration)|$(Platform)'=='Release|Win32'&quot;&gt;true&lt;/ExcludedFromBuild&gt;
+      &lt;ExcludedFromBuild Condition=&quot;'$(Configuration)|$(Platform)'=='Release|x64'&quot;&gt;true&lt;/ExcludedFromBuild&gt;
+      &lt;ExcludedFromBuild Condition=&quot;'$(Configuration)|$(Platform)'=='Release_WinCairo|Win32'&quot;&gt;true&lt;/ExcludedFromBuild&gt;
+      &lt;ExcludedFromBuild Condition=&quot;'$(Configuration)|$(Platform)'=='Release_WinCairo|x64'&quot;&gt;true&lt;/ExcludedFromBuild&gt;
+      &lt;ExcludedFromBuild Condition=&quot;'$(Configuration)|$(Platform)'=='Production|Win32'&quot;&gt;true&lt;/ExcludedFromBuild&gt;
+      &lt;ExcludedFromBuild Condition=&quot;'$(Configuration)|$(Platform)'=='Production|x64'&quot;&gt;true&lt;/ExcludedFromBuild&gt;
+    &lt;/ClCompile&gt;
</ins><span class="cx">     &lt;ClCompile Include=&quot;..\inspector\ConsoleMessage.cpp&quot;&gt;
</span><span class="cx">       &lt;ExcludedFromBuild Condition=&quot;'$(Configuration)|$(Platform)'=='Release|Win32'&quot;&gt;true&lt;/ExcludedFromBuild&gt;
</span><span class="cx">       &lt;ExcludedFromBuild Condition=&quot;'$(Configuration)|$(Platform)'=='Release|x64'&quot;&gt;true&lt;/ExcludedFromBuild&gt;
</span><span class="lines">@@ -18087,6 +18095,7 @@
</span><span class="cx">   &lt;/ItemGroup&gt;
</span><span class="cx">   &lt;ItemGroup&gt;
</span><span class="cx">     &lt;ClInclude Include=&quot;$(ConfigurationBuildDir)\obj$(PlatformArchitecture)\$(ProjectName)\DerivedSources\CSSGrammar.h&quot; /&gt;
</span><ins>+    &lt;ClInclude Include=&quot;$(ConfigurationBuildDir)\obj$(PlatformArchitecture)\$(ProjectName)\DerivedSources\CommandLineAPIModuleSource.h&quot; /&gt;
</ins><span class="cx">     &lt;ClInclude Include=&quot;$(ConfigurationBuildDir)\obj$(PlatformArchitecture)\$(ProjectName)\DerivedSources\EventHeaders.h&quot; /&gt;
</span><span class="cx">     &lt;ClInclude Include=&quot;$(ConfigurationBuildDir)\obj$(PlatformArchitecture)\$(ProjectName)\DerivedSources\EventInterfaces.h&quot; /&gt;
</span><span class="cx">     &lt;ClInclude Include=&quot;$(ConfigurationBuildDir)\obj$(PlatformArchitecture)\$(ProjectName)\DerivedSources\EventTargetHeaders.h&quot; /&gt;
</span><span class="lines">@@ -20941,6 +20950,7 @@
</span><span class="cx">     &lt;ClInclude Include=&quot;..\bridge\runtime_root.h&quot; /&gt;
</span><span class="cx">     &lt;ClInclude Include=&quot;..\inspector\BindingVisitors.h&quot; /&gt;
</span><span class="cx">     &lt;ClInclude Include=&quot;..\inspector\ConsoleAPITypes.h&quot; /&gt;
</span><ins>+    &lt;ClInclude Include=&quot;..\inspector\CommandLineAPIModule.h&quot; /&gt;
</ins><span class="cx">     &lt;ClInclude Include=&quot;..\inspector\ConsoleMessage.h&quot; /&gt;
</span><span class="cx">     &lt;ClInclude Include=&quot;..\inspector\ContentSearchUtils.h&quot; /&gt;
</span><span class="cx">     &lt;ClInclude Include=&quot;..\inspector\DOMEditor.h&quot; /&gt;
</span></span></pre></div>
<a id="trunkSourceWebCoreWebCorevcxprojWebCorevcxprojfilters"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/WebCore.vcxproj/WebCore.vcxproj.filters (160923 => 160924)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/WebCore.vcxproj/WebCore.vcxproj.filters        2013-12-20 22:01:27 UTC (rev 160923)
+++ trunk/Source/WebCore/WebCore.vcxproj/WebCore.vcxproj.filters        2013-12-20 22:04:28 UTC (rev 160924)
</span><span class="lines">@@ -4791,6 +4791,9 @@
</span><span class="cx">     &lt;ClCompile Include=&quot;..\bridge\runtime_root.cpp&quot;&gt;
</span><span class="cx">       &lt;Filter&gt;bridge&lt;/Filter&gt;
</span><span class="cx">     &lt;/ClCompile&gt;
</span><ins>+    &lt;ClCompile Include=&quot;..\inspector\CommandLineAPIModule.cpp&quot;&gt;
+      &lt;Filter&gt;inspector&lt;/Filter&gt;
+    &lt;/ClCompile&gt;
</ins><span class="cx">     &lt;ClCompile Include=&quot;..\inspector\ConsoleMessage.cpp&quot;&gt;
</span><span class="cx">       &lt;Filter&gt;inspector&lt;/Filter&gt;
</span><span class="cx">     &lt;/ClCompile&gt;
</span><span class="lines">@@ -12368,6 +12371,9 @@
</span><span class="cx">     &lt;ClInclude Include=&quot;..\inspector\BindingVisitors.h&quot;&gt;
</span><span class="cx">       &lt;Filter&gt;inspector&lt;/Filter&gt;
</span><span class="cx">     &lt;/ClInclude&gt;
</span><ins>+    &lt;ClInclude Include=&quot;..\inspector\CommandLineAPIModule.h&quot;&gt;
+      &lt;Filter&gt;inspector&lt;/Filter&gt;
+    &lt;/ClInclude&gt;
</ins><span class="cx">     &lt;ClInclude Include=&quot;..\inspector\ConsoleAPITypes.h&quot;&gt;
</span><span class="cx">       &lt;Filter&gt;inspector&lt;/Filter&gt;
</span><span class="cx">     &lt;/ClInclude&gt;
</span><span class="lines">@@ -13039,6 +13045,9 @@
</span><span class="cx">     &lt;ClInclude Include=&quot;$(ConfigurationBuildDir)\obj$(PlatformArchitecture)\$(ProjectName)\DerivedSources\CSSGrammar.h&quot;&gt;
</span><span class="cx">       &lt;Filter&gt;DerivedSources&lt;/Filter&gt;
</span><span class="cx">     &lt;/ClInclude&gt;
</span><ins>+    &lt;ClInclude Include=&quot;$(ConfigurationBuildDir)\obj$(PlatformArchitecture)\$(ProjectName)\DerivedSources\CommandLineAPIModuleSource.h&quot;&gt;
+      &lt;Filter&gt;DerivedSources&lt;/Filter&gt;
+    &lt;/ClInclude&gt;
</ins><span class="cx">     &lt;ClInclude Include=&quot;$(ConfigurationBuildDir)\obj$(PlatformArchitecture)\$(ProjectName)\DerivedSources\EventHeaders.h&quot;&gt;
</span><span class="cx">       &lt;Filter&gt;DerivedSources&lt;/Filter&gt;
</span><span class="cx">     &lt;/ClInclude&gt;
</span></span></pre></div>
<a id="trunkSourceWebCoreWebCorexcodeprojprojectpbxproj"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj (160923 => 160924)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj        2013-12-20 22:01:27 UTC (rev 160923)
+++ trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj        2013-12-20 22:04:28 UTC (rev 160924)
</span><span class="lines">@@ -3529,6 +3529,9 @@
</span><span class="cx">                 A54A82F115228DF600C72BA6 /* DOMNodePrivate.h in Copy Generated Headers */ = {isa = PBXBuildFile; fileRef = A54A82EA15228CA300C72BA6 /* DOMNodePrivate.h */; };
</span><span class="cx">                 A5732B0A136A161D005C8D7C /* DateComponents.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A5732B08136A161D005C8D7C /* DateComponents.cpp */; };
</span><span class="cx">                 A5732B0B136A161D005C8D7C /* DateComponents.h in Headers */ = {isa = PBXBuildFile; fileRef = A5732B09136A161D005C8D7C /* DateComponents.h */; };
</span><ins>+                A584FE2618637DAB00843B10 /* CommandLineAPIModuleSource.h in Headers */ = {isa = PBXBuildFile; fileRef = A584FE2518637DAB00843B10 /* CommandLineAPIModuleSource.h */; };
+                A584FE2B1863870F00843B10 /* CommandLineAPIModule.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A584FE291863870F00843B10 /* CommandLineAPIModule.cpp */; };
+                A584FE2C1863870F00843B10 /* CommandLineAPIModule.h in Headers */ = {isa = PBXBuildFile; fileRef = A584FE2A1863870F00843B10 /* CommandLineAPIModule.h */; };
</ins><span class="cx">                 A593CF8B1840535200BFCE27 /* InspectorWebAgentBase.h in Headers */ = {isa = PBXBuildFile; fileRef = A593CF8A1840535200BFCE27 /* InspectorWebAgentBase.h */; settings = {ATTRIBUTES = (Private, ); }; };
</span><span class="cx">                 A5A2AF0B1829734300DE1729 /* PageDebuggable.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A5A2AF091829734300DE1729 /* PageDebuggable.cpp */; };
</span><span class="cx">                 A5A2AF0C1829734300DE1729 /* PageDebuggable.h in Headers */ = {isa = PBXBuildFile; fileRef = A5A2AF0A1829734300DE1729 /* PageDebuggable.h */; };
</span><span class="lines">@@ -10364,6 +10367,10 @@
</span><span class="cx">                 A54A82EA15228CA300C72BA6 /* DOMNodePrivate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DOMNodePrivate.h; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="cx">                 A5732B08136A161D005C8D7C /* DateComponents.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = DateComponents.cpp; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="cx">                 A5732B09136A161D005C8D7C /* DateComponents.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DateComponents.h; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><ins>+                A584FE2518637DAB00843B10 /* CommandLineAPIModuleSource.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CommandLineAPIModuleSource.h; sourceTree = &quot;&lt;group&gt;&quot;; };
+                A584FE2718637DCA00843B10 /* CommandLineAPIModuleSource.js */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.javascript; path = CommandLineAPIModuleSource.js; sourceTree = &quot;&lt;group&gt;&quot;; };
+                A584FE291863870F00843B10 /* CommandLineAPIModule.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CommandLineAPIModule.cpp; sourceTree = &quot;&lt;group&gt;&quot;; };
+                A584FE2A1863870F00843B10 /* CommandLineAPIModule.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CommandLineAPIModule.h; sourceTree = &quot;&lt;group&gt;&quot;; };
</ins><span class="cx">                 A593CF7218402CE900BFCE27 /* protocol */ = {isa = PBXFileReference; lastKnownFileType = folder; path = protocol; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="cx">                 A593CF7518402D4B00BFCE27 /* combine-javascript-resources.pl */ = {isa = PBXFileReference; lastKnownFileType = text.script.perl; path = &quot;combine-javascript-resources.pl&quot;; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="cx">                 A593CF8A1840535200BFCE27 /* InspectorWebAgentBase.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = InspectorWebAgentBase.h; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="lines">@@ -14467,6 +14474,7 @@
</span><span class="cx">                 1C5FAECA0DCFD8C900D58F78 /* Inspector */ = {
</span><span class="cx">                         isa = PBXGroup;
</span><span class="cx">                         children = (
</span><ins>+                                A584FE2518637DAB00843B10 /* CommandLineAPIModuleSource.h */,
</ins><span class="cx">                                 AA912750157E35A500454E54 /* InjectedScriptCanvasModuleSource.h */,
</span><span class="cx">                                 7A563E5412DE32B000F4536D /* InjectedScriptSource.h */,
</span><span class="cx">                                 4F707A9711EF679400ACDA69 /* InspectorWebBackendDispatchers.cpp */,
</span><span class="lines">@@ -14496,6 +14504,9 @@
</span><span class="cx">                                 A518225317E28CF100A9BA1D /* Scripts */,
</span><span class="cx">                                 A593CF7518402D4B00BFCE27 /* combine-javascript-resources.pl */,
</span><span class="cx">                                 F35AE5AB14925F5B004D5776 /* BindingVisitors.h */,
</span><ins>+                                A584FE291863870F00843B10 /* CommandLineAPIModule.cpp */,
+                                A584FE2A1863870F00843B10 /* CommandLineAPIModule.h */,
+                                A584FE2718637DCA00843B10 /* CommandLineAPIModuleSource.js */,
</ins><span class="cx">                                 2DF2E9D4166E39740035BEF2 /* ConsoleAPITypes.h */,
</span><span class="cx">                                 41F0618D0F5F069800A07EAC /* ConsoleMessage.cpp */,
</span><span class="cx">                                 41F0618C0F5F069800A07EAC /* ConsoleMessage.h */,
</span><span class="lines">@@ -22967,6 +22978,7 @@
</span><span class="cx">                                 3F2B33EB165AF15600E3987C /* DOMWebKitCSSViewportRule.h in Headers */,
</span><span class="cx">                                 3F2B33ED165AF15600E3987C /* DOMWebKitCSSViewportRuleInternal.h in Headers */,
</span><span class="cx">                                 CDF2B0171820540700F2B424 /* MockSourceBufferPrivate.h in Headers */,
</span><ins>+                                A584FE2C1863870F00843B10 /* CommandLineAPIModule.h in Headers */,
</ins><span class="cx">                                 8A195932147EA16E00D1EA61 /* DOMWebKitNamedFlow.h in Headers */,
</span><span class="cx">                                 8A195934147EA16E00D1EA61 /* DOMWebKitNamedFlowInternal.h in Headers */,
</span><span class="cx">                                 31C0FF4C0E4CEFDD007D6FE5 /* DOMWebKitTransitionEvent.h in Headers */,
</span><span class="lines">@@ -23378,6 +23390,7 @@
</span><span class="cx">                                 5913A24213D49EBA00F5B05C /* IdentifiersFactory.h in Headers */,
</span><span class="cx">                                 49E911C50EF86D47009D0CAF /* IdentityTransformOperation.h in Headers */,
</span><span class="cx">                                 E125F856182C0F8300D84CD9 /* CryptoKeySerialization.h in Headers */,
</span><ins>+                                A584FE2618637DAB00843B10 /* CommandLineAPIModuleSource.h in Headers */,
</ins><span class="cx">                                 CD641EC01819B36000EE4C41 /* MediaTimeMac.h in Headers */,
</span><span class="cx">                                 C0C054CD1118C8E400CE2636 /* IDLParser.pm in Headers */,
</span><span class="cx">                                 C3CF17A515B0063F00276D39 /* IdTargetObserver.h in Headers */,
</span><span class="lines">@@ -28107,6 +28120,7 @@
</span><span class="cx">                                 B25599840D00D8BA00BB825C /* SVGFEImage.cpp in Sources */,
</span><span class="cx">                                 B22279EE0D00BF220071B782 /* SVGFEImageElement.cpp in Sources */,
</span><span class="cx">                                 51D719EB181106E00016DC51 /* IDBRequest.cpp in Sources */,
</span><ins>+                                A584FE2B1863870F00843B10 /* CommandLineAPIModule.cpp in Sources */,
</ins><span class="cx">                                 B22279F10D00BF220071B782 /* SVGFELightElement.cpp in Sources */,
</span><span class="cx">                                 B22279F30D00BF220071B782 /* SVGFEMergeElement.cpp in Sources */,
</span><span class="cx">                                 B22279F60D00BF220071B782 /* SVGFEMergeNodeElement.cpp in Sources */,
</span></span></pre></div>
<a id="trunkSourceWebCoreinspectorCommandLineAPIModulecpp"></a>
<div class="addfile"><h4>Added: trunk/Source/WebCore/inspector/CommandLineAPIModule.cpp (0 => 160924)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/inspector/CommandLineAPIModule.cpp                                (rev 0)
+++ trunk/Source/WebCore/inspector/CommandLineAPIModule.cpp        2013-12-20 22:04:28 UTC (rev 160924)
</span><span class="lines">@@ -0,0 +1,53 @@
</span><ins>+/*
+ * Copyright (C) 2013 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include &quot;config.h&quot;
+#include &quot;CommandLineAPIModule.h&quot;
+
+#if ENABLE(INSPECTOR)
+
+#include &quot;CommandLineAPIModuleSource.h&quot;
+
+namespace WebCore {
+
+CommandLineAPIModule::CommandLineAPIModule()
+    : InjectedScriptModule(ASCIILiteral(&quot;CommandLineAPI&quot;))
+{
+}
+
+void CommandLineAPIModule::injectIfNeeded(InjectedScriptManager* injectedScriptManager, InjectedScript injectedScript)
+{
+    CommandLineAPIModule module;
+    module.ensureInjected(injectedScriptManager, injectedScript);
+}
+
+String CommandLineAPIModule::source() const
+{
+    return String(reinterpret_cast&lt;const char*&gt;(CommandLineAPIModuleSource_js), sizeof(CommandLineAPIModuleSource_js));
+}
+
+} // namespace WebCore
+
+#endif // ENABLE(INSPECTOR)
</ins></span></pre></div>
<a id="trunkSourceWebCoreinspectorCommandLineAPIModuleh"></a>
<div class="addfile"><h4>Added: trunk/Source/WebCore/inspector/CommandLineAPIModule.h (0 => 160924)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/inspector/CommandLineAPIModule.h                                (rev 0)
+++ trunk/Source/WebCore/inspector/CommandLineAPIModule.h        2013-12-20 22:04:28 UTC (rev 160924)
</span><span class="lines">@@ -0,0 +1,49 @@
</span><ins>+/*
+ * Copyright (C) 2013 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef CommandLineAPIModule_h
+#define CommandLineAPIModule_h
+
+#include &quot;InjectedScriptModule.h&quot;
+
+#if ENABLE(INSPECTOR)
+
+namespace WebCore {
+
+class CommandLineAPIModule FINAL : public InjectedScriptModule {
+public:
+    CommandLineAPIModule();
+
+    virtual String source() const OVERRIDE;
+    virtual bool returnsObject() const OVERRIDE { return false; }
+
+    static void injectIfNeeded(InjectedScriptManager*, InjectedScript);
+};
+
+} // namespace WebCore
+
+#endif // ENABLE(INSPECTOR)
+
+#endif // !defined(CommandLineAPIModule_h)
</ins></span></pre></div>
<a id="trunkSourceWebCoreinspectorCommandLineAPIModuleSourcejs"></a>
<div class="addfile"><h4>Added: trunk/Source/WebCore/inspector/CommandLineAPIModuleSource.js (0 => 160924)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/inspector/CommandLineAPIModuleSource.js                                (rev 0)
+++ trunk/Source/WebCore/inspector/CommandLineAPIModuleSource.js        2013-12-20 22:04:28 UTC (rev 160924)
</span><span class="lines">@@ -0,0 +1,349 @@
</span><ins>+/*
+ * Copyright (C) 2007 Apple Inc.  All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1.  Redistributions of source code must retain the above copyright
+ *     notice, this list of conditions and the following disclaimer.
+ * 2.  Redistributions in binary form must reproduce the above copyright
+ *     notice, this list of conditions and the following disclaimer in the
+ *     documentation and/or other materials provided with the distribution.
+ * 3.  Neither the name of Apple Computer, Inc. (&quot;Apple&quot;) nor the names of
+ *     its contributors may be used to endorse or promote products derived
+ *     from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS &quot;AS IS&quot; AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/**
+ * @param {InjectedScriptHost} InjectedScriptHost
+ * @param {Window} inspectedWindow
+ * @param {number} injectedScriptId
+ */
+(function (InjectedScriptHost, inspectedWindow, injectedScriptId, injectedScript) {
+
+/**
+ * @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;
+}
+
+/**
+ * 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)
+{
+    var args = slice(arguments, 2);
+
+    /**
+     * @param {...number} var_args
+     */
+    function bound(var_args)
+    {
+        return func.apply(thisObject, args.concat(slice(arguments)));
+    }
+    bound.toString = function() {
+        return &quot;bound: &quot; + func;
+    };
+    return bound;
+}
+
+/**
+ * @constructor
+ * @param {CommandLineAPIImpl} commandLineAPIImpl
+ * @param {Object} callFrame
+ */
+function CommandLineAPI(commandLineAPIImpl, callFrame)
+{
+    /**
+     * @param {string} member
+     * @return {boolean}
+     */
+    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;
+    }
+
+    /**
+     * @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);
+    }
+
+    for (var i = 0; i &lt; 5; ++i) {
+        var member = &quot;$&quot; + i;
+        if (member in inspectedWindow || inScopeVariables(member))
+            continue;
+
+        this.__defineGetter__(&quot;$&quot; + i, bind(commandLineAPIImpl._inspectedObject, commandLineAPIImpl, i));
+    }
+
+    this.$_ = injectedScript._lastResult;
+}
+
+/**
+ * @type {Array.&lt;string&gt;}
+ * @const
+ */
+CommandLineAPI.members_ = [
+    &quot;$&quot;, &quot;$$&quot;, &quot;$x&quot;, &quot;dir&quot;, &quot;dirxml&quot;, &quot;keys&quot;, &quot;values&quot;, &quot;profile&quot;, &quot;profileEnd&quot;,
+    &quot;monitorEvents&quot;, &quot;unmonitorEvents&quot;, &quot;inspect&quot;, &quot;copy&quot;, &quot;clear&quot;, &quot;getEventListeners&quot;
+];
+
+/**
+ * @constructor
+ */
+function CommandLineAPIImpl()
+{
+}
+
+CommandLineAPIImpl.prototype = {
+    /**
+     * @param {string} selector
+     * @param {Node=} start
+     */
+    $: function (selector, start)
+    {
+        if (this._canQuerySelectorOnNode(start))
+            return start.querySelector(selector);
+
+        var result = inspectedWindow.document.querySelector(selector);
+        if (result)
+            return result;
+        if (selector &amp;&amp; selector[0] !== &quot;#&quot;) {
+            result = inspectedWindow.document.getElementById(selector);
+            if (result) {
+                inspectedWindow.console.warn(&quot;The console function $() has changed from $=getElementById(id) to $=querySelector(selector). You might try $(\&quot;#%s\&quot;)&quot;, selector );
+                return null;
+            }
+        }
+        return result;
+    },
+
+    /**
+     * @param {string} selector
+     * @param {Node=} start
+     */
+    $$: function (selector, start)
+    {
+        if (this._canQuerySelectorOnNode(start))
+            return start.querySelectorAll(selector);
+        return inspectedWindow.document.querySelectorAll(selector);
+    },
+
+    /**
+     * @param {Node=} node
+     * @return {boolean}
+     */
+    _canQuerySelectorOnNode: function(node)
+    {
+        return !!node &amp;&amp; InjectedScriptHost.type(node) === &quot;node&quot; &amp;&amp; (node.nodeType === Node.ELEMENT_NODE || node.nodeType === Node.DOCUMENT_NODE || node.nodeType === Node.DOCUMENT_FRAGMENT_NODE);
+    },
+
+    /**
+     * @param {string} xpath
+     * @param {Node=} context
+     */
+    $x: function(xpath, context)
+    {
+        var doc = (context &amp;&amp; context.ownerDocument) || inspectedWindow.document;
+        var result = doc.evaluate(xpath, context || doc, null, XPathResult.ANY_TYPE, null);
+        switch (result.resultType) {
+        case XPathResult.NUMBER_TYPE:
+            return result.numberValue;
+        case XPathResult.STRING_TYPE:
+            return result.stringValue;
+        case XPathResult.BOOLEAN_TYPE:
+            return result.booleanValue;
+        default:
+            var nodes = [];
+            var node;
+            while (node = result.iterateNext())
+                nodes.push(node);
+            return nodes;
+        }
+    },
+
+    dir: function()
+    {
+        return inspectedWindow.console.dir.apply(inspectedWindow.console, arguments)
+    },
+
+    dirxml: function()
+    {
+        return inspectedWindow.console.dirxml.apply(inspectedWindow.console, arguments)
+    },
+
+    keys: function(object)
+    {
+        return Object.keys(object);
+    },
+
+    values: function(object)
+    {
+        var result = [];
+        for (var key in object)
+            result.push(object[key]);
+        return result;
+    },
+
+    profile: function()
+    {
+        return inspectedWindow.console.profile.apply(inspectedWindow.console, arguments)
+    },
+
+    profileEnd: function()
+    {
+        return inspectedWindow.console.profileEnd.apply(inspectedWindow.console, arguments)
+    },
+
+    /**
+     * @param {Object} object
+     * @param {Array.&lt;string&gt;|string=} types
+     */
+    monitorEvents: function(object, types)
+    {
+        if (!object || !object.addEventListener || !object.removeEventListener)
+            return;
+        types = this._normalizeEventTypes(types);
+        for (var i = 0; i &lt; types.length; ++i) {
+            object.removeEventListener(types[i], this._logEvent, false);
+            object.addEventListener(types[i], this._logEvent, false);
+        }
+    },
+
+    /**
+     * @param {Object} object
+     * @param {Array.&lt;string&gt;|string=} types
+     */
+    unmonitorEvents: function(object, types)
+    {
+        if (!object || !object.addEventListener || !object.removeEventListener)
+            return;
+        types = this._normalizeEventTypes(types);
+        for (var i = 0; i &lt; types.length; ++i)
+            object.removeEventListener(types[i], this._logEvent, false);
+    },
+
+    /**
+     * @param {*} object
+     * @return {*}
+     */
+    inspect: function(object)
+    {
+        return injectedScript._inspect(object);
+    },
+
+    copy: function(object)
+    {
+        if (injectedScript._subtype(object) === &quot;node&quot;)
+            object = object.outerHTML;
+        InjectedScriptHost.copyText(object);
+    },
+
+    clear: function()
+    {
+        InjectedScriptHost.clearConsoleMessages();
+    },
+
+    /**
+     * @param {Node} node
+     */
+    getEventListeners: function(node)
+    {
+        return InjectedScriptHost.getEventListeners(node);
+    },
+
+    /**
+     * @param {number} num
+     */
+    _inspectedObject: function(num)
+    {
+        return InjectedScriptHost.inspectedObject(num);
+    },
+
+    /**
+     * @param {Array.&lt;string&gt;|string=} types
+     * @return {Array.&lt;string&gt;}
+     */
+    _normalizeEventTypes: function(types)
+    {
+        if (typeof types === &quot;undefined&quot;)
+            types = [ &quot;mouse&quot;, &quot;key&quot;, &quot;touch&quot;, &quot;control&quot;, &quot;load&quot;, &quot;unload&quot;, &quot;abort&quot;, &quot;error&quot;, &quot;select&quot;, &quot;change&quot;, &quot;submit&quot;, &quot;reset&quot;, &quot;focus&quot;, &quot;blur&quot;, &quot;resize&quot;, &quot;scroll&quot;, &quot;search&quot;, &quot;devicemotion&quot;, &quot;deviceorientation&quot; ];
+        else if (typeof types === &quot;string&quot;)
+            types = [ types ];
+
+        var result = [];
+        for (var i = 0; i &lt; types.length; i++) {
+            if (types[i] === &quot;mouse&quot;)
+                result.splice(0, 0, &quot;mousedown&quot;, &quot;mouseup&quot;, &quot;click&quot;, &quot;dblclick&quot;, &quot;mousemove&quot;, &quot;mouseover&quot;, &quot;mouseout&quot;, &quot;mousewheel&quot;);
+            else if (types[i] === &quot;key&quot;)
+                result.splice(0, 0, &quot;keydown&quot;, &quot;keyup&quot;, &quot;keypress&quot;, &quot;textInput&quot;);
+            else if (types[i] === &quot;touch&quot;)
+                result.splice(0, 0, &quot;touchstart&quot;, &quot;touchmove&quot;, &quot;touchend&quot;, &quot;touchcancel&quot;);
+            else if (types[i] === &quot;control&quot;)
+                result.splice(0, 0, &quot;resize&quot;, &quot;scroll&quot;, &quot;zoom&quot;, &quot;focus&quot;, &quot;blur&quot;, &quot;select&quot;, &quot;change&quot;, &quot;submit&quot;, &quot;reset&quot;);
+            else
+                result.push(types[i]);
+        }
+        return result;
+    },
+
+    /**
+     * @param {Event} event
+     */
+    _logEvent: function(event)
+    {
+        inspectedWindow.console.log(event.type, event);
+    }
+}
+
+injectedScript.CommandLineAPI = CommandLineAPI;
+injectedScript._commandLineAPIImpl = new CommandLineAPIImpl();
+
+// This Module doesn't expose an object, it just adds an extension that InjectedScript uses.
+// However, we return an empty object, so that InjectedScript knows this module has been loaded.
+return {};
+
+})
</ins></span></pre></div>
<a id="trunkSourceWebCoreinspectorInjectedScriptCanvasModuleh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/inspector/InjectedScriptCanvasModule.h (160923 => 160924)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/inspector/InjectedScriptCanvasModule.h        2013-12-20 22:01:27 UTC (rev 160923)
+++ trunk/Source/WebCore/inspector/InjectedScriptCanvasModule.h        2013-12-20 22:04:28 UTC (rev 160924)
</span><span class="lines">@@ -50,6 +50,7 @@
</span><span class="cx">     InjectedScriptCanvasModule();
</span><span class="cx">     
</span><span class="cx">     virtual String source() const;
</span><ins>+    virtual bool returnsObject() const { return true; }
</ins><span class="cx"> 
</span><span class="cx">     static InjectedScriptCanvasModule moduleForState(InjectedScriptManager*, JSC::ExecState*);
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebCoreinspectorInjectedScriptModulecpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/inspector/InjectedScriptModule.cpp (160923 => 160924)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/inspector/InjectedScriptModule.cpp        2013-12-20 22:01:27 UTC (rev 160923)
+++ trunk/Source/WebCore/inspector/InjectedScriptModule.cpp        2013-12-20 22:04:28 UTC (rev 160924)
</span><span class="lines">@@ -52,6 +52,11 @@
</span><span class="cx"> void InjectedScriptModule::ensureInjected(InjectedScriptManager* injectedScriptManager, JSC::ExecState* scriptState)
</span><span class="cx"> {
</span><span class="cx">     InjectedScript injectedScript = injectedScriptManager-&gt;injectedScriptFor(scriptState);
</span><ins>+    ensureInjected(injectedScriptManager, injectedScript);
+}
+
+void InjectedScriptModule::ensureInjected(InjectedScriptManager* injectedScriptManager, InjectedScript injectedScript)
+{
</ins><span class="cx">     ASSERT(!injectedScript.hasNoValue());
</span><span class="cx">     if (injectedScript.hasNoValue())
</span><span class="cx">         return;
</span><span class="lines">@@ -67,14 +72,16 @@
</span><span class="cx">         function.appendArgument(name());
</span><span class="cx">         function.appendArgument(source());
</span><span class="cx">         resultValue = injectedScript.callFunctionWithEvalEnabled(function, hadException);
</span><del>-        if (hadException || resultValue.hasNoValue() || !resultValue.isObject()) {
</del><ins>+        if (hadException || (returnsObject() &amp;&amp; (resultValue.hasNoValue() || !resultValue.isObject()))) {
</ins><span class="cx">             ASSERT_NOT_REACHED();
</span><span class="cx">             return;
</span><span class="cx">         }
</span><span class="cx">     }
</span><span class="cx"> 
</span><del>-    Deprecated::ScriptObject moduleObject(scriptState, resultValue);
-    initialize(moduleObject, injectedScriptManager-&gt;inspectedStateAccessCheck());
</del><ins>+    if (returnsObject()) {
+        Deprecated::ScriptObject moduleObject(injectedScript.scriptState(), resultValue);
+        initialize(moduleObject, injectedScriptManager-&gt;inspectedStateAccessCheck());
+    }
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> } // namespace WebCore
</span></span></pre></div>
<a id="trunkSourceWebCoreinspectorInjectedScriptModuleh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/inspector/InjectedScriptModule.h (160923 => 160924)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/inspector/InjectedScriptModule.h        2013-12-20 22:01:27 UTC (rev 160923)
+++ trunk/Source/WebCore/inspector/InjectedScriptModule.h        2013-12-20 22:04:28 UTC (rev 160924)
</span><span class="lines">@@ -31,19 +31,21 @@
</span><span class="cx"> #ifndef InjectedScriptModule_h
</span><span class="cx"> #define InjectedScriptModule_h
</span><span class="cx"> 
</span><ins>+#include &quot;InjectedScript.h&quot;
</ins><span class="cx"> #include &quot;InjectedScriptBase.h&quot;
</span><span class="cx"> #include &quot;ScriptState.h&quot;
</span><span class="cx"> #include &lt;wtf/text/WTFString.h&gt;
</span><span class="cx"> 
</span><ins>+#if ENABLE(INSPECTOR)
+
</ins><span class="cx"> namespace WebCore {
</span><span class="cx"> 
</span><span class="cx"> class InjectedScriptManager;
</span><span class="cx"> 
</span><del>-#if ENABLE(INSPECTOR)
-
</del><span class="cx"> class InjectedScriptModule : public InjectedScriptBase {
</span><span class="cx"> public:
</span><span class="cx">     virtual String source() const = 0;
</span><ins>+    virtual bool returnsObject() const = 0;
</ins><span class="cx"> 
</span><span class="cx"> protected:
</span><span class="cx">     // Do not expose constructor in the child classes as well. Instead provide
</span><span class="lines">@@ -51,10 +53,11 @@
</span><span class="cx">     // and call its ensureInjected() method immediately.
</span><span class="cx">     InjectedScriptModule(const String&amp; name);
</span><span class="cx">     void ensureInjected(InjectedScriptManager*, JSC::ExecState*);
</span><ins>+    void ensureInjected(InjectedScriptManager*, InjectedScript);
</ins><span class="cx"> };
</span><span class="cx"> 
</span><del>-#endif
-
</del><span class="cx"> } // namespace WebCore
</span><span class="cx"> 
</span><ins>+#endif // ENABLE(INSPECTOR)
+
</ins><span class="cx"> #endif
</span></span></pre></div>
<a id="trunkSourceWebCoreinspectorInjectedScriptSourcejs"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/inspector/InjectedScriptSource.js (160923 => 160924)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/inspector/InjectedScriptSource.js        2013-12-20 22:01:27 UTC (rev 160923)
+++ trunk/Source/WebCore/inspector/InjectedScriptSource.js        2013-12-20 22:04:28 UTC (rev 160924)
</span><span class="lines">@@ -30,51 +30,15 @@
</span><span class="cx"> 
</span><span class="cx"> /**
</span><span class="cx">  * @param {InjectedScriptHost} InjectedScriptHost
</span><del>- * @param {Window} inspectedWindow
</del><ins>+ * @param {GlobalObject} inspectedGlobalObject
</ins><span class="cx">  * @param {number} injectedScriptId
</span><span class="cx">  */
</span><del>-(function (InjectedScriptHost, inspectedWindow, injectedScriptId) {
</del><ins>+(function (InjectedScriptHost, inspectedGlobalObject, injectedScriptId) {
</ins><span class="cx"> 
</span><span class="cx"> // Protect against Object overwritten by the user code.
</span><span class="cx"> var Object = {}.constructor;
</span><span class="cx"> 
</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;
-}
-
-/**
- * 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)
-{
-    var args = slice(arguments, 2);
-
-    /**
-     * @param {...number} var_args
-     */
-    function bound(var_args)
-    {
-        return func.apply(thisObject, args.concat(slice(arguments)));
-    }
-    bound.toString = function() {
-        return &quot;bound: &quot; + func;
-    };
-    return bound;
-}
-
-/**
</del><span class="cx">  * @constructor
</span><span class="cx">  */
</span><span class="cx"> var InjectedScript = function()
</span><span class="lines">@@ -111,13 +75,13 @@
</span><span class="cx">     /**
</span><span class="cx">      * @param {*} object
</span><span class="cx">      * @param {string} groupName
</span><del>-     * @param {boolean} canAccessInspectedWindow
</del><ins>+     * @param {boolean} canAccessInspectedGlobalObject
</ins><span class="cx">      * @param {boolean} generatePreview
</span><span class="cx">      * @return {!RuntimeAgent.RemoteObject}
</span><span class="cx">      */
</span><del>-    wrapObject: function(object, groupName, canAccessInspectedWindow, generatePreview)
</del><ins>+    wrapObject: function(object, groupName, canAccessInspectedGlobalObject, generatePreview)
</ins><span class="cx">     {
</span><del>-        if (canAccessInspectedWindow)
</del><ins>+        if (canAccessInspectedGlobalObject)
</ins><span class="cx">             return this._wrapObject(object, groupName, false, generatePreview);
</span><span class="cx">         return this._fallbackWrapper(object);
</span><span class="cx">     },
</span><span class="lines">@@ -138,14 +102,14 @@
</span><span class="cx">     },
</span><span class="cx"> 
</span><span class="cx">     /**
</span><del>-     * @param {boolean} canAccessInspectedWindow
</del><ins>+     * @param {boolean} canAccessInspectedGlobalObject
</ins><span class="cx">      * @param {Object} table
</span><span class="cx">      * @param {Array.&lt;string&gt;|string|boolean} columns
</span><span class="cx">      * @return {!RuntimeAgent.RemoteObject}
</span><span class="cx">      */
</span><del>-    wrapTable: function(canAccessInspectedWindow, table, columns)
</del><ins>+    wrapTable: function(canAccessInspectedGlobalObject, table, columns)
</ins><span class="cx">     {
</span><del>-        if (!canAccessInspectedWindow)
</del><ins>+        if (!canAccessInspectedGlobalObject)
</ins><span class="cx">             return this._fallbackWrapper(table);
</span><span class="cx">         var columnNames = null;
</span><span class="cx">         if (typeof columns === &quot;string&quot;)
</span><span class="lines">@@ -272,7 +236,9 @@
</span><span class="cx">         var argsArray = InjectedScriptHost.evaluate(&quot;(&quot; + args + &quot;)&quot;);
</span><span class="cx">         var result = this[methodName].apply(this, argsArray);
</span><span class="cx">         if (typeof result === &quot;undefined&quot;) {
</span><del>-            inspectedWindow.console.error(&quot;Web Inspector error: InjectedScript.%s returns undefined&quot;, methodName);
</del><ins>+            // FIXME: JS Context inspection currently does not have a global.console object.
+            if (inspectedGlobalObject.console)
+                inspectedGlobalObject.console.error(&quot;Web Inspector error: InjectedScript.%s returns undefined&quot;, methodName);
</ins><span class="cx">             result = null;
</span><span class="cx">         }
</span><span class="cx">         return result;
</span><span class="lines">@@ -554,7 +520,13 @@
</span><span class="cx">      */
</span><span class="cx">     _evaluateOn: function(evalFunction, object, objectGroup, expression, isEvalOnCallFrame, injectCommandLineAPI)
</span><span class="cx">     {
</span><del>-        var commandLineAPI = injectCommandLineAPI ? new CommandLineAPI(this._commandLineAPIImpl, isEvalOnCallFrame ? object : null) : null;
</del><ins>+        var commandLineAPI = null;
+        if (injectCommandLineAPI) {
+            if (this.CommandLineAPI)
+                commandLineAPI = new this.CommandLineAPI(this._commandLineAPIImpl, isEvalOnCallFrame ? object : null);
+            else
+                commandLineAPI = new BasicCommandLineAPI;
+        }
</ins><span class="cx"> 
</span><span class="cx">         if (isEvalOnCallFrame) {
</span><span class="cx">             // We can only use this approach if the evaluate function is the true 'eval'. That allows us to use it with
</span><span class="lines">@@ -562,7 +534,11 @@
</span><span class="cx">             // create that provides the command line APIs.
</span><span class="cx"> 
</span><span class="cx">             var parameters = [InjectedScriptHost.evaluate, expression];
</span><del>-            var expressionFunctionBody = &quot;var __originalEval = window.eval; window.eval = __eval; try { return eval(__currentExpression); } finally { window.eval = __originalEval; }&quot;;
</del><ins>+            var expressionFunctionBody = &quot;&quot; +
+                &quot;var global = Function('return this')() || (1, eval)('this');&quot; +
+                &quot;var __originalEval = global.eval; global.eval = __eval;&quot; +
+                &quot;try { return eval(__currentExpression); }&quot; +
+                &quot;finally { global.eval = __originalEval; }&quot;;
</ins><span class="cx"> 
</span><span class="cx">             if (commandLineAPI) {
</span><span class="cx">                 // To avoid using a 'with' statement (which fails in strict mode and requires injecting the API object)
</span><span class="lines">@@ -596,21 +572,29 @@
</span><span class="cx">         // When not evaluating on a call frame we use a 'with' statement to allow var and function statements to leak
</span><span class="cx">         // into the global scope. This allow them to stick around between evaluations.
</span><span class="cx"> 
</span><ins>+        // FIXME: JS Context inspection currently does not have a global.console object.
</ins><span class="cx">         try {
</span><del>-            if (commandLineAPI &amp;&amp; inspectedWindow.console) {
-                inspectedWindow.console.__commandLineAPI = commandLineAPI;
-                expression = &quot;with ((window &amp;&amp; window.console &amp;&amp; window.console.__commandLineAPI) || {}) { &quot; + expression + &quot;\n}&quot;;
</del><ins>+            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;;
</ins><span class="cx">             }
</span><span class="cx"> 
</span><del>-            var result = evalFunction.call(object, expression);
</del><ins>+            var result = evalFunction.call(inspectedGlobalObject, expression);
</ins><span class="cx"> 
</span><span class="cx">             if (objectGroup === &quot;console&quot;)
</span><span class="cx">                 this._lastResult = result;
</span><span class="cx"> 
</span><span class="cx">             return result;
</span><span class="cx">         } finally {
</span><del>-            if (commandLineAPI &amp;&amp; inspectedWindow.console)
-                delete inspectedWindow.console.__commandLineAPI;
</del><ins>+            if (commandLineAPI) {
+                if (inspectedGlobalObject.console)
+                    delete inspectedGlobalObject.console.__commandLineAPI;
+                else
+                    delete inspectedGlobalObject.__commandLineAPI;
+            }
</ins><span class="cx">         }
</span><span class="cx">     },
</span><span class="cx"> 
</span><span class="lines">@@ -715,10 +699,12 @@
</span><span class="cx">         delete this._modules[name];
</span><span class="cx">         var moduleFunction = InjectedScriptHost.evaluate(&quot;(&quot; + source + &quot;)&quot;);
</span><span class="cx">         if (typeof moduleFunction !== &quot;function&quot;) {
</span><del>-            inspectedWindow.console.error(&quot;Web Inspector error: A function was expected for module %s evaluation&quot;, name);
</del><ins>+            // FIXME: JS Context inspection currently does not have a global.console object.
+            if (inspectedGlobalObject.console)
+                inspectedGlobalObject.console.error(&quot;Web Inspector error: A function was expected for module %s evaluation&quot;, name);
</ins><span class="cx">             return null;
</span><span class="cx">         }
</span><del>-        var module = moduleFunction.call(inspectedWindow, InjectedScriptHost, inspectedWindow, injectedScriptId);
</del><ins>+        var module = moduleFunction.call(inspectedGlobalObject, InjectedScriptHost, inspectedGlobalObject, injectedScriptId, this);
</ins><span class="cx">         this._modules[name] = module;
</span><span class="cx">         return module;
</span><span class="cx">     },
</span><span class="lines">@@ -836,7 +822,7 @@
</span><span class="cx">      */
</span><span class="cx">     _toString: function(obj)
</span><span class="cx">     {
</span><del>-        // We don't use String(obj) because inspectedWindow.String is undefined if owning frame navigated to another page.
</del><ins>+        // We don't use String(obj) because inspectedGlobalObject.String is undefined if owning frame navigated to another page.
</ins><span class="cx">         return &quot;&quot; + obj;
</span><span class="cx">     }
</span><span class="cx"> }
</span><span class="lines">@@ -1077,277 +1063,10 @@
</span><span class="cx">     };
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-/**
- * @constructor
- * @param {CommandLineAPIImpl} commandLineAPIImpl
- * @param {Object} callFrame
- */
-function CommandLineAPI(commandLineAPIImpl, callFrame)
</del><ins>+function BasicCommandLineAPI()
</ins><span class="cx"> {
</span><del>-    /**
-     * @param {string} member
-     * @return {boolean}
-     */
-    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;
-    }
-
-    /**
-     * @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);
-    }
-
-    for (var i = 0; i &lt; 5; ++i) {
-        var member = &quot;$&quot; + i;
-        if (member in inspectedWindow || inScopeVariables(member))
-            continue;
-
-        this.__defineGetter__(&quot;$&quot; + i, bind(commandLineAPIImpl._inspectedObject, commandLineAPIImpl, i));
-    }
-
</del><span class="cx">     this.$_ = injectedScript._lastResult;
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-// NOTE: Please keep the list of API methods below snchronized to that in WebInspector.RuntimeModel!
-/**
- * @type {Array.&lt;string&gt;}
- * @const
- */
-CommandLineAPI.members_ = [
-    &quot;$&quot;, &quot;$$&quot;, &quot;$x&quot;, &quot;dir&quot;, &quot;dirxml&quot;, &quot;keys&quot;, &quot;values&quot;, &quot;profile&quot;, &quot;profileEnd&quot;,
-    &quot;monitorEvents&quot;, &quot;unmonitorEvents&quot;, &quot;inspect&quot;, &quot;copy&quot;, &quot;clear&quot;, &quot;getEventListeners&quot;
-];
-
-/**
- * @constructor
- */
-function CommandLineAPIImpl()
-{
-}
-
-CommandLineAPIImpl.prototype = {
-    /**
-     * @param {string} selector
-     * @param {Node=} start
-     */
-    $: function (selector, start)
-    {
-        if (this._canQuerySelectorOnNode(start))
-            return start.querySelector(selector);
-
-        var result = inspectedWindow.document.querySelector(selector);
-        if (result)
-            return result;
-        if (selector &amp;&amp; selector[0] !== &quot;#&quot;) {
-            result = inspectedWindow.document.getElementById(selector);
-            if (result) {
-                inspectedWindow.console.warn(&quot;The console function $() has changed from $=getElementById(id) to $=querySelector(selector). You might try $(\&quot;#%s\&quot;)&quot;, selector );
-                return null;
-            }
-        }
-        return result;
-    },
-
-    /**
-     * @param {string} selector
-     * @param {Node=} start
-     */
-    $$: function (selector, start)
-    {
-        if (this._canQuerySelectorOnNode(start))
-            return start.querySelectorAll(selector);
-        return inspectedWindow.document.querySelectorAll(selector);
-    },
-
-    /**
-     * @param {Node=} node
-     * @return {boolean}
-     */
-    _canQuerySelectorOnNode: function(node)
-    {
-        return !!node &amp;&amp; InjectedScriptHost.type(node) === &quot;node&quot; &amp;&amp; (node.nodeType === Node.ELEMENT_NODE || node.nodeType === Node.DOCUMENT_NODE || node.nodeType === Node.DOCUMENT_FRAGMENT_NODE);
-    },
-
-    /**
-     * @param {string} xpath
-     * @param {Node=} context
-     */
-    $x: function(xpath, context)
-    {
-        var doc = (context &amp;&amp; context.ownerDocument) || inspectedWindow.document;
-        var result = doc.evaluate(xpath, context || doc, null, XPathResult.ANY_TYPE, null);
-        switch (result.resultType) {
-        case XPathResult.NUMBER_TYPE:
-            return result.numberValue;
-        case XPathResult.STRING_TYPE:
-            return result.stringValue;
-        case XPathResult.BOOLEAN_TYPE:
-            return result.booleanValue;
-        default:
-            var nodes = [];
-            var node;
-            while (node = result.iterateNext())
-                nodes.push(node);
-            return nodes;
-        }
-    },
-
-    dir: function()
-    {
-        return inspectedWindow.console.dir.apply(inspectedWindow.console, arguments)
-    },
-
-    dirxml: function()
-    {
-        return inspectedWindow.console.dirxml.apply(inspectedWindow.console, arguments)
-    },
-
-    keys: function(object)
-    {
-        return Object.keys(object);
-    },
-
-    values: function(object)
-    {
-        var result = [];
-        for (var key in object)
-            result.push(object[key]);
-        return result;
-    },
-
-    profile: function()
-    {
-        return inspectedWindow.console.profile.apply(inspectedWindow.console, arguments)
-    },
-
-    profileEnd: function()
-    {
-        return inspectedWindow.console.profileEnd.apply(inspectedWindow.console, arguments)
-    },
-
-    /**
-     * @param {Object} object
-     * @param {Array.&lt;string&gt;|string=} types
-     */
-    monitorEvents: function(object, types)
-    {
-        if (!object || !object.addEventListener || !object.removeEventListener)
-            return;
-        types = this._normalizeEventTypes(types);
-        for (var i = 0; i &lt; types.length; ++i) {
-            object.removeEventListener(types[i], this._logEvent, false);
-            object.addEventListener(types[i], this._logEvent, false);
-        }
-    },
-
-    /**
-     * @param {Object} object
-     * @param {Array.&lt;string&gt;|string=} types
-     */
-    unmonitorEvents: function(object, types)
-    {
-        if (!object || !object.addEventListener || !object.removeEventListener)
-            return;
-        types = this._normalizeEventTypes(types);
-        for (var i = 0; i &lt; types.length; ++i)
-            object.removeEventListener(types[i], this._logEvent, false);
-    },
-
-    /**
-     * @param {*} object
-     * @return {*}
-     */
-    inspect: function(object)
-    {
-        return injectedScript._inspect(object);
-    },
-
-    copy: function(object)
-    {
-        if (injectedScript._subtype(object) === &quot;node&quot;)
-            object = object.outerHTML;
-        InjectedScriptHost.copyText(object);
-    },
-
-    clear: function()
-    {
-        InjectedScriptHost.clearConsoleMessages();
-    },
-
-    /**
-     * @param {Node} node
-     */
-    getEventListeners: function(node)
-    {
-        return InjectedScriptHost.getEventListeners(node);
-    },
-
-    /**
-     * @param {number} num
-     */
-    _inspectedObject: function(num)
-    {
-        return InjectedScriptHost.inspectedObject(num);
-    },
-
-    /**
-     * @param {Array.&lt;string&gt;|string=} types
-     * @return {Array.&lt;string&gt;}
-     */
-    _normalizeEventTypes: function(types)
-    {
-        if (typeof types === &quot;undefined&quot;)
-            types = [ &quot;mouse&quot;, &quot;key&quot;, &quot;touch&quot;, &quot;control&quot;, &quot;load&quot;, &quot;unload&quot;, &quot;abort&quot;, &quot;error&quot;, &quot;select&quot;, &quot;change&quot;, &quot;submit&quot;, &quot;reset&quot;, &quot;focus&quot;, &quot;blur&quot;, &quot;resize&quot;, &quot;scroll&quot;, &quot;search&quot;, &quot;devicemotion&quot;, &quot;deviceorientation&quot; ];
-        else if (typeof types === &quot;string&quot;)
-            types = [ types ];
-
-        var result = [];
-        for (var i = 0; i &lt; types.length; i++) {
-            if (types[i] === &quot;mouse&quot;)
-                result.splice(0, 0, &quot;mousedown&quot;, &quot;mouseup&quot;, &quot;click&quot;, &quot;dblclick&quot;, &quot;mousemove&quot;, &quot;mouseover&quot;, &quot;mouseout&quot;, &quot;mousewheel&quot;);
-            else if (types[i] === &quot;key&quot;)
-                result.splice(0, 0, &quot;keydown&quot;, &quot;keyup&quot;, &quot;keypress&quot;, &quot;textInput&quot;);
-            else if (types[i] === &quot;touch&quot;)
-                result.splice(0, 0, &quot;touchstart&quot;, &quot;touchmove&quot;, &quot;touchend&quot;, &quot;touchcancel&quot;);
-            else if (types[i] === &quot;control&quot;)
-                result.splice(0, 0, &quot;resize&quot;, &quot;scroll&quot;, &quot;zoom&quot;, &quot;focus&quot;, &quot;blur&quot;, &quot;select&quot;, &quot;change&quot;, &quot;submit&quot;, &quot;reset&quot;);
-            else
-                result.push(types[i]);
-        }
-        return result;
-    },
-
-    /**
-     * @param {Event} event
-     */
-    _logEvent: function(event)
-    {
-        inspectedWindow.console.log(event.type, event);
-    }
-}
-
-injectedScript._commandLineAPIImpl = new CommandLineAPIImpl();
</del><span class="cx"> return injectedScript;
</span><span class="cx"> })
</span></span></pre></div>
<a id="trunkSourceWebCoreinspectorInspectorAllInOnecpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/inspector/InspectorAllInOne.cpp (160923 => 160924)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/inspector/InspectorAllInOne.cpp        2013-12-20 22:01:27 UTC (rev 160923)
+++ trunk/Source/WebCore/inspector/InspectorAllInOne.cpp        2013-12-20 22:04:28 UTC (rev 160924)
</span><span class="lines">@@ -25,6 +25,7 @@
</span><span class="cx"> 
</span><span class="cx"> // This all-in-one cpp file cuts down on template bloat to allow us to build our Windows release build.
</span><span class="cx"> 
</span><ins>+#include &quot;CommandLineAPIModule.cpp&quot;
</ins><span class="cx"> #include &quot;ConsoleMessage.cpp&quot;
</span><span class="cx"> #include &quot;ContentSearchUtils.cpp&quot;
</span><span class="cx"> #include &quot;DOMEditor.cpp&quot;
</span></span></pre></div>
<a id="trunkSourceWebCoreinspectorPageRuntimeAgentcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/inspector/PageRuntimeAgent.cpp (160923 => 160924)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/inspector/PageRuntimeAgent.cpp        2013-12-20 22:01:27 UTC (rev 160923)
+++ trunk/Source/WebCore/inspector/PageRuntimeAgent.cpp        2013-12-20 22:04:28 UTC (rev 160924)
</span><span class="lines">@@ -34,6 +34,7 @@
</span><span class="cx"> 
</span><span class="cx"> #include &quot;PageRuntimeAgent.h&quot;
</span><span class="cx"> 
</span><ins>+#include &quot;CommandLineAPIModule.h&quot;
</ins><span class="cx"> #include &quot;Document.h&quot;
</span><span class="cx"> #include &quot;InjectedScript.h&quot;
</span><span class="cx"> #include &quot;InjectedScriptManager.h&quot;
</span><span class="lines">@@ -129,12 +130,15 @@
</span><span class="cx">         JSC::ExecState* scriptState = mainWorldExecState(&amp;m_inspectedPage-&gt;mainFrame());
</span><span class="cx">         InjectedScript result = injectedScriptManager()-&gt;injectedScriptFor(scriptState);
</span><span class="cx">         if (result.hasNoValue())
</span><del>-            *errorString = &quot;Internal error: main world execution context not found.&quot;;
</del><ins>+            *errorString = ASCIILiteral(&quot;Internal error: main world execution context not found.&quot;);
+        CommandLineAPIModule::injectIfNeeded(injectedScriptManager(), result);
</ins><span class="cx">         return result;
</span><span class="cx">     }
</span><ins>+
</ins><span class="cx">     InjectedScript injectedScript = injectedScriptManager()-&gt;injectedScriptForId(*executionContextId);
</span><span class="cx">     if (injectedScript.hasNoValue())
</span><del>-        *errorString = &quot;Execution context with given id not found.&quot;;
</del><ins>+        *errorString = ASCIILiteral(&quot;Execution context with given id not found.&quot;);
+    CommandLineAPIModule::injectIfNeeded(injectedScriptManager(), injectedScript);
</ins><span class="cx">     return injectedScript;
</span><span class="cx"> }
</span><span class="cx"> 
</span></span></pre>
</div>
</div>

</body>
</html>