Web Inspector: Extract CommandLineAPI into its own InjectedScriptModule
authorjoepeck@webkit.org <joepeck@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 20 Dec 2013 22:04:28 +0000 (22:04 +0000)
committerjoepeck@webkit.org <joepeck@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 20 Dec 2013 22:04:28 +0000 (22:04 +0000)
commit265a37cb4b7cc15c1f946d47884e07df0bb3806f
tree170eb89db664b63015dba915c9397db58fcba4f1
parent244bcda52ece2cf9826c1c1f8faea7cf67df3e35
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 "$_",
which is the "last evaluated result". 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 "window" 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 "window" to something like globalObject.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@160924 268f45cc-cd09-0410-ab3c-d52691b4dbfc
17 files changed:
Source/WebCore/CMakeLists.txt
Source/WebCore/ChangeLog
Source/WebCore/DerivedSources.make
Source/WebCore/GNUmakefile.am
Source/WebCore/GNUmakefile.list.am
Source/WebCore/WebCore.vcxproj/WebCore.vcxproj
Source/WebCore/WebCore.vcxproj/WebCore.vcxproj.filters
Source/WebCore/WebCore.xcodeproj/project.pbxproj
Source/WebCore/inspector/CommandLineAPIModule.cpp [new file with mode: 0644]
Source/WebCore/inspector/CommandLineAPIModule.h [new file with mode: 0644]
Source/WebCore/inspector/CommandLineAPIModuleSource.js [new file with mode: 0644]
Source/WebCore/inspector/InjectedScriptCanvasModule.h
Source/WebCore/inspector/InjectedScriptModule.cpp
Source/WebCore/inspector/InjectedScriptModule.h
Source/WebCore/inspector/InjectedScriptSource.js
Source/WebCore/inspector/InspectorAllInOne.cpp
Source/WebCore/inspector/PageRuntimeAgent.cpp