summaryrefslogtreecommitdiffstats
path: root/webkit/port
diff options
context:
space:
mode:
authorfqian@google.com <fqian@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2008-11-14 17:29:05 +0000
committerfqian@google.com <fqian@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2008-11-14 17:29:05 +0000
commit296d61e24b5a5311f120a767a59ac006176f6f9a (patch)
tree2b70d0a190ab2719137b274bd63b6fc83ce02bde /webkit/port
parent99b362e5289d111296f72404e7ea1b4cbe7a07cf (diff)
downloadchromium_src-296d61e24b5a5311f120a767a59ac006176f6f9a.zip
chromium_src-296d61e24b5a5311f120a767a59ac006176f6f9a.tar.gz
chromium_src-296d61e24b5a5311f120a767a59ac006176f6f9a.tar.bz2
Add GCController support to test_shell.
This is done in the binding layer, GCController is a JS object, GCController.collect() is a JS function which calls gc(). GCController object can be enabled by calling ScriptController::setShouldExposeGCController(true); GCController.collect() needs V8 expose gc function, which is controlled by a flag '--expose-gc'. Otherwise GCController.collect() has no effect. By default, test_shell exposes both gc function and GCController object. Review URL: http://codereview.chromium.org/10719 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@5482 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'webkit/port')
-rw-r--r--webkit/port/bindings/v8/ScriptController.cpp1
-rw-r--r--webkit/port/bindings/v8/ScriptController.h15
-rw-r--r--webkit/port/bindings/v8/v8_proxy.cpp19
3 files changed, 33 insertions, 2 deletions
diff --git a/webkit/port/bindings/v8/ScriptController.cpp b/webkit/port/bindings/v8/ScriptController.cpp
index 6521a4d..7eda483 100644
--- a/webkit/port/bindings/v8/ScriptController.cpp
+++ b/webkit/port/bindings/v8/ScriptController.cpp
@@ -78,6 +78,7 @@ NPRuntimeFunctions npruntime_functions = {
namespace WebCore {
bool ScriptController::m_recordPlaybackMode = false;
+bool ScriptController::m_shouldExposeGCController = false;
void ScriptController::setFlags(const char* str, int length)
{
diff --git a/webkit/port/bindings/v8/ScriptController.h b/webkit/port/bindings/v8/ScriptController.h
index 9c29a56..34de5f0 100644
--- a/webkit/port/bindings/v8/ScriptController.h
+++ b/webkit/port/bindings/v8/ScriptController.h
@@ -218,6 +218,20 @@ public:
static bool RecordPlaybackMode() { return m_recordPlaybackMode; }
static void setRecordPlaybackMode(bool value) { m_recordPlaybackMode = value; }
+ // Set/Get ShouldExposeGCController flag.
+ // Some WebKit layout test need window.GCController.collect() to
+ // trigger GC, this flag lets the binding code expose
+ // window.GCController.collect() to the JavaScript code.
+ //
+ // GCController.collect() needs V8 engine expose gc() function by passing
+ // '--expose-gc' flag to the engine.
+ static bool shouldExposeGCController() {
+ return m_shouldExposeGCController;
+ }
+ static void setShouldExposeGCController(bool value) {
+ m_shouldExposeGCController = value;
+ }
+
void finishedWithEvent(Event*);
void setEventHandlerLineno(int lineno);
@@ -245,6 +259,7 @@ public:
private:
static bool m_recordPlaybackMode;
+ static bool m_shouldExposeGCController;
Frame* m_frame;
const String* m_sourceURL;
diff --git a/webkit/port/bindings/v8/v8_proxy.cpp b/webkit/port/bindings/v8/v8_proxy.cpp
index 1176692..17ae8c1 100644
--- a/webkit/port/bindings/v8/v8_proxy.cpp
+++ b/webkit/port/bindings/v8/v8_proxy.cpp
@@ -1826,8 +1826,23 @@ void V8Proxy::initContextIfNeeded()
V8Custom::v8DOMWindowIndexedSecurityCheck,
v8::Integer::New(V8ClassIndex::DOMWINDOW));
- // Create a new context.
- m_context = v8::Context::New(NULL, global_template, m_global);
+ if (ScriptController::shouldExposeGCController()) {
+ v8::RegisterExtension(new v8::Extension("v8/GCController",
+ "(function v8_GCController() {"
+ " var v8_gc;"
+ " if (gc) v8_gc = gc;"
+ " GCController = new Object();"
+ " GCController.collect ="
+ " function() {if (v8_gc) v8_gc(); };"
+ " })()"));
+ const char* extension_names[] = { "v8/GCController" };
+ v8::ExtensionConfiguration extensions(1, extension_names);
+ // Create a new context.
+ m_context = v8::Context::New(&extensions, global_template, m_global);
+ } else {
+ m_context = v8::Context::New(NULL, global_template, m_global);
+ }
+
if (m_context.IsEmpty())
return;