Web Inspector: Give the CommandLineAPIModule its own Host object, making InjectedScri...
authorjoepeck@webkit.org <joepeck@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 21 Dec 2013 00:44:36 +0000 (00:44 +0000)
committerjoepeck@webkit.org <joepeck@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 21 Dec 2013 00:44:36 +0000 (00:44 +0000)
https://bugs.webkit.org/show_bug.cgi?id=126082

Reviewed by Timothy Hatcher.

Extract CommandLineAPIHost from InjectedScriptHost. The command line API contained
a bunch of DOM specific JavaScript that would not be suitable for a pure JavaScript
environment. Now that the DOM related code is in this WebCore only module, give this
module a host object that WebCore will provide.

No new tests, no observable change in functionality.

* CMakeLists.txt:
* DerivedSources.cpp:
* DerivedSources.make:
* GNUmakefile.list.am:
* UseJSC.cmake:
* WebCore.vcxproj/WebCore.vcxproj:
* WebCore.vcxproj/WebCore.vcxproj.filters:
* WebCore.xcodeproj/project.pbxproj:
* bindings/js/JSBindingsAllInOne.cpp:
Add new files.

* bindings/js/JSCommandLineAPIHostCustom.cpp: Added.
(WebCore::JSCommandLineAPIHost::inspectedObject):
(WebCore::getJSListenerFunctions):
(WebCore::JSCommandLineAPIHost::getEventListeners):
(WebCore::JSCommandLineAPIHost::inspect):
(WebCore::JSCommandLineAPIHost::databaseId):
(WebCore::JSCommandLineAPIHost::storageId):
* bindings/js/JSInjectedScriptHostCustom.cpp:
* inspector/CommandLineAPIHost.cpp: Copied from Source/WebCore/inspector/InjectedScriptHost.cpp.
(WebCore::CommandLineAPIHost::create):
(WebCore::CommandLineAPIHost::CommandLineAPIHost):
(WebCore::CommandLineAPIHost::~CommandLineAPIHost):
(WebCore::CommandLineAPIHost::disconnect):
(WebCore::CommandLineAPIHost::inspectImpl):
(WebCore::CommandLineAPIHost::getEventListenersImpl):
(WebCore::CommandLineAPIHost::clearConsoleMessages):
(WebCore::CommandLineAPIHost::copyText):
(WebCore::CommandLineAPIHost::InspectableObject::get):
(WebCore::CommandLineAPIHost::addInspectedObject):
(WebCore::CommandLineAPIHost::clearInspectedObjects):
(WebCore::CommandLineAPIHost::inspectedObject):
(WebCore::CommandLineAPIHost::databaseIdImpl):
(WebCore::CommandLineAPIHost::storageIdImpl):
* inspector/CommandLineAPIHost.h: Copied from Source/WebCore/inspector/InjectedScriptHost.h.
(WebCore::CommandLineAPIHost::init):
* inspector/CommandLineAPIHost.idl: Copied from Source/WebCore/inspector/InjectedScriptHost.idl.
* inspector/CommandLineAPIModule.cpp:
These are almost all pure copies from InjectedScriptHost files. Cleaned up a bit.

* inspector/InjectedScriptModule.h:
* inspector/InjectedScriptModule.cpp:
(WebCore::InjectedScriptModule::ensureInjected):
Modules can now define a host object when they are getting injected.

(WebCore::CommandLineAPIModule::host):
* inspector/CommandLineAPIModule.h:
Provide a CommandLineAPIHost, host object.

* inspector/InjectedScriptCanvasModule.h:
* inspector/InjectedScriptCanvasModule.cpp:
(WebCore::InjectedScriptCanvasModule::host):
No host object is needed for the CanvasModule.

* inspector/InjectedScriptSource.js:
* inspector/CommandLineAPIModuleSource.js:
When injecting a module, pass on an optional host object to
the module's source. Move a little more code between the
two files. The two files are very tightly coupled right now.

* inspector/InjectedScriptHost.cpp:
(WebCore::InjectedScriptHost::create):
* inspector/InjectedScriptHost.h:
(WebCore::InjectedScriptHost::~InjectedScriptHost):
(WebCore::InjectedScriptHost::InjectedScriptHost):
* inspector/InjectedScriptHost.idl:
Move any command line specific logic to CommandLineAPIHost classes.

* inspector/InjectedScriptManager.cpp:
(WebCore::InjectedScriptManager::disconnect):
* inspector/InjectedScriptManager.h:
(WebCore::InjectedScriptManager::commandLineAPIHost):
* inspector/InspectorConsoleAgent.cpp:
(WebCore::InspectorConsoleAgent::addInspectedHeapObject):
* inspector/InspectorController.cpp:
(WebCore::InspectorController::InspectorController):
* inspector/InspectorHeapProfilerAgent.cpp:
(WebCore::InspectorHeapProfilerAgent::resetState):
* inspector/InspectorProfilerAgent.cpp:
(WebCore::InspectorProfilerAgent::resetState):
* inspector/PageConsoleAgent.cpp:
(WebCore::PageConsoleAgent::addInspectedNode):
* inspector/PageInjectedScriptManager.cpp:
(WebCore::PageInjectedScriptManager::PageInjectedScriptManager):
(WebCore::PageInjectedScriptManager::disconnect):
* inspector/PageInjectedScriptManager.h:
* inspector/WorkerInspectorController.cpp:
(WebCore::WorkerInspectorController::WorkerInspectorController):
An InjectedScriptManager may optionally have a commandLineAPIHost object.
If it does, initialize it, and send it messages.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@160946 268f45cc-cd09-0410-ab3c-d52691b4dbfc

36 files changed:
Source/WebCore/CMakeLists.txt
Source/WebCore/ChangeLog
Source/WebCore/DerivedSources.cpp
Source/WebCore/DerivedSources.make
Source/WebCore/GNUmakefile.list.am
Source/WebCore/UseJSC.cmake
Source/WebCore/WebCore.vcxproj/WebCore.vcxproj
Source/WebCore/WebCore.vcxproj/WebCore.vcxproj.filters
Source/WebCore/WebCore.xcodeproj/project.pbxproj
Source/WebCore/bindings/js/JSBindingsAllInOne.cpp
Source/WebCore/bindings/js/JSCommandLineAPIHostCustom.cpp [new file with mode: 0644]
Source/WebCore/bindings/js/JSInjectedScriptHostCustom.cpp
Source/WebCore/inspector/CommandLineAPIHost.cpp [new file with mode: 0644]
Source/WebCore/inspector/CommandLineAPIHost.h [new file with mode: 0644]
Source/WebCore/inspector/CommandLineAPIHost.idl [new file with mode: 0644]
Source/WebCore/inspector/CommandLineAPIModule.cpp
Source/WebCore/inspector/CommandLineAPIModule.h
Source/WebCore/inspector/CommandLineAPIModuleSource.js
Source/WebCore/inspector/InjectedScriptCanvasModule.cpp
Source/WebCore/inspector/InjectedScriptCanvasModule.h
Source/WebCore/inspector/InjectedScriptHost.cpp
Source/WebCore/inspector/InjectedScriptHost.h
Source/WebCore/inspector/InjectedScriptHost.idl
Source/WebCore/inspector/InjectedScriptManager.cpp
Source/WebCore/inspector/InjectedScriptManager.h
Source/WebCore/inspector/InjectedScriptModule.cpp
Source/WebCore/inspector/InjectedScriptModule.h
Source/WebCore/inspector/InjectedScriptSource.js
Source/WebCore/inspector/InspectorConsoleAgent.cpp
Source/WebCore/inspector/InspectorController.cpp
Source/WebCore/inspector/InspectorHeapProfilerAgent.cpp
Source/WebCore/inspector/InspectorProfilerAgent.cpp
Source/WebCore/inspector/PageConsoleAgent.cpp
Source/WebCore/inspector/PageInjectedScriptManager.cpp
Source/WebCore/inspector/PageInjectedScriptManager.h
Source/WebCore/inspector/WorkerInspectorController.cpp

index d4289f8..e2b56a1 100644 (file)
@@ -529,6 +529,7 @@ set(WebCore_IDL_FILES
     html/canvas/WebGLUniformLocation.idl
     html/canvas/WebGLVertexArrayObjectOES.idl
 
+    inspector/CommandLineAPIHost.idl
     inspector/InjectedScriptHost.idl
     inspector/InspectorFrontendHost.idl
     inspector/JavaScriptCallFrame.idl
@@ -1568,6 +1569,7 @@ set(WebCore_SOURCES
     html/shadow/SpinButtonElement.cpp
     html/shadow/TextControlInnerElements.cpp
 
+    inspector/CommandLineAPIHost.cpp
     inspector/CommandLineAPIModule.cpp
     inspector/ConsoleMessage.cpp
     inspector/ContentSearchUtils.cpp
index e84f59d..c6702d7 100644 (file)
@@ -1,3 +1,108 @@
+2013-12-20  Joseph Pecoraro  <pecoraro@apple.com>
+
+        Web Inspector: Give the CommandLineAPIModule its own Host object, making InjectedScriptHost viable for a JS Context
+        https://bugs.webkit.org/show_bug.cgi?id=126082
+
+        Reviewed by Timothy Hatcher.
+
+        Extract CommandLineAPIHost from InjectedScriptHost. The command line API contained
+        a bunch of DOM specific JavaScript that would not be suitable for a pure JavaScript
+        environment. Now that the DOM related code is in this WebCore only module, give this
+        module a host object that WebCore will provide.
+
+        No new tests, no observable change in functionality.
+
+        * CMakeLists.txt:
+        * DerivedSources.cpp:
+        * DerivedSources.make:
+        * GNUmakefile.list.am:
+        * UseJSC.cmake:
+        * WebCore.vcxproj/WebCore.vcxproj:
+        * WebCore.vcxproj/WebCore.vcxproj.filters:
+        * WebCore.xcodeproj/project.pbxproj:
+        * bindings/js/JSBindingsAllInOne.cpp:
+        Add new files.
+
+        * bindings/js/JSCommandLineAPIHostCustom.cpp: Added.
+        (WebCore::JSCommandLineAPIHost::inspectedObject):
+        (WebCore::getJSListenerFunctions):
+        (WebCore::JSCommandLineAPIHost::getEventListeners):
+        (WebCore::JSCommandLineAPIHost::inspect):
+        (WebCore::JSCommandLineAPIHost::databaseId):
+        (WebCore::JSCommandLineAPIHost::storageId):
+        * bindings/js/JSInjectedScriptHostCustom.cpp:
+        * inspector/CommandLineAPIHost.cpp: Copied from Source/WebCore/inspector/InjectedScriptHost.cpp.
+        (WebCore::CommandLineAPIHost::create):
+        (WebCore::CommandLineAPIHost::CommandLineAPIHost):
+        (WebCore::CommandLineAPIHost::~CommandLineAPIHost):
+        (WebCore::CommandLineAPIHost::disconnect):
+        (WebCore::CommandLineAPIHost::inspectImpl):
+        (WebCore::CommandLineAPIHost::getEventListenersImpl):
+        (WebCore::CommandLineAPIHost::clearConsoleMessages):
+        (WebCore::CommandLineAPIHost::copyText):
+        (WebCore::CommandLineAPIHost::InspectableObject::get):
+        (WebCore::CommandLineAPIHost::addInspectedObject):
+        (WebCore::CommandLineAPIHost::clearInspectedObjects):
+        (WebCore::CommandLineAPIHost::inspectedObject):
+        (WebCore::CommandLineAPIHost::databaseIdImpl):
+        (WebCore::CommandLineAPIHost::storageIdImpl):
+        * inspector/CommandLineAPIHost.h: Copied from Source/WebCore/inspector/InjectedScriptHost.h.
+        (WebCore::CommandLineAPIHost::init):
+        * inspector/CommandLineAPIHost.idl: Copied from Source/WebCore/inspector/InjectedScriptHost.idl.
+        * inspector/CommandLineAPIModule.cpp:
+        These are almost all pure copies from InjectedScriptHost files. Cleaned up a bit.
+
+        * inspector/InjectedScriptModule.h:
+        * inspector/InjectedScriptModule.cpp:
+        (WebCore::InjectedScriptModule::ensureInjected):
+        Modules can now define a host object when they are getting injected.
+
+        (WebCore::CommandLineAPIModule::host):
+        * inspector/CommandLineAPIModule.h:
+        Provide a CommandLineAPIHost, host object.
+
+        * inspector/InjectedScriptCanvasModule.h:
+        * inspector/InjectedScriptCanvasModule.cpp:
+        (WebCore::InjectedScriptCanvasModule::host):
+        No host object is needed for the CanvasModule.
+
+        * inspector/InjectedScriptSource.js:
+        * inspector/CommandLineAPIModuleSource.js:
+        When injecting a module, pass on an optional host object to
+        the module's source. Move a little more code between the
+        two files. The two files are very tightly coupled right now.
+
+        * inspector/InjectedScriptHost.cpp:
+        (WebCore::InjectedScriptHost::create):
+        * inspector/InjectedScriptHost.h:
+        (WebCore::InjectedScriptHost::~InjectedScriptHost):
+        (WebCore::InjectedScriptHost::InjectedScriptHost):
+        * inspector/InjectedScriptHost.idl:
+        Move any command line specific logic to CommandLineAPIHost classes.
+
+        * inspector/InjectedScriptManager.cpp:
+        (WebCore::InjectedScriptManager::disconnect):
+        * inspector/InjectedScriptManager.h:
+        (WebCore::InjectedScriptManager::commandLineAPIHost):
+        * inspector/InspectorConsoleAgent.cpp:
+        (WebCore::InspectorConsoleAgent::addInspectedHeapObject):
+        * inspector/InspectorController.cpp:
+        (WebCore::InspectorController::InspectorController):
+        * inspector/InspectorHeapProfilerAgent.cpp:
+        (WebCore::InspectorHeapProfilerAgent::resetState):
+        * inspector/InspectorProfilerAgent.cpp:
+        (WebCore::InspectorProfilerAgent::resetState):
+        * inspector/PageConsoleAgent.cpp:
+        (WebCore::PageConsoleAgent::addInspectedNode):
+        * inspector/PageInjectedScriptManager.cpp:
+        (WebCore::PageInjectedScriptManager::PageInjectedScriptManager):
+        (WebCore::PageInjectedScriptManager::disconnect):
+        * inspector/PageInjectedScriptManager.h:
+        * inspector/WorkerInspectorController.cpp:
+        (WebCore::WorkerInspectorController::WorkerInspectorController):
+        An InjectedScriptManager may optionally have a commandLineAPIHost object.
+        If it does, initialize it, and send it messages.
+
 2013-12-09  Myles C. Maxfield  <mmaxfield@apple.com>
 
         Allow ImageBuffer to re-use IOSurfaces
index 01a5095..3b9981f 100644 (file)
@@ -20,7 +20,7 @@
  * 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. 
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
 // This all-in-one cpp file cuts down on template bloat to allow us to build our Windows release build.
@@ -73,6 +73,7 @@
 #include "JSClientRectList.cpp"
 #include "JSClipboard.cpp"
 #include "JSCloseEvent.cpp"
+#include "JSCommandLineAPIHost.cpp"
 #include "JSComment.cpp"
 #include "JSCompositionEvent.cpp"
 #include "JSConsole.cpp"
index 9b71c97..61e2cfc 100644 (file)
@@ -452,6 +452,7 @@ BINDING_IDLS = \
     $(WebCore)/html/track/TrackEvent.idl \
     $(WebCore)/html/track/VideoTrack.idl \
     $(WebCore)/html/track/VideoTrackList.idl \
+    $(WebCore)/inspector/CommandLineAPIHost.idl \
     $(WebCore)/inspector/InjectedScriptHost.idl \
     $(WebCore)/inspector/InspectorFrontendHost.idl \
     $(WebCore)/inspector/ScriptProfile.idl \
index 9d501ea..36033db 100644 (file)
@@ -105,6 +105,8 @@ webcore_built_sources += \
        DerivedSources/WebCore/JSClipboard.h \
        DerivedSources/WebCore/JSCloseEvent.cpp \
        DerivedSources/WebCore/JSCloseEvent.h \
+       DerivedSources/WebCore/JSCommandLineAPIHost.cpp \
+       DerivedSources/WebCore/JSCommandLineAPIHost.h \
        DerivedSources/WebCore/JSComment.cpp \
        DerivedSources/WebCore/JSComment.h \
        DerivedSources/WebCore/JSCompositionEvent.cpp \
@@ -1548,6 +1550,7 @@ dom_binding_idls += \
        $(WebCore)/html/track/TrackEvent.idl \
        $(WebCore)/html/track/VideoTrack.idl \
        $(WebCore)/html/track/VideoTrackList.idl \
+       $(WebCore)/inspector/CommandLineAPIHost.idl \
        $(WebCore)/inspector/InjectedScriptHost.idl \
        $(WebCore)/inspector/InspectorFrontendHost.idl \
        $(WebCore)/inspector/JavaScriptCallFrame.idl \
@@ -2293,6 +2296,7 @@ webcore_sources += \
        Source/WebCore/bindings/js/JSCanvasRenderingContext2DCustom.cpp \
        Source/WebCore/bindings/js/JSCanvasRenderingContextCustom.cpp \
        Source/WebCore/bindings/js/JSClipboardCustom.cpp \
+       Source/WebCore/bindings/js/JSCommandLineAPIHostCustom.cpp \
        Source/WebCore/bindings/js/JSCryptoCustom.cpp \
        Source/WebCore/bindings/js/JSCustomSQLStatementErrorCallback.cpp \
        Source/WebCore/bindings/js/JSCustomXPathNSResolver.cpp \
@@ -3767,8 +3771,10 @@ webcore_sources += \
        Source/WebCore/icu/unicode/utypes.h \
        Source/WebCore/icu/unicode/uversion.h \
        Source/WebCore/inspector/BindingVisitors.h \
-    Source/WebCore/inspector/CommandLineAPIModule.cpp \
-    Source/WebCore/inspector/CommandLineAPIModule.h \
+       Source/WebCore/inspector/CommandLineAPIHost.cpp \
+       Source/WebCore/inspector/CommandLineAPIHost.h \
+       Source/WebCore/inspector/CommandLineAPIModule.cpp \
+       Source/WebCore/inspector/CommandLineAPIModule.h \
        Source/WebCore/inspector/ConsoleAPITypes.h \
        Source/WebCore/inspector/ConsoleMessage.cpp \
        Source/WebCore/inspector/ConsoleMessage.h \
index 6384598..22b4f6c 100644 (file)
@@ -39,6 +39,7 @@ list(APPEND WebCore_SOURCES
     bindings/js/JSCanvasRenderingContext2DCustom.cpp
     bindings/js/JSCanvasRenderingContextCustom.cpp
     bindings/js/JSClipboardCustom.cpp
+    bindings/js/JSCommandLineAPIHostCustom.cpp
     bindings/js/JSCryptoCustom.cpp
     bindings/js/JSCustomXPathNSResolver.cpp
     bindings/js/JSDictionary.cpp
index 3effa09..227d628 100644 (file)
       <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Production|Win32'">true</ExcludedFromBuild>
       <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Production|x64'">true</ExcludedFromBuild>
     </ClCompile>
+    <ClCompile Include="$(ConfigurationBuildDir)\obj$(PlatformArchitecture)\$(ProjectName)\DerivedSources\JSCommandLineAPIHost.cpp">
+      <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</ExcludedFromBuild>
+      <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</ExcludedFromBuild>
+      <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug_WinCairo|Win32'">true</ExcludedFromBuild>
+      <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug_WinCairo|x64'">true</ExcludedFromBuild>
+      <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='DebugSuffix|Win32'">true</ExcludedFromBuild>
+      <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='DebugSuffix|x64'">true</ExcludedFromBuild>
+      <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</ExcludedFromBuild>
+      <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</ExcludedFromBuild>
+      <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release_WinCairo|Win32'">true</ExcludedFromBuild>
+      <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release_WinCairo|x64'">true</ExcludedFromBuild>
+      <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Production|Win32'">true</ExcludedFromBuild>
+      <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Production|x64'">true</ExcludedFromBuild>
+    </ClCompile>
     <ClCompile Include="$(ConfigurationBuildDir)\obj$(PlatformArchitecture)\$(ProjectName)\DerivedSources\JSComment.cpp">
       <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</ExcludedFromBuild>
       <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</ExcludedFromBuild>
       <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Production|Win32'">true</ExcludedFromBuild>
       <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Production|x64'">true</ExcludedFromBuild>
     </ClCompile>
+    <ClCompile Include="..\bindings\js\JSCommandLineAPIHostCustom.cpp">
+      <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</ExcludedFromBuild>
+      <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</ExcludedFromBuild>
+      <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug_WinCairo|Win32'">true</ExcludedFromBuild>
+      <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug_WinCairo|x64'">true</ExcludedFromBuild>
+      <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='DebugSuffix|Win32'">true</ExcludedFromBuild>
+      <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='DebugSuffix|x64'">true</ExcludedFromBuild>
+      <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</ExcludedFromBuild>
+      <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</ExcludedFromBuild>
+      <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release_WinCairo|Win32'">true</ExcludedFromBuild>
+      <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release_WinCairo|x64'">true</ExcludedFromBuild>
+      <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Production|Win32'">true</ExcludedFromBuild>
+      <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Production|x64'">true</ExcludedFromBuild>
+    </ClCompile>
     <ClCompile Include="..\bindings\js\JSCSSRuleCustom.cpp">
       <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</ExcludedFromBuild>
       <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</ExcludedFromBuild>
     <ClCompile Include="..\bridge\runtime_method.cpp" />
     <ClCompile Include="..\bridge\runtime_object.cpp" />
     <ClCompile Include="..\bridge\runtime_root.cpp" />
+    <ClCompile Include="..\inspector\CommandLineAPIHost.cpp">
+      <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</ExcludedFromBuild>
+      <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</ExcludedFromBuild>
+      <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release_WinCairo|Win32'">true</ExcludedFromBuild>
+      <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release_WinCairo|x64'">true</ExcludedFromBuild>
+      <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Production|Win32'">true</ExcludedFromBuild>
+      <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Production|x64'">true</ExcludedFromBuild>
+    </ClCompile>
     <ClCompile Include="..\inspector\CommandLineAPIModule.cpp">
       <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</ExcludedFromBuild>
       <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</ExcludedFromBuild>
     <ClInclude Include="$(ConfigurationBuildDir)\obj$(PlatformArchitecture)\$(ProjectName)\DerivedSources\JSClientRect.h" />
     <ClInclude Include="$(ConfigurationBuildDir)\obj$(PlatformArchitecture)\$(ProjectName)\DerivedSources\JSClientRectList.h" />
     <ClInclude Include="$(ConfigurationBuildDir)\obj$(PlatformArchitecture)\$(ProjectName)\DerivedSources\JSClipboard.h" />
+    <ClInclude Include="$(ConfigurationBuildDir)\obj$(PlatformArchitecture)\$(ProjectName)\DerivedSources\JSCommandLineAPIHost.h" />
     <ClInclude Include="$(ConfigurationBuildDir)\obj$(PlatformArchitecture)\$(ProjectName)\DerivedSources\JSComment.h" />
     <ClInclude Include="$(ConfigurationBuildDir)\obj$(PlatformArchitecture)\$(ProjectName)\DerivedSources\JSCompositionEvent.h" />
     <ClInclude Include="$(ConfigurationBuildDir)\obj$(PlatformArchitecture)\$(ProjectName)\DerivedSources\JSConsole.h" />
     <ClInclude Include="..\bridge\runtime_root.h" />
     <ClInclude Include="..\inspector\BindingVisitors.h" />
     <ClInclude Include="..\inspector\ConsoleAPITypes.h" />
+    <ClInclude Include="..\inspector\CommandLineAPIHost.h" />
     <ClInclude Include="..\inspector\CommandLineAPIModule.h" />
     <ClInclude Include="..\inspector\ConsoleMessage.h" />
     <ClInclude Include="..\inspector\ContentSearchUtils.h" />
index cae05a6..8bdddd3 100644 (file)
     <ClCompile Include="..\bindings\js\JSClipboardCustom.cpp">
       <Filter>bindings\js</Filter>
     </ClCompile>
+    <ClCompile Include="..\bindings\js\JSCommandLineAPIHostCustom.cpp">
+      <Filter>bindings\js</Filter>
+    </ClCompile>
     <ClCompile Include="..\bindings\js\JSCSSRuleCustom.cpp">
       <Filter>bindings\js</Filter>
     </ClCompile>
     <ClCompile Include="..\bridge\runtime_root.cpp">
       <Filter>bridge</Filter>
     </ClCompile>
+    <ClCompile Include="..\inspector\CommandLineAPIHost.cpp">
+      <Filter>inspector</Filter>
+    </ClCompile>
     <ClCompile Include="..\inspector\CommandLineAPIModule.cpp">
       <Filter>inspector</Filter>
     </ClCompile>
     <ClCompile Include="$(ConfigurationBuildDir)\obj$(PlatformArchitecture)\$(ProjectName)\DerivedSources\JSClipboard.cpp">
       <Filter>DerivedSources</Filter>
     </ClCompile>
+    <ClCompile Include="$(ConfigurationBuildDir)\obj$(PlatformArchitecture)\$(ProjectName)\DerivedSources\JSCommandLineAPIHost.cpp">
+      <Filter>DerivedSources</Filter>
+    </ClCompile>
     <ClCompile Include="$(ConfigurationBuildDir)\obj$(PlatformArchitecture)\$(ProjectName)\DerivedSources\JSComment.cpp">
       <Filter>DerivedSources</Filter>
     </ClCompile>
     <ClInclude Include="..\inspector\BindingVisitors.h">
       <Filter>inspector</Filter>
     </ClInclude>
+    <ClInclude Include="..\inspector\CommandLineAPIHost.h">
+      <Filter>inspector</Filter>
+    </ClInclude>
     <ClInclude Include="..\inspector\CommandLineAPIModule.h">
       <Filter>inspector</Filter>
     </ClInclude>
     <ClInclude Include="$(ConfigurationBuildDir)\obj$(PlatformArchitecture)\$(ProjectName)\DerivedSources\JSClipboard.h">
       <Filter>DerivedSources</Filter>
     </ClInclude>
+    <ClInclude Include="$(ConfigurationBuildDir)\obj$(PlatformArchitecture)\$(ProjectName)\DerivedSources\JSCommandLineAPIHost.h">
+      <Filter>DerivedSources</Filter>
+    </ClInclude>
     <ClInclude Include="$(ConfigurationBuildDir)\obj$(PlatformArchitecture)\$(ProjectName)\DerivedSources\JSComment.h">
       <Filter>DerivedSources</Filter>
     </ClInclude>
index 61c242c..2bc4d3b 100644 (file)
                A584FE2C1863870F00843B10 /* CommandLineAPIModule.h in Headers */ = {isa = PBXBuildFile; fileRef = A584FE2A1863870F00843B10 /* CommandLineAPIModule.h */; };
                A584FE2F1864CB8400843B10 /* PageInjectedScriptManager.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A584FE2D1864CB8400843B10 /* PageInjectedScriptManager.cpp */; };
                A584FE301864CB8400843B10 /* PageInjectedScriptManager.h in Headers */ = {isa = PBXBuildFile; fileRef = A584FE2E1864CB8400843B10 /* PageInjectedScriptManager.h */; };
+               A584FE341864D5AF00843B10 /* CommandLineAPIHost.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A584FE311864D5AF00843B10 /* CommandLineAPIHost.cpp */; };
+               A584FE351864D5AF00843B10 /* CommandLineAPIHost.h in Headers */ = {isa = PBXBuildFile; fileRef = A584FE321864D5AF00843B10 /* CommandLineAPIHost.h */; };
+               A584FE381864DAC100843B10 /* JSCommandLineAPIHostCustom.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A584FE371864DAC100843B10 /* JSCommandLineAPIHostCustom.cpp */; };
+               A584FE3B1864E2D800843B10 /* JSCommandLineAPIHost.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A584FE391864E2D800843B10 /* JSCommandLineAPIHost.cpp */; };
+               A584FE3C1864E2D800843B10 /* JSCommandLineAPIHost.h in Headers */ = {isa = PBXBuildFile; fileRef = A584FE3A1864E2D800843B10 /* JSCommandLineAPIHost.h */; };
                A593CF8B1840535200BFCE27 /* InspectorWebAgentBase.h in Headers */ = {isa = PBXBuildFile; fileRef = A593CF8A1840535200BFCE27 /* InspectorWebAgentBase.h */; settings = {ATTRIBUTES = (Private, ); }; };
                A5A2AF0B1829734300DE1729 /* PageDebuggable.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A5A2AF091829734300DE1729 /* PageDebuggable.cpp */; };
                A5A2AF0C1829734300DE1729 /* PageDebuggable.h in Headers */ = {isa = PBXBuildFile; fileRef = A5A2AF0A1829734300DE1729 /* PageDebuggable.h */; };
                A584FE2A1863870F00843B10 /* CommandLineAPIModule.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CommandLineAPIModule.h; sourceTree = "<group>"; };
                A584FE2D1864CB8400843B10 /* PageInjectedScriptManager.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = PageInjectedScriptManager.cpp; sourceTree = "<group>"; };
                A584FE2E1864CB8400843B10 /* PageInjectedScriptManager.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PageInjectedScriptManager.h; sourceTree = "<group>"; };
+               A584FE311864D5AF00843B10 /* CommandLineAPIHost.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CommandLineAPIHost.cpp; sourceTree = "<group>"; };
+               A584FE321864D5AF00843B10 /* CommandLineAPIHost.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CommandLineAPIHost.h; sourceTree = "<group>"; };
+               A584FE331864D5AF00843B10 /* CommandLineAPIHost.idl */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = CommandLineAPIHost.idl; sourceTree = "<group>"; };
+               A584FE371864DAC100843B10 /* JSCommandLineAPIHostCustom.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSCommandLineAPIHostCustom.cpp; sourceTree = "<group>"; };
+               A584FE391864E2D800843B10 /* JSCommandLineAPIHost.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSCommandLineAPIHost.cpp; sourceTree = "<group>"; };
+               A584FE3A1864E2D800843B10 /* JSCommandLineAPIHost.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSCommandLineAPIHost.h; sourceTree = "<group>"; };
                A593CF7218402CE900BFCE27 /* protocol */ = {isa = PBXFileReference; lastKnownFileType = folder; path = protocol; sourceTree = "<group>"; };
                A593CF7518402D4B00BFCE27 /* combine-javascript-resources.pl */ = {isa = PBXFileReference; lastKnownFileType = text.script.perl; path = "combine-javascript-resources.pl"; sourceTree = "<group>"; };
                A593CF8A1840535200BFCE27 /* InspectorWebAgentBase.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = InspectorWebAgentBase.h; sourceTree = "<group>"; };
                                4F4F5FFC11CBD30100A186BF /* InspectorWebFrontendDispatchers.h */,
                                573D134514CE39FF0057ABCA /* InspectorWebTypeBuilders.cpp */,
                                573D134614CE39FF0057ABCA /* InspectorWebTypeBuilders.h */,
+                               A584FE391864E2D800843B10 /* JSCommandLineAPIHost.cpp */,
+                               A584FE3A1864E2D800843B10 /* JSCommandLineAPIHost.h */,
                                7A0E76D810BF059800A0276E /* JSInjectedScriptHost.cpp */,
                                7A0E76D910BF059800A0276E /* JSInjectedScriptHost.h */,
                                7A0E771C10C00DB100A0276E /* JSInspectorFrontendHost.cpp */,
                                A518225317E28CF100A9BA1D /* Scripts */,
                                A593CF7518402D4B00BFCE27 /* combine-javascript-resources.pl */,
                                F35AE5AB14925F5B004D5776 /* BindingVisitors.h */,
+                               A584FE311864D5AF00843B10 /* CommandLineAPIHost.cpp */,
+                               A584FE321864D5AF00843B10 /* CommandLineAPIHost.h */,
+                               A584FE331864D5AF00843B10 /* CommandLineAPIHost.idl */,
                                A584FE291863870F00843B10 /* CommandLineAPIModule.cpp */,
                                A584FE2A1863870F00843B10 /* CommandLineAPIModule.h */,
                                A584FE2718637DCA00843B10 /* CommandLineAPIModuleSource.js */,
                                49EED14D1051971A00099FAB /* JSCanvasRenderingContextCustom.cpp */,
                                93BA59B10F2AA5FE008E8E99 /* JSCDATASectionCustom.cpp */,
                                BCA83E510D7CE205003421A8 /* JSClipboardCustom.cpp */,
+                               A584FE371864DAC100843B10 /* JSCommandLineAPIHostCustom.cpp */,
                                209B456A16796A7E00E54E4E /* JSCryptoCustom.cpp */,
                                E157A8E618184C67009F821D /* JSCryptoKeyCustom.cpp */,
                                E1F80B89183172A2007885C3 /* JSCryptoKeyPairCustom.cpp */,
                                85032DE90AA8C9BE007D3B7D /* DOMCSSUnknownRule.h in Headers */,
                                85909CE40ACC7A7E00DF01F1 /* DOMCSSUnknownRuleInternal.h in Headers */,
                                858C381C0AA8E29600B187A4 /* DOMCSSValue.h in Headers */,
+                               A584FE351864D5AF00843B10 /* CommandLineAPIHost.h in Headers */,
                                85B498F30ADB336A00925CBB /* DOMCSSValueInternal.h in Headers */,
                                858C383C0AA8ED8200B187A4 /* DOMCSSValueList.h in Headers */,
                                85909D2B0ACC7D5500DF01F1 /* DOMCSSValueListInternal.h in Headers */,
                                F916C48E0DB510F80076CD83 /* JSXMLHttpRequestProgressEvent.h in Headers */,
                                BCDFD4960E30592F009D10AD /* JSXMLHttpRequestUpload.h in Headers */,
                                1ACE53F70A8D19470022947D /* JSXMLSerializer.h in Headers */,
+                               A584FE3C1864E2D800843B10 /* JSCommandLineAPIHost.h in Headers */,
                                1A762C740A074F2600989F5B /* JSXPathEvaluator.h in Headers */,
                                E157A8ED181851AC009F821D /* CryptoAlgorithmDescriptionBuilder.h in Headers */,
                                BC60DB4A0D2A3D1E00B9918F /* JSXPathException.h in Headers */,
                                4ACBC0BE12713CBD0094F9B2 /* ClassList.cpp in Sources */,
                                BC904B760D10998F00680D32 /* ClassNodeList.cpp in Sources */,
                                BCC0657D0F3CE1B700CD2D87 /* ClientRect.cpp in Sources */,
+                               A584FE341864D5AF00843B10 /* CommandLineAPIHost.cpp in Sources */,
                                BCC065800F3CE1B700CD2D87 /* ClientRectList.cpp in Sources */,
                                A784941B0B5FE507001E237A /* Clipboard.cpp in Sources */,
                                85031B3F0A44EFC700F992E0 /* ClipboardEvent.cpp in Sources */,
                                50D405F9147D31F300D30BB5 /* CustomFilterMesh.cpp in Sources */,
                                E1C266DE18319F31003F8B33 /* CryptoKeyDataRSAComponents.cpp in Sources */,
                                7E12E91015FA5D3A005E4126 /* CustomFilterMeshGenerator.cpp in Sources */,
+                               A584FE3B1864E2D800843B10 /* JSCommandLineAPIHost.cpp in Sources */,
                                50CC0A3914C6F5B10017AB51 /* CustomFilterOperation.cpp in Sources */,
                                5093334F163B0E4300099A60 /* CustomFilterParameterList.cpp in Sources */,
                                503D0CAA14B5B08700F32F57 /* CustomFilterProgram.cpp in Sources */,
                                82889B4C13C62392009A6156 /* InspectorStyleTextEditor.cpp in Sources */,
                                07277E4E17D018CC0015534D /* JSMediaStreamAudioDestinationNode.cpp in Sources */,
                                754133AA102E00F400075D00 /* InspectorTimelineAgent.cpp in Sources */,
+                               A584FE381864DAC100843B10 /* JSCommandLineAPIHostCustom.cpp in Sources */,
                                573D134714CE39FF0057ABCA /* InspectorWebTypeBuilders.cpp in Sources */,
                                F3810C1B1365A49600ED6E33 /* InspectorWorkerAgent.cpp in Sources */,
                                F350B73513F1377D00880C43 /* InstrumentingAgents.cpp in Sources */,
index a30f79e..234259c 100644 (file)
 #include "JSCanvasRenderingContext2DCustom.cpp"
 #include "JSCanvasRenderingContextCustom.cpp"
 #include "JSClipboardCustom.cpp"
+#include "JSCommandLineAPIHostCustom.cpp"
 #include "JSCryptoCustom.cpp"
 #include "JSCustomSQLStatementErrorCallback.cpp"
 #include "JSCustomXPathNSResolver.cpp"
-#include "JSDictionary.cpp"
 #include "JSDOMBinding.cpp"
 #include "JSDOMFormDataCustom.cpp"
 #include "JSDOMGlobalObject.cpp"
@@ -64,6 +64,7 @@
 #include "JSDOMWrapper.cpp"
 #include "JSDedicatedWorkerGlobalScopeCustom.cpp"
 #include "JSDeviceOrientationEventCustom.cpp"
+#include "JSDictionary.cpp"
 #include "JSDocumentCustom.cpp"
 #include "JSElementCustom.cpp"
 #include "JSErrorHandler.cpp"
diff --git a/Source/WebCore/bindings/js/JSCommandLineAPIHostCustom.cpp b/Source/WebCore/bindings/js/JSCommandLineAPIHostCustom.cpp
new file mode 100644 (file)
index 0000000..be0ae27
--- /dev/null
@@ -0,0 +1,173 @@
+/*
+ * Copyright (C) 2007, 2008 Apple Inc. All rights reserved.
+ * Copyright (C) 2008 Matt Lilek <webkit@mattlilek.com>
+ * Copyright (C) 2010-2011 Google 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:
+ *
+ *     * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *     * 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.
+ *     * Neither the name of Google Inc. 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 THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "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 THE COPYRIGHT
+ * OWNER 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 "config.h"
+
+#if ENABLE(INSPECTOR)
+
+#include "JSCommandLineAPIHost.h"
+
+#include "CommandLineAPIHost.h"
+#include "InspectorDOMAgent.h"
+#include "JSEventListener.h"
+#include "JSNode.h"
+#include "JSStorage.h"
+#include "Storage.h"
+#include <bindings/ScriptValue.h>
+#include <inspector/InspectorValues.h>
+#include <parser/SourceCode.h>
+#include <runtime/JSArray.h>
+#include <runtime/JSFunction.h>
+#include <runtime/JSLock.h>
+#include <runtime/ObjectConstructor.h>
+
+#if ENABLE(SQL_DATABASE)
+#include "Database.h"
+#include "JSDatabase.h"
+#endif
+
+using namespace JSC;
+
+namespace WebCore {
+
+JSValue JSCommandLineAPIHost::inspectedObject(ExecState* exec)
+{
+    if (exec->argumentCount() < 1)
+        return jsUndefined();
+
+    CommandLineAPIHost::InspectableObject* object = impl().inspectedObject(exec->uncheckedArgument(0).toInt32(exec));
+    if (!object)
+        return jsUndefined();
+
+    JSLockHolder lock(exec);
+    Deprecated::ScriptValue scriptValue = object->get(exec);
+    if (scriptValue.hasNoValue())
+        return jsUndefined();
+
+    return scriptValue.jsValue();
+}
+
+static JSArray* getJSListenerFunctions(ExecState* exec, Document* document, const EventListenerInfo& listenerInfo)
+{
+    JSArray* result = constructEmptyArray(exec, nullptr);
+    size_t handlersCount = listenerInfo.eventListenerVector.size();
+    for (size_t i = 0, outputIndex = 0; i < handlersCount; ++i) {
+        const JSEventListener* jsListener = JSEventListener::cast(listenerInfo.eventListenerVector[i].listener.get());
+        if (!jsListener) {
+            ASSERT_NOT_REACHED();
+            continue;
+        }
+
+        // Hide listeners from other contexts.
+        if (&jsListener->isolatedWorld() != &currentWorld(exec))
+            continue;
+
+        JSObject* function = jsListener->jsFunction(document);
+        if (!function)
+            continue;
+
+        JSObject* listenerEntry = constructEmptyObject(exec);
+        listenerEntry->putDirect(exec->vm(), Identifier(exec, "listener"), function);
+        listenerEntry->putDirect(exec->vm(), Identifier(exec, "useCapture"), jsBoolean(listenerInfo.eventListenerVector[i].useCapture));
+        result->putDirectIndex(exec, outputIndex++, JSValue(listenerEntry));
+    }
+    return result;
+}
+
+JSValue JSCommandLineAPIHost::getEventListeners(ExecState* exec)
+{
+    if (exec->argumentCount() < 1)
+        return jsUndefined();
+
+    JSValue value = exec->uncheckedArgument(0);
+    if (!value.isObject() || value.isNull())
+        return jsUndefined();
+
+    Node* node = toNode(value);
+    if (!node)
+        return jsUndefined();
+
+    Vector<EventListenerInfo> listenersArray;
+    impl().getEventListenersImpl(node, listenersArray);
+
+    JSObject* result = constructEmptyObject(exec);
+    for (size_t i = 0; i < listenersArray.size(); ++i) {
+        JSArray* listeners = getJSListenerFunctions(exec, &node->document(), listenersArray[i]);
+        if (!listeners->length())
+            continue;
+        AtomicString eventType = listenersArray[i].eventType;
+        result->putDirect(exec->vm(), Identifier(exec, eventType.impl()), JSValue(listeners));
+    }
+
+    return result;
+}
+
+JSValue JSCommandLineAPIHost::inspect(ExecState* exec)
+{
+    if (exec->argumentCount() >= 2) {
+        Deprecated::ScriptValue object(exec->vm(), exec->uncheckedArgument(0));
+        Deprecated::ScriptValue hints(exec->vm(), exec->uncheckedArgument(1));
+        impl().inspectImpl(object.toInspectorValue(exec), hints.toInspectorValue(exec));
+    }
+
+    return jsUndefined();
+}
+
+JSValue JSCommandLineAPIHost::databaseId(ExecState* exec)
+{
+    if (exec->argumentCount() < 1)
+        return jsUndefined();
+
+#if ENABLE(SQL_DATABASE)
+    Database* database = toDatabase(exec->uncheckedArgument(0));
+    if (database)
+        return jsStringWithCache(exec, impl().databaseIdImpl(database));
+#endif
+
+    return jsUndefined();
+}
+
+JSValue JSCommandLineAPIHost::storageId(ExecState* exec)
+{
+    if (exec->argumentCount() < 1)
+        return jsUndefined();
+
+    Storage* storage = toStorage(exec->uncheckedArgument(0));
+    if (storage)
+        return jsStringWithCache(exec, impl().storageIdImpl(storage));
+
+    return jsUndefined();
+}
+
+} // namespace WebCore
+
+#endif // ENABLE(INSPECTOR)
index 2417635..7ff5d5f 100644 (file)
 
 #include "JSInjectedScriptHost.h"
 
-#if ENABLE(SQL_DATABASE)
-#include "Database.h"
-#include "JSDatabase.h"
-#endif
 #include "ExceptionCode.h"
 #include "InjectedScriptHost.h"
-#include "InspectorDOMAgent.h"
-#include "InspectorDebuggerAgent.h"
-#include "JSEventListener.h"
 #include "JSHTMLAllCollection.h"
 #include "JSHTMLCollection.h"
 #include "JSNode.h"
 #include "JSNodeList.h"
-#include "JSStorage.h"
-#include "Storage.h"
 #include <bindings/ScriptValue.h>
-#include <inspector/InspectorValues.h>
 #include <parser/SourceCode.h>
 #include <runtime/DateInstance.h>
 #include <runtime/Error.h>
@@ -85,23 +75,6 @@ Deprecated::ScriptValue InjectedScriptHost::nodeAsScriptValue(JSC::ExecState* st
     return Deprecated::ScriptValue(state->vm(), toJS(state, deprecatedGlobalObjectForPrototype(state), node));
 }
 
-JSValue JSInjectedScriptHost::inspectedObject(ExecState* exec)
-{
-    if (exec->argumentCount() < 1)
-        return jsUndefined();
-
-    InjectedScriptHost::InspectableObject* object = impl().inspectedObject(exec->uncheckedArgument(0).toInt32(exec));
-    if (!object)
-        return jsUndefined();
-
-    JSLockHolder lock(exec);
-    Deprecated::ScriptValue scriptValue = object->get(exec);
-    if (scriptValue.hasNoValue())
-        return jsUndefined();
-
-    return scriptValue.jsValue();
-}
-
 JSValue JSInjectedScriptHost::internalConstructorName(ExecState* exec)
 {
     if (exec->argumentCount() < 1)
@@ -195,88 +168,6 @@ JSValue JSInjectedScriptHost::getInternalProperties(ExecState*)
     return jsUndefined();
 }
 
-static JSArray* getJSListenerFunctions(ExecState* exec, Document* document, const EventListenerInfo& listenerInfo)
-{
-    JSArray* result = constructEmptyArray(exec, 0);
-    size_t handlersCount = listenerInfo.eventListenerVector.size();
-    for (size_t i = 0, outputIndex = 0; i < handlersCount; ++i) {
-        const JSEventListener* jsListener = JSEventListener::cast(listenerInfo.eventListenerVector[i].listener.get());
-        if (!jsListener) {
-            ASSERT_NOT_REACHED();
-            continue;
-        }
-        // Hide listeners from other contexts.
-        if (&jsListener->isolatedWorld() != &currentWorld(exec))
-            continue;
-        JSObject* function = jsListener->jsFunction(document);
-        if (!function)
-            continue;
-        JSObject* listenerEntry = constructEmptyObject(exec);
-        listenerEntry->putDirect(exec->vm(), Identifier(exec, "listener"), function);
-        listenerEntry->putDirect(exec->vm(), Identifier(exec, "useCapture"), jsBoolean(listenerInfo.eventListenerVector[i].useCapture));
-        result->putDirectIndex(exec, outputIndex++, JSValue(listenerEntry));
-    }
-    return result;
-}
-
-JSValue JSInjectedScriptHost::getEventListeners(ExecState* exec)
-{
-    if (exec->argumentCount() < 1)
-        return jsUndefined();
-    JSValue value = exec->uncheckedArgument(0);
-    if (!value.isObject() || value.isNull())
-        return jsUndefined();
-    Node* node = toNode(value);
-    if (!node)
-        return jsUndefined();
-
-    Vector<EventListenerInfo> listenersArray;
-    impl().getEventListenersImpl(node, listenersArray);
-
-    JSObject* result = constructEmptyObject(exec);
-    for (size_t i = 0; i < listenersArray.size(); ++i) {
-        JSArray* listeners = getJSListenerFunctions(exec, &node->document(), listenersArray[i]);
-        if (!listeners->length())
-            continue;
-        AtomicString eventType = listenersArray[i].eventType;
-        result->putDirect(exec->vm(), Identifier(exec, eventType.impl()), JSValue(listeners));
-    }
-
-    return result;
-}
-
-JSValue JSInjectedScriptHost::inspect(ExecState* exec)
-{
-    if (exec->argumentCount() >= 2) {
-        Deprecated::ScriptValue object(exec->vm(), exec->uncheckedArgument(0));
-        Deprecated::ScriptValue hints(exec->vm(), exec->uncheckedArgument(1));
-        impl().inspectImpl(object.toInspectorValue(exec), hints.toInspectorValue(exec));
-    }
-    return jsUndefined();
-}
-
-JSValue JSInjectedScriptHost::databaseId(ExecState* exec)
-{
-    if (exec->argumentCount() < 1)
-        return jsUndefined();
-#if ENABLE(SQL_DATABASE)
-    Database* database = toDatabase(exec->uncheckedArgument(0));
-    if (database)
-        return jsStringWithCache(exec, impl().databaseIdImpl(database));
-#endif
-    return jsUndefined();
-}
-
-JSValue JSInjectedScriptHost::storageId(ExecState* exec)
-{
-    if (exec->argumentCount() < 1)
-        return jsUndefined();
-    Storage* storage = toStorage(exec->uncheckedArgument(0));
-    if (storage)
-        return jsStringWithCache(exec, impl().storageIdImpl(storage));
-    return jsUndefined();
-}
-
 JSValue JSInjectedScriptHost::evaluate(ExecState* exec) const
 {
     JSGlobalObject* globalObject = exec->lexicalGlobalObject();
diff --git a/Source/WebCore/inspector/CommandLineAPIHost.cpp b/Source/WebCore/inspector/CommandLineAPIHost.cpp
new file mode 100644 (file)
index 0000000..107242a
--- /dev/null
@@ -0,0 +1,166 @@
+/*
+ * Copyright (C) 2007, 2008 Apple Inc. All rights reserved.
+ * Copyright (C) 2008 Matt Lilek <webkit@mattlilek.com>
+ * Copyright (C) 2010 Google 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. ("Apple") 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 "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 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.
+ */
+
+#include "config.h"
+#include "CommandLineAPIHost.h"
+
+#if ENABLE(INSPECTOR)
+
+#include "Element.h"
+#include "Frame.h"
+#include "FrameLoader.h"
+#include "HTMLFrameOwnerElement.h"
+#include "InjectedScript.h"
+#include "InspectorAgent.h"
+#include "InspectorClient.h"
+#include "InspectorConsoleAgent.h"
+#include "InspectorDOMAgent.h"
+#include "InspectorDOMStorageAgent.h"
+#include "InspectorDatabaseAgent.h"
+#include "InspectorWebFrontendDispatchers.h"
+#include "Pasteboard.h"
+#include "Storage.h"
+#include "markup.h"
+#include <bindings/ScriptValue.h>
+#include <inspector/InspectorValues.h>
+#include <wtf/RefPtr.h>
+#include <wtf/StdLibExtras.h>
+
+#if ENABLE(SQL_DATABASE)
+#include "Database.h"
+#endif
+
+using namespace Inspector;
+
+namespace WebCore {
+
+PassRefPtr<CommandLineAPIHost> CommandLineAPIHost::create()
+{
+    return adoptRef(new CommandLineAPIHost);
+}
+
+CommandLineAPIHost::CommandLineAPIHost()
+    : m_inspectorAgent(nullptr)
+    , m_consoleAgent(nullptr)
+    , m_domAgent(nullptr)
+    , m_domStorageAgent(nullptr)
+#if ENABLE(SQL_DATABASE)
+    , m_databaseAgent(nullptr)
+#endif
+{
+    m_defaultInspectableObject = adoptPtr(new InspectableObject);
+}
+
+CommandLineAPIHost::~CommandLineAPIHost()
+{
+}
+
+void CommandLineAPIHost::disconnect()
+{
+    m_inspectorAgent = nullptr;
+    m_consoleAgent = nullptr;
+    m_domAgent = nullptr;
+    m_domStorageAgent = nullptr;
+#if ENABLE(SQL_DATABASE)
+    m_databaseAgent = nullptr;
+#endif
+}
+
+void CommandLineAPIHost::inspectImpl(PassRefPtr<InspectorValue> object, PassRefPtr<InspectorValue> hints)
+{
+    if (m_inspectorAgent) {
+        RefPtr<Inspector::TypeBuilder::Runtime::RemoteObject> remoteObject = Inspector::TypeBuilder::Runtime::RemoteObject::runtimeCast(object);
+        m_inspectorAgent->inspect(remoteObject, hints->asObject());
+    }
+}
+
+void CommandLineAPIHost::getEventListenersImpl(Node* node, Vector<EventListenerInfo>& listenersArray)
+{
+    if (m_domAgent)
+        m_domAgent->getEventListeners(node, listenersArray, false);
+}
+
+void CommandLineAPIHost::clearConsoleMessages()
+{
+    if (m_consoleAgent) {
+        ErrorString error;
+        m_consoleAgent->clearMessages(&error);
+    }
+}
+
+void CommandLineAPIHost::copyText(const String& text)
+{
+    Pasteboard::createForCopyAndPaste()->writePlainText(text, Pasteboard::CannotSmartReplace);
+}
+
+Deprecated::ScriptValue CommandLineAPIHost::InspectableObject::get(JSC::ExecState*)
+{
+    return Deprecated::ScriptValue();
+};
+
+void CommandLineAPIHost::addInspectedObject(PassOwnPtr<CommandLineAPIHost::InspectableObject> object)
+{
+    m_inspectedObjects.insert(0, object);
+    while (m_inspectedObjects.size() > 5)
+        m_inspectedObjects.removeLast();
+}
+
+void CommandLineAPIHost::clearInspectedObjects()
+{
+    m_inspectedObjects.clear();
+}
+
+CommandLineAPIHost::InspectableObject* CommandLineAPIHost::inspectedObject(unsigned index)
+{
+    if (index >= m_inspectedObjects.size())
+        return m_defaultInspectableObject.get();
+
+    return m_inspectedObjects[index].get();
+}
+
+#if ENABLE(SQL_DATABASE)
+String CommandLineAPIHost::databaseIdImpl(Database* database)
+{
+    if (m_databaseAgent)
+        return m_databaseAgent->databaseId(database);
+    return String();
+}
+#endif
+
+String CommandLineAPIHost::storageIdImpl(Storage* storage)
+{
+    if (m_domStorageAgent)
+        return m_domStorageAgent->storageId(storage);
+    return String();
+}
+
+} // namespace WebCore
+
+#endif // ENABLE(INSPECTOR)
diff --git a/Source/WebCore/inspector/CommandLineAPIHost.h b/Source/WebCore/inspector/CommandLineAPIHost.h
new file mode 100644 (file)
index 0000000..bc3fd2c
--- /dev/null
@@ -0,0 +1,125 @@
+/*
+ * Copyright (C) 2007, 2013 Apple Inc. All rights reserved.
+ * Copyright (C) 2009 Google 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. ("Apple") 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 "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 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.
+ */
+
+#ifndef CommandLineAPIHost_h
+#define CommandLineAPIHost_h
+
+#include "ConsoleTypes.h"
+#include "InspectorAgent.h"
+#include "ScriptState.h"
+#include <wtf/RefCounted.h>
+#include <wtf/Vector.h>
+
+namespace Deprecated {
+class ScriptValue;
+}
+
+namespace Inspector {
+class InspectorObject;
+class InspectorValue;
+}
+
+namespace WebCore {
+
+class Database;
+class InjectedScript;
+class InspectorAgent;
+class InspectorConsoleAgent;
+class InspectorDOMAgent;
+class InspectorDOMStorageAgent;
+class InspectorDatabaseAgent;
+class Node;
+class Storage;
+
+struct EventListenerInfo;
+
+class CommandLineAPIHost : public RefCounted<CommandLineAPIHost> {
+public:
+    static PassRefPtr<CommandLineAPIHost> create();
+    ~CommandLineAPIHost();
+
+    void init(InspectorAgent* inspectorAgent
+            , InspectorConsoleAgent* consoleAgent
+            , InspectorDOMAgent* domAgent
+            , InspectorDOMStorageAgent* domStorageAgent
+#if ENABLE(SQL_DATABASE)
+            , InspectorDatabaseAgent* databaseAgent
+#endif
+        )
+    {
+        m_inspectorAgent = inspectorAgent;
+        m_consoleAgent = consoleAgent;
+        m_domAgent = domAgent;
+        m_domStorageAgent = domStorageAgent;
+#if ENABLE(SQL_DATABASE)
+        m_databaseAgent = databaseAgent;
+#endif
+    }
+
+    void disconnect();
+
+    void clearConsoleMessages();
+    void copyText(const String& text);
+
+    class InspectableObject {
+        WTF_MAKE_FAST_ALLOCATED;
+    public:
+        virtual Deprecated::ScriptValue get(JSC::ExecState*);
+        virtual ~InspectableObject() { }
+    };
+    void addInspectedObject(PassOwnPtr<InspectableObject>);
+    void clearInspectedObjects();
+    InspectableObject* inspectedObject(unsigned index);
+    void inspectImpl(PassRefPtr<Inspector::InspectorValue> objectToInspect, PassRefPtr<Inspector::InspectorValue> hints);
+
+    void getEventListenersImpl(Node*, Vector<EventListenerInfo>& listenersArray);
+
+#if ENABLE(SQL_DATABASE)
+    String databaseIdImpl(Database*);
+#endif
+    String storageIdImpl(Storage*);
+
+private:
+    CommandLineAPIHost();
+
+    InspectorAgent* m_inspectorAgent;
+    InspectorConsoleAgent* m_consoleAgent;
+    InspectorDOMAgent* m_domAgent;
+    InspectorDOMStorageAgent* m_domStorageAgent;
+#if ENABLE(SQL_DATABASE)
+    InspectorDatabaseAgent* m_databaseAgent;
+#endif
+
+    Vector<OwnPtr<InspectableObject>> m_inspectedObjects;
+    OwnPtr<InspectableObject> m_defaultInspectableObject;
+};
+
+} // namespace WebCore
+
+#endif // !defined(CommandLineAPIHost_h)
diff --git a/Source/WebCore/inspector/CommandLineAPIHost.idl b/Source/WebCore/inspector/CommandLineAPIHost.idl
new file mode 100644 (file)
index 0000000..228426c
--- /dev/null
@@ -0,0 +1,45 @@
+/*
+ * Copyright (C) 2007, 2008, 2013 Apple Inc. All rights reserved.
+ * Copyright (C) 2008 Matt Lilek <webkit@mattlilek.com>
+ * Copyright (C) 2010 Google 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:
+ *
+ *     * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *     * 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.
+ *     * Neither the name of Google Inc. 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 THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "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 THE COPYRIGHT
+ * OWNER 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.
+ */
+
+[
+    NoInterfaceObject,
+    Conditional=INSPECTOR,
+    ImplementationLacksVTable
+] interface CommandLineAPIHost {
+    void clearConsoleMessages();
+    void copyText(DOMString text);
+    [Custom] void inspect(any objectId, any hints);
+    [Custom] any inspectedObject(int num);
+    [Custom] Array getEventListeners(Node node);
+    [Custom] DOMString databaseId(any database);
+    [Custom] DOMString storageId(any storage);
+};
index 2502d2f..95339e1 100644 (file)
@@ -29,6 +29,9 @@
 #if ENABLE(INSPECTOR)
 
 #include "CommandLineAPIModuleSource.h"
+#include "JSCommandLineAPIHost.h"
+
+using namespace JSC;
 
 namespace WebCore {
 
@@ -48,6 +51,13 @@ String CommandLineAPIModule::source() const
     return String(reinterpret_cast<const char*>(CommandLineAPIModuleSource_js), sizeof(CommandLineAPIModuleSource_js));
 }
 
+JSC::JSValue CommandLineAPIModule::host(InjectedScriptManager* injectedScriptManager, JSC::ExecState* exec) const
+{
+    ASSERT(injectedScriptManager->commandLineAPIHost());
+    JSDOMGlobalObject* globalObject = jsCast<JSDOMGlobalObject*>(exec->lexicalGlobalObject());
+    return toJS(exec, globalObject, injectedScriptManager->commandLineAPIHost());
+}
+
 } // namespace WebCore
 
 #endif // ENABLE(INSPECTOR)
index 75e3163..b4a5af4 100644 (file)
@@ -37,6 +37,7 @@ public:
     CommandLineAPIModule();
 
     virtual String source() const OVERRIDE;
+    virtual JSC::JSValue host(InjectedScriptManager*, JSC::ExecState*) const OVERRIDE;
     virtual bool returnsObject() const OVERRIDE { return false; }
 
     static void injectIfNeeded(InjectedScriptManager*, InjectedScript);
index 7a2c5ae..0e8bacc 100644 (file)
  * @param {InjectedScriptHost} InjectedScriptHost
  * @param {Window} inspectedWindow
  * @param {number} injectedScriptId
+ * @param {InjectedScript} injectedScript
+ * @param {CommandLineAPIHost} CommandLineAPIHost
  */
-(function (InjectedScriptHost, inspectedWindow, injectedScriptId, injectedScript) {
+(function (InjectedScriptHost, inspectedWindow, injectedScriptId, injectedScript, CommandLineAPIHost) {
 
 /**
  * @param {Arguments} array
@@ -272,19 +274,19 @@ CommandLineAPIImpl.prototype = {
      */
     inspect: function(object)
     {
-        return injectedScript._inspect(object);
+        return this._inspect(object);
     },
 
     copy: function(object)
     {
         if (injectedScript._subtype(object) === "node")
             object = object.outerHTML;
-        InjectedScriptHost.copyText(object);
+        CommandLineAPIHost.copyText(object);
     },
 
     clear: function()
     {
-        InjectedScriptHost.clearConsoleMessages();
+        CommandLineAPIHost.clearConsoleMessages();
     },
 
     /**
@@ -292,7 +294,7 @@ CommandLineAPIImpl.prototype = {
      */
     getEventListeners: function(node)
     {
-        return InjectedScriptHost.getEventListeners(node);
+        return CommandLineAPIHost.getEventListeners(node);
     },
 
     /**
@@ -300,7 +302,7 @@ CommandLineAPIImpl.prototype = {
      */
     _inspectedObject: function(num)
     {
-        return InjectedScriptHost.inspectedObject(num);
+        return CommandLineAPIHost.inspectedObject(num);
     },
 
     /**
@@ -336,6 +338,35 @@ CommandLineAPIImpl.prototype = {
     _logEvent: function(event)
     {
         inspectedWindow.console.log(event.type, event);
+    },
+
+    /**
+     * @param {*} object
+     * @return {*}
+     */
+    _inspect: function(object)
+    {
+        if (arguments.length === 0)
+            return;
+
+        var objectId = injectedScript._wrapObject(object, "");
+        var hints = {};
+
+        switch (injectedScript._describe(object)) {
+        case "Database":
+            var databaseId = CommandLineAPIHost.databaseId(object)
+            if (databaseId)
+                hints.databaseId = databaseId;
+            break;
+        case "Storage":
+            var storageId = CommandLineAPIHost.storageId(object)
+            if (storageId)
+                hints.domStorageId = InjectedScriptHost.evaluate("(" + storageId + ")");
+            break;
+        }
+
+        CommandLineAPIHost.inspect(objectId, hints);
+        return object;
     }
 }
 
index 58be739..f250214 100644 (file)
@@ -49,6 +49,7 @@ using Inspector::TypeBuilder::Canvas::ResourceState;
 using Inspector::TypeBuilder::Canvas::TraceLog;
 using Inspector::TypeBuilder::Canvas::TraceLogId;
 
+using namespace JSC;
 using namespace Inspector;
 
 namespace WebCore {
@@ -70,6 +71,11 @@ String InjectedScriptCanvasModule::source() const
     return String(reinterpret_cast<const char*>(InjectedScriptCanvasModuleSource_js), sizeof(InjectedScriptCanvasModuleSource_js));
 }
 
+JSC::JSValue InjectedScriptCanvasModule::host(InjectedScriptManager*, JSC::ExecState*) const
+{
+    return jsUndefined();
+}
+
 Deprecated::ScriptObject InjectedScriptCanvasModule::wrapCanvas2DContext(const Deprecated::ScriptObject& context)
 {
     return callWrapContextFunction("wrapCanvas2DContext", context);
index 501d2e6..2c44369 100644 (file)
@@ -45,12 +45,13 @@ class InjectedScriptManager;
 
 #if ENABLE(INSPECTOR)
 
-class InjectedScriptCanvasModule : public InjectedScriptModule {
+class InjectedScriptCanvasModule FINAL : public InjectedScriptModule {
 public:
     InjectedScriptCanvasModule();
     
-    virtual String source() const;
-    virtual bool returnsObject() const { return true; }
+    virtual String source() const OVERRIDE;
+    virtual JSC::JSValue host(InjectedScriptManager*, JSC::ExecState*) const OVERRIDE;
+    virtual bool returnsObject() const OVERRIDE { return true; }
 
     static InjectedScriptCanvasModule moduleForState(InjectedScriptManager*, JSC::ExecState*);
 
index 07c76e4..c2399e0 100644 (file)
  */
 
 #include "config.h"
-
-#if ENABLE(INSPECTOR)
-
 #include "InjectedScriptHost.h"
 
-#include "Element.h"
-#include "Frame.h"
-#include "FrameLoader.h"
-#include "HTMLFrameOwnerElement.h"
-#include "InjectedScript.h"
-#include "InspectorAgent.h"
-#include "InspectorClient.h"
-#include "InspectorConsoleAgent.h"
-#include "InspectorDOMAgent.h"
-#include "InspectorDOMStorageAgent.h"
-#include "InspectorDatabaseAgent.h"
-#include "InspectorWebFrontendDispatchers.h"
-#include "Pasteboard.h"
-#include "Storage.h"
-#include "markup.h"
-#include <bindings/ScriptValue.h>
-#include <inspector/InspectorValues.h>
-#include <wtf/RefPtr.h>
-#include <wtf/StdLibExtras.h>
-
-#if ENABLE(SQL_DATABASE)
-#include "Database.h"
-#endif
-
-using namespace Inspector;
+#if ENABLE(INSPECTOR)
 
 namespace WebCore {
 
 PassRefPtr<InjectedScriptHost> InjectedScriptHost::create()
 {
-    return adoptRef(new InjectedScriptHost());
-}
-
-InjectedScriptHost::InjectedScriptHost()
-    : m_inspectorAgent(0)
-    , m_consoleAgent(0)
-#if ENABLE(SQL_DATABASE)
-    , m_databaseAgent(0)
-#endif
-    , m_domStorageAgent(0)
-    , m_domAgent(0)
-{
-    m_defaultInspectableObject = adoptPtr(new InspectableObject());
-}
-
-InjectedScriptHost::~InjectedScriptHost()
-{
-}
-
-void InjectedScriptHost::disconnect()
-{
-    m_inspectorAgent = 0;
-    m_consoleAgent = 0;
-#if ENABLE(SQL_DATABASE)
-    m_databaseAgent = 0;
-#endif
-    m_domStorageAgent = 0;
-    m_domAgent = 0;
-}
-
-void InjectedScriptHost::inspectImpl(PassRefPtr<InspectorValue> object, PassRefPtr<InspectorValue> hints)
-{
-    if (m_inspectorAgent) {
-        RefPtr<Inspector::TypeBuilder::Runtime::RemoteObject> remoteObject = Inspector::TypeBuilder::Runtime::RemoteObject::runtimeCast(object);
-        m_inspectorAgent->inspect(remoteObject, hints->asObject());
-    }
-}
-
-void InjectedScriptHost::getEventListenersImpl(Node* node, Vector<EventListenerInfo>& listenersArray)
-{
-    if (m_domAgent)
-        m_domAgent->getEventListeners(node, listenersArray, false);
-}
-
-void InjectedScriptHost::clearConsoleMessages()
-{
-    if (m_consoleAgent) {
-        ErrorString error;
-        m_consoleAgent->clearMessages(&error);
-    }
-}
-
-void InjectedScriptHost::copyText(const String& text)
-{
-    Pasteboard::createForCopyAndPaste()->writePlainText(text, Pasteboard::CannotSmartReplace);
-}
-
-Deprecated::ScriptValue InjectedScriptHost::InspectableObject::get(JSC::ExecState*)
-{
-    return Deprecated::ScriptValue();
-};
-
-void InjectedScriptHost::addInspectedObject(PassOwnPtr<InjectedScriptHost::InspectableObject> object)
-{
-    m_inspectedObjects.insert(0, object);
-    while (m_inspectedObjects.size() > 5)
-        m_inspectedObjects.removeLast();
-}
-
-void InjectedScriptHost::clearInspectedObjects()
-{
-    m_inspectedObjects.clear();
-}
-
-InjectedScriptHost::InspectableObject* InjectedScriptHost::inspectedObject(unsigned int num)
-{
-    if (num >= m_inspectedObjects.size())
-        return m_defaultInspectableObject.get();
-    return m_inspectedObjects[num].get();
-}
-
-#if ENABLE(SQL_DATABASE)
-String InjectedScriptHost::databaseIdImpl(Database* database)
-{
-    if (m_databaseAgent)
-        return m_databaseAgent->databaseId(database);
-    return String();
-}
-#endif
-
-String InjectedScriptHost::storageIdImpl(Storage* storage)
-{
-    if (m_domStorageAgent)
-        return m_domStorageAgent->storageId(storage);
-    return String();
+    return adoptRef(new InjectedScriptHost);
 }
 
 } // namespace WebCore
index 119a450..a5097c6 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2007 Apple Inc. All rights reserved.
+ * Copyright (C) 2007, 2013 Apple Inc. All rights reserved.
  * Copyright (C) 2009 Google Inc. All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -7,13 +7,13 @@
  * are met:
  *
  * 1.  Redistributions of source code must retain the above copyright
- *     notice, this list of conditions and the following disclaimer. 
+ *     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. 
+ *     documentation and/or other materials provided with the distribution.
  * 3.  Neither the name of Apple Computer, Inc. ("Apple") nor the names of
  *     its contributors may be used to endorse or promote products derived
- *     from this software without specific prior written permission. 
+ *     from this software without specific prior written permission.
  *
  * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
  * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
 #ifndef InjectedScriptHost_h
 #define InjectedScriptHost_h
 
-#include "ConsoleTypes.h"
-#include "InspectorAgent.h"
 #include "ScriptState.h"
+#include <wtf/PassRefPtr.h>
 #include <wtf/RefCounted.h>
-#include <wtf/Vector.h>
 
 namespace Deprecated {
 class ScriptValue;
 }
 
-namespace Inspector {
-class InspectorObject;
-class InspectorValue;
-}
-
 namespace WebCore {
 
-class Database;
-class InjectedScript;
-class InspectorAgent;
-class InspectorConsoleAgent;
-class InspectorDOMAgent;
-class InspectorDOMStorageAgent;
-class InspectorDatabaseAgent;
 class Node;
-class Storage;
-
-struct EventListenerInfo;
 
 class InjectedScriptHost : public RefCounted<InjectedScriptHost> {
 public:
     static PassRefPtr<InjectedScriptHost> create();
-    ~InjectedScriptHost();
-
-    void init(InspectorAgent* inspectorAgent
-            , InspectorConsoleAgent* consoleAgent
-#if ENABLE(SQL_DATABASE)
-            , InspectorDatabaseAgent* databaseAgent
-#endif
-            , InspectorDOMStorageAgent* domStorageAgent
-            , InspectorDOMAgent* domAgent
-        )
-    {
-        m_inspectorAgent = inspectorAgent;
-        m_consoleAgent = consoleAgent;
-#if ENABLE(SQL_DATABASE)
-        m_databaseAgent = databaseAgent;
-#endif
-        m_domStorageAgent = domStorageAgent;
-        m_domAgent = domAgent;
-    }
+    ~InjectedScriptHost() { }
 
     static Node* scriptValueAsNode(Deprecated::ScriptValue);
     static Deprecated::ScriptValue nodeAsScriptValue(JSC::ExecState*, Node*);
 
-    void disconnect();
-
-    class InspectableObject {
-        WTF_MAKE_FAST_ALLOCATED;
-    public:
-        virtual Deprecated::ScriptValue get(JSC::ExecState*);
-        virtual ~InspectableObject() { }
-    };
-    void addInspectedObject(PassOwnPtr<InspectableObject>);
-    void clearInspectedObjects();
-    InspectableObject* inspectedObject(unsigned int num);
-
-    void inspectImpl(PassRefPtr<Inspector::InspectorValue> objectToInspect, PassRefPtr<Inspector::InspectorValue> hints);
-    void getEventListenersImpl(Node*, Vector<EventListenerInfo>& listenersArray);
-
-    void clearConsoleMessages();
-    void copyText(const String& text);
-#if ENABLE(SQL_DATABASE)
-    String databaseIdImpl(Database*);
-#endif
-    String storageIdImpl(Storage*);
-
 private:
-    InjectedScriptHost();
-
-    InspectorAgent* m_inspectorAgent;
-    InspectorConsoleAgent* m_consoleAgent;
-#if ENABLE(SQL_DATABASE)
-    InspectorDatabaseAgent* m_databaseAgent;
-#endif
-    InspectorDOMStorageAgent* m_domStorageAgent;
-    InspectorDOMAgent* m_domAgent;
-    Vector<OwnPtr<InspectableObject>> m_inspectedObjects;
-    OwnPtr<InspectableObject> m_defaultInspectableObject;
+    InjectedScriptHost() { }
 };
 
 } // namespace WebCore
index d8663ed..6a88a6b 100644 (file)
     Conditional=INSPECTOR,
     ImplementationLacksVTable
 ] interface InjectedScriptHost {
-    void clearConsoleMessages();
-
-    void copyText(DOMString text);
-    [Custom] void inspect(any objectId, any hints);
-    [Custom] any inspectedObject(int num);
     [Custom] any internalConstructorName(any object);
     [Custom] boolean isHTMLAllCollection(any object);
     [Custom] DOMString type(any object);
     [Custom] any functionDetails(any object);
     [Custom] Array getInternalProperties(any object);
-    [Custom] Array getEventListeners(Node node);
 
     [Custom] readonly attribute any evaluate;
-
-    [Custom] DOMString databaseId(any database);
-    [Custom] DOMString storageId(any storage);
 };
index cb86483..d9e999a 100644 (file)
@@ -69,7 +69,6 @@ InjectedScriptManager::~InjectedScriptManager()
 
 void InjectedScriptManager::disconnect()
 {
-    m_injectedScriptHost->disconnect();
     m_injectedScriptHost.clear();
 }
 
index d61fd28..133b1da 100644 (file)
@@ -51,6 +51,7 @@ namespace WebCore {
 class DOMWindow;
 class InjectedScript;
 class InjectedScriptHost;
+class CommandLineAPIHost;
 
 class InjectedScriptManager {
     WTF_MAKE_NONCOPYABLE(InjectedScriptManager); WTF_MAKE_FAST_ALLOCATED;
@@ -59,9 +60,10 @@ public:
     static PassOwnPtr<InjectedScriptManager> createForWorker();
     virtual ~InjectedScriptManager();
 
-    void disconnect();
+    virtual void disconnect();
 
     InjectedScriptHost* injectedScriptHost();
+    virtual CommandLineAPIHost* commandLineAPIHost() const { return nullptr; }
 
     InjectedScript injectedScriptFor(JSC::ExecState*);
     InjectedScript injectedScriptForId(int);
index 0797b78..ecc9797 100644 (file)
@@ -71,6 +71,7 @@ void InjectedScriptModule::ensureInjected(InjectedScriptManager* injectedScriptM
         Deprecated::ScriptFunctionCall function(injectedScript.injectedScriptObject(), "injectModule", WebCore::functionCallHandlerFromAnyThread);
         function.appendArgument(name());
         function.appendArgument(source());
+        function.appendArgument(host(injectedScriptManager, injectedScript.scriptState()));
         resultValue = injectedScript.callFunctionWithEvalEnabled(function, hadException);
         if (hadException || (returnsObject() && (resultValue.hasNoValue() || !resultValue.isObject()))) {
             ASSERT_NOT_REACHED();
index feba346..73517d5 100644 (file)
 
 #if ENABLE(INSPECTOR)
 
+namespace JSC {
+class JSValue;
+}
+
 namespace WebCore {
 
 class InjectedScriptManager;
@@ -45,6 +49,7 @@ class InjectedScriptManager;
 class InjectedScriptModule : public InjectedScriptBase {
 public:
     virtual String source() const = 0;
+    virtual JSC::JSValue host(InjectedScriptManager*, JSC::ExecState*) const = 0;
     virtual bool returnsObject() const = 0;
 
 protected:
index 20646c3..9c88c73 100644 (file)
@@ -127,35 +127,8 @@ InjectedScript.prototype = {
      */
     inspectNode: function(object)
     {
-        this._inspect(object);
-    },
-
-    /**
-     * @param {*} object
-     * @return {*}
-     */
-    _inspect: function(object)
-    {
-        if (arguments.length === 0)
-            return;
-
-        var objectId = this._wrapObject(object, "");
-        var hints = {};
-
-        switch (injectedScript._describe(object)) {
-            case "Database":
-                var databaseId = InjectedScriptHost.databaseId(object)
-                if (databaseId)
-                    hints.databaseId = databaseId;
-                break;
-            case "Storage":
-                var storageId = InjectedScriptHost.storageId(object)
-                if (storageId)
-                    hints.domStorageId = InjectedScriptHost.evaluate("(" + storageId + ")");
-                break;
-        }
-        InjectedScriptHost.inspect(objectId, hints);
-        return object;
+        if (this._commandLineAPIImpl)
+            this._commandLineAPIImpl.inspect(object);
     },
 
     /**
@@ -694,7 +667,7 @@ InjectedScript.prototype = {
      * @param {string} source
      * @return {Object}
      */
-    injectModule: function(name, source)
+    injectModule: function(name, source, host)
     {
         delete this._modules[name];
         var moduleFunction = InjectedScriptHost.evaluate("(" + source + ")");
@@ -704,7 +677,7 @@ InjectedScript.prototype = {
                 inspectedGlobalObject.console.error("Web Inspector error: A function was expected for module %s evaluation", name);
             return null;
         }
-        var module = moduleFunction.call(inspectedGlobalObject, InjectedScriptHost, inspectedGlobalObject, injectedScriptId, this);
+        var module = moduleFunction.call(inspectedGlobalObject, InjectedScriptHost, inspectedGlobalObject, injectedScriptId, this, host);
         this._modules[name] = module;
         return module;
     },
index 019c295..28a409e 100644 (file)
 
 #include "InspectorConsoleAgent.h"
 
+#include "CommandLineAPIHost.h"
 #include "Console.h"
 #include "ConsoleMessage.h"
 #include "DOMWindow.h"
-#include "InjectedScriptHost.h"
 #include "InjectedScriptManager.h"
 #include "InspectorWebFrontendDispatchers.h"
 #include "InstrumentingAgents.h"
@@ -319,10 +319,10 @@ void InspectorConsoleAgent::addConsoleMessage(PassOwnPtr<ConsoleMessage> console
     }
 }
 
-class InspectableHeapObject : public InjectedScriptHost::InspectableObject {
+class InspectableHeapObject FINAL : public CommandLineAPIHost::InspectableObject {
 public:
     explicit InspectableHeapObject(int heapObjectId) : m_heapObjectId(heapObjectId) { }
-    virtual Deprecated::ScriptValue get(JSC::ExecState*)
+    virtual Deprecated::ScriptValue get(JSC::ExecState*) OVERRIDE
     {
         return ScriptProfiler::objectByHeapObjectId(m_heapObjectId);
     }
@@ -332,7 +332,8 @@ private:
 
 void InspectorConsoleAgent::addInspectedHeapObject(ErrorString*, int inspectedHeapObjectId)
 {
-    m_injectedScriptManager->injectedScriptHost()->addInspectedObject(adoptPtr(new InspectableHeapObject(inspectedHeapObjectId)));
+    if (CommandLineAPIHost* commandLineAPIHost = m_injectedScriptManager->commandLineAPIHost())
+        commandLineAPIHost->addInspectedObject(adoptPtr(new InspectableHeapObject(inspectedHeapObjectId)));
 }
 
 } // namespace WebCore
index b62c4a6..b2986dc 100644 (file)
@@ -34,6 +34,7 @@
 
 #include "InspectorController.h"
 
+#include "CommandLineAPIHost.h"
 #include "DOMWrapperWorld.h"
 #include "GraphicsContext.h"
 #include "IdentifiersFactory.h"
@@ -89,6 +90,8 @@ InspectorController::InspectorController(Page* page, InspectorClient* inspectorC
     , m_hasRemoteFrontend(false)
 #endif
 {
+    ASSERT_ARG(inspectorClient, inspectorClient);
+
     OwnPtr<InspectorAgent> inspectorAgentPtr(InspectorAgent::create(page, m_instrumentingAgents.get()));
     m_inspectorAgent = inspectorAgentPtr.get();
     m_agents.append(inspectorAgentPtr.release());
@@ -164,15 +167,17 @@ InspectorController::InspectorController(Page* page, InspectorClient* inspectorC
     m_agents.append(InspectorLayerTreeAgent::create(m_instrumentingAgents.get()));
 #endif
 
-    ASSERT_ARG(inspectorClient, inspectorClient);
-    m_injectedScriptManager->injectedScriptHost()->init(m_inspectorAgent
-        , consoleAgent
+    ASSERT(m_injectedScriptManager->commandLineAPIHost());
+    if (CommandLineAPIHost* commandLineAPIHost = m_injectedScriptManager->commandLineAPIHost()) {
+        commandLineAPIHost->init(m_inspectorAgent
+            , consoleAgent
+            , m_domAgent
+            , domStorageAgent
 #if ENABLE(SQL_DATABASE)
-        , databaseAgent
+            , databaseAgent
 #endif
-        , domStorageAgent
-        , m_domAgent
-    );
+        );
+    }
 
 #if ENABLE(JAVASCRIPT_DEBUGGER)
     runtimeAgent->setScriptDebugServer(&m_debuggerAgent->scriptDebugServer());
index 7b788ab..25c9738 100644 (file)
  */
 
 #include "config.h"
+#include "InspectorHeapProfilerAgent.h"
 
 #if ENABLE(JAVASCRIPT_DEBUGGER) && ENABLE(INSPECTOR)
 
-#include "InspectorHeapProfilerAgent.h"
-
+#include "CommandLineAPIHost.h"
 #include "InjectedScript.h"
 #include "InjectedScriptHost.h"
 #include "InstrumentingAgents.h"
@@ -69,7 +69,9 @@ void InspectorHeapProfilerAgent::resetState()
     m_snapshots.clear();
     m_nextUserInitiatedHeapSnapshotNumber = 1;
     resetFrontendProfiles();
-    m_injectedScriptManager->injectedScriptHost()->clearInspectedObjects();
+
+    if (CommandLineAPIHost* commandLineAPIHost = m_injectedScriptManager->commandLineAPIHost())
+        commandLineAPIHost->clearInspectedObjects();
 }
 
 void InspectorHeapProfilerAgent::resetFrontendProfiles()
index f77e014..aa786dd 100644 (file)
@@ -33,6 +33,7 @@
 
 #include "InspectorProfilerAgent.h"
 
+#include "CommandLineAPIHost.h"
 #include "Console.h"
 #include "ConsoleAPITypes.h"
 #include "ConsoleTypes.h"
@@ -316,7 +317,9 @@ void InspectorProfilerAgent::resetState()
     m_nextUserInitiatedProfileNumber = 1;
     m_nextUserInitiatedHeapSnapshotNumber = 1;
     resetFrontendProfiles();
-    m_injectedScriptManager->injectedScriptHost()->clearInspectedObjects();
+
+    if (CommandLineAPIHost* commandLineAPIHost = m_injectedScriptManager->commandLineAPIHost())
+        commandLineAPIHost->clearInspectedObjects();
 }
 
 void InspectorProfilerAgent::resetFrontendProfiles()
index ceabbd2..97d68d3 100644 (file)
@@ -34,6 +34,7 @@
 
 #include "PageConsoleAgent.h"
 
+#include "CommandLineAPIHost.h"
 #include "DOMWindow.h"
 #include "InjectedScriptHost.h"
 #include "InjectedScriptManager.h"
@@ -64,10 +65,10 @@ void PageConsoleAgent::clearMessages(ErrorString* errorString)
     InspectorConsoleAgent::clearMessages(errorString);
 }
 
-class InspectableNode : public InjectedScriptHost::InspectableObject {
+class InspectableNode FINAL : public CommandLineAPIHost::InspectableObject {
 public:
     explicit InspectableNode(Node* node) : m_node(node) { }
-    virtual Deprecated::ScriptValue get(JSC::ExecState* state)
+    virtual Deprecated::ScriptValue get(JSC::ExecState* state) OVERRIDE
     {
         return InjectedScriptHost::nodeAsScriptValue(state, m_node);
     }
@@ -79,10 +80,12 @@ void PageConsoleAgent::addInspectedNode(ErrorString* errorString, int nodeId)
 {
     Node* node = m_inspectorDOMAgent->nodeForId(nodeId);
     if (!node || node->isInShadowTree()) {
-        *errorString = "nodeId is not valid";
+        *errorString = ASCIILiteral("nodeId is not valid");
         return;
     }
-    m_injectedScriptManager->injectedScriptHost()->addInspectedObject(adoptPtr(new InspectableNode(node)));
+
+    if (CommandLineAPIHost* commandLineAPIHost = m_injectedScriptManager->commandLineAPIHost())
+        commandLineAPIHost->addInspectedObject(adoptPtr(new InspectableNode(node)));
 }
 
 bool PageConsoleAgent::developerExtrasEnabled()
index be55179..3432b0c 100644 (file)
 #include "CommandLineAPIModule.h"
 
 namespace WebCore {
+    
+PageInjectedScriptManager::PageInjectedScriptManager(InspectedStateAccessCheck accessCheck)
+    : InjectedScriptManager(accessCheck)
+    , m_commandLineAPIHost(CommandLineAPIHost::create())
+{
+}
+
+void PageInjectedScriptManager::disconnect()
+{
+    InjectedScriptManager::disconnect();
+
+    m_commandLineAPIHost->disconnect();
+    m_commandLineAPIHost.clear();
+}
 
 void PageInjectedScriptManager::didCreateInjectedScript(InjectedScript injectedScript)
 {
index adfbe87..884b3ac 100644 (file)
 #ifndef PageInjectedScriptManager_h
 #define PageInjectedScriptManager_h
 
+#include "CommandLineAPIHost.h"
 #include "InjectedScriptManager.h"
+#include <wtf/RefPtr.h>
 
 namespace WebCore {
 
 class PageInjectedScriptManager FINAL : public InjectedScriptManager {
 public:
-    explicit PageInjectedScriptManager(InspectedStateAccessCheck accessCheck) : InjectedScriptManager(accessCheck) { }
+    explicit PageInjectedScriptManager(InspectedStateAccessCheck);
     virtual ~PageInjectedScriptManager() { }
 
+    virtual void disconnect() OVERRIDE;
+    virtual CommandLineAPIHost* commandLineAPIHost() const OVERRIDE { return m_commandLineAPIHost.get(); }
+
 protected:
     virtual void didCreateInjectedScript(InjectedScript) OVERRIDE;
+
+private:
+    RefPtr<CommandLineAPIHost> m_commandLineAPIHost;
 };
 
 } // namespace WebCore
index dfff3f8..e4fb554 100644 (file)
@@ -34,6 +34,7 @@
 
 #include "WorkerInspectorController.h"
 
+#include "CommandLineAPIHost.h"
 #include "InjectedScriptHost.h"
 #include "InjectedScriptManager.h"
 #include "InspectorClient.h"
@@ -98,14 +99,16 @@ WorkerInspectorController::WorkerInspectorController(WorkerGlobalScope* workerGl
     m_agents.append(InspectorTimelineAgent::create(m_instrumentingAgents.get(), 0, 0, InspectorTimelineAgent::WorkerInspector, 0));
     m_agents.append(consoleAgent.release());
 
-    m_injectedScriptManager->injectedScriptHost()->init(0
-        , 0
+    if (CommandLineAPIHost* commandLineAPIHost = m_injectedScriptManager->commandLineAPIHost()) {
+        commandLineAPIHost->init(nullptr
+            , nullptr
+            , nullptr
+            , nullptr
 #if ENABLE(SQL_DATABASE)
-        , 0
+            , nullptr
 #endif
-        , 0
-        , 0
-    );
+        );
+    }
 }
  
 WorkerInspectorController::~WorkerInspectorController()