summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--chrome/renderer/render_process.cc4
-rw-r--r--chrome/renderer/render_thread.cc13
-rw-r--r--webkit/build/V8Bindings/SConscript9
-rw-r--r--webkit/build/V8Bindings/V8Bindings.vcproj16
-rw-r--r--webkit/extensions/v8/gc_extension.cc25
-rw-r--r--webkit/extensions/v8/gc_extension.h (renamed from webkit/port/bindings/v8/extensions/GCController.h)12
-rw-r--r--[-rwxr-xr-x]webkit/extensions/v8/gears_extension.cc (renamed from webkit/port/bindings/v8/extensions/Gears.cpp)13
-rw-r--r--[-rwxr-xr-x]webkit/extensions/v8/gears_extension.h (renamed from webkit/port/bindings/v8/extensions/Gears.h)12
-rw-r--r--webkit/extensions/v8/interval_extension.cc59
-rw-r--r--webkit/extensions/v8/interval_extension.h (renamed from webkit/port/bindings/v8/extensions/Interval.h)12
-rw-r--r--webkit/extensions/v8/playback_extension.cc30
-rw-r--r--webkit/extensions/v8/playback_extension.h (renamed from webkit/port/bindings/v8/extensions/Playback.h)15
-rw-r--r--webkit/glue/webkit_glue.cc12
-rw-r--r--webkit/glue/webkit_glue.h2
-rw-r--r--webkit/port/bindings/v8/ScriptController.cpp3
-rw-r--r--webkit/port/bindings/v8/ScriptController.h26
-rw-r--r--webkit/port/bindings/v8/extensions/GCController.cpp26
-rw-r--r--webkit/port/bindings/v8/extensions/Interval.cpp57
-rw-r--r--webkit/port/bindings/v8/extensions/Playback.cpp31
-rw-r--r--webkit/port/bindings/v8/v8_proxy.cpp13
-rw-r--r--webkit/tools/test_shell/node_leak_test.cc2
-rw-r--r--webkit/tools/test_shell/test_shell_main.cc15
-rw-r--r--webkit/tools/test_shell/test_shell_webkit_init.h4
-rw-r--r--webkit/webkit.gyp16
24 files changed, 193 insertions, 234 deletions
diff --git a/chrome/renderer/render_process.cc b/chrome/renderer/render_process.cc
index 80ec5fb..99b91fa 100644
--- a/chrome/renderer/render_process.cc
+++ b/chrome/renderer/render_process.cc
@@ -131,10 +131,6 @@ void RenderProcess::Init() {
webkit_glue::SetJavaScriptFlags(
command_line.GetSwitchValue(switches::kJavaScriptFlags));
}
- if (command_line.HasSwitch(switches::kPlaybackMode) ||
- command_line.HasSwitch(switches::kRecordMode)) {
- webkit_glue::SetRecordPlaybackMode(true);
- }
if (command_line.HasSwitch(switches::kEnableWatchdog)) {
// TODO(JAR): Need to implement renderer IO msgloop watchdog.
diff --git a/chrome/renderer/render_thread.cc b/chrome/renderer/render_thread.cc
index f244092..f2eed65 100644
--- a/chrome/renderer/render_thread.cc
+++ b/chrome/renderer/render_thread.cc
@@ -12,8 +12,10 @@
#include "chrome/renderer/render_thread.h"
+#include "base/command_line.h"
#include "base/shared_memory.h"
#include "chrome/common/chrome_plugin_lib.h"
+#include "chrome/common/chrome_switches.h"
#include "chrome/common/render_messages.h"
#include "chrome/common/notification_service.h"
#include "chrome/common/url_constants.h"
@@ -33,6 +35,9 @@
#include "chrome/renderer/renderer_webkitclient_impl.h"
#include "chrome/renderer/user_script_slave.h"
#include "chrome/renderer/visitedlink_slave.h"
+#include "webkit/extensions/v8/gears_extension.h"
+#include "webkit/extensions/v8/interval_extension.h"
+#include "webkit/extensions/v8/playback_extension.h"
#include "webkit/glue/cache_manager.h"
#include "WebKit.h"
@@ -244,4 +249,12 @@ void RenderThread::EnsureWebKitInitialized() {
webkit_client_.reset(new RendererWebKitClientImpl);
WebKit::initialize(webkit_client_.get());
WebKit::registerURLSchemeAsLocal(ASCIIToUTF16(chrome::kChromeUIScheme));
+ WebKit::registerExtension(extensions_v8::GearsExtension::Get());
+ WebKit::registerExtension(extensions_v8::IntervalExtension::Get());
+
+ const CommandLine& command_line = *CommandLine::ForCurrentProcess();
+ if (command_line.HasSwitch(switches::kPlaybackMode) ||
+ command_line.HasSwitch(switches::kRecordMode)) {
+ WebKit::registerExtension(extensions_v8::PlaybackExtension::Get());
+ }
}
diff --git a/webkit/build/V8Bindings/SConscript b/webkit/build/V8Bindings/SConscript
index 64fa2b5..7739356 100644
--- a/webkit/build/V8Bindings/SConscript
+++ b/webkit/build/V8Bindings/SConscript
@@ -350,10 +350,6 @@ inputs = [
'$PORT_DIR/bindings/v8/V8XMLHttpRequestCustom.cpp',
'$PORT_DIR/bindings/v8/WorkerContextExecutionProxy.cpp',
'$PORT_DIR/bindings/v8/WorkerScriptController.cpp',
- '$PORT_DIR/bindings/v8/extensions/GCController.cpp',
- '$PORT_DIR/bindings/v8/extensions/Gears.cpp',
- '$PORT_DIR/bindings/v8/extensions/Interval.cpp',
- '$PORT_DIR/bindings/v8/extensions/Playback.cpp',
'$WEBCORE_DIR/bindings/v8/custom/V8CanvasRenderingContext2DCustom.cpp',
'$WEBCORE_DIR/bindings/v8/custom/V8ClipboardCustom.cpp',
@@ -390,6 +386,11 @@ inputs = [
'$WEBCORE_DIR/bindings/v8/custom/V8XMLSerializerConstructor.cpp',
'$WEBCORE_DIR/bindings/v8/custom/V8XPathEvaluatorConstructor.cpp',
'$WEBCORE_DIR/bindings/v8/custom/V8XSLTProcessorCustom.cpp',
+
+ '$WEBKIT_DIR/extensions/v8/gc_extension.cc',
+ '$WEBKIT_DIR/extensions/v8/gears_extension.cc',
+ '$WEBKIT_DIR/extensions/v8/interval_extension.cc',
+ '$WEBKIT_DIR/extensions/v8/playback_extension.cc',
]
if env.Bit('windows'):
diff --git a/webkit/build/V8Bindings/V8Bindings.vcproj b/webkit/build/V8Bindings/V8Bindings.vcproj
index c104f9e..87d4964 100644
--- a/webkit/build/V8Bindings/V8Bindings.vcproj
+++ b/webkit/build/V8Bindings/V8Bindings.vcproj
@@ -2668,35 +2668,35 @@
Name="extensions"
>
<File
- RelativePath="..\..\port\bindings\v8\extensions\GCController.cpp"
+ RelativePath="..\..\extensions\v8\gc_extension.cc"
>
</File>
<File
- RelativePath="..\..\port\bindings\v8\extensions\GCController.h"
+ RelativePath="..\..\extensions\v8\gc_extension.h"
>
</File>
<File
- RelativePath="..\..\port\bindings\v8\extensions\Gears.cpp"
+ RelativePath="..\..\extensions\v8\gears_extension.cc"
>
</File>
<File
- RelativePath="..\..\port\bindings\v8\extensions\Gears.h"
+ RelativePath="..\..\extensions\v8\gears_extension.h"
>
</File>
<File
- RelativePath="..\..\port\bindings\v8\extensions\Interval.cpp"
+ RelativePath="..\..\extensions\v8\interval_extension.cc"
>
</File>
<File
- RelativePath="..\..\port\bindings\v8\extensions\Interval.h"
+ RelativePath="..\..\extensions\v8\interval_extension.h"
>
</File>
<File
- RelativePath="..\..\port\bindings\v8\extensions\Playback.cpp"
+ RelativePath="..\..\extensions\v8\playback_extension.cc"
>
</File>
<File
- RelativePath="..\..\port\bindings\v8\extensions\Playback.h"
+ RelativePath="..\..\extensions\v8\playback_extension.h"
>
</File>
</Filter>
diff --git a/webkit/extensions/v8/gc_extension.cc b/webkit/extensions/v8/gc_extension.cc
new file mode 100644
index 0000000..fb3e978
--- /dev/null
+++ b/webkit/extensions/v8/gc_extension.cc
@@ -0,0 +1,25 @@
+// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "webkit/extensions/v8/gc_extension.h"
+
+namespace extensions_v8 {
+
+const char* kGCExtensionName = "v8/GCController";
+
+v8::Extension* GCExtension::Get() {
+ v8::Extension* extension = new v8::Extension(
+ kGCExtensionName,
+ "(function () {"
+ " var v8_gc;"
+ " if (gc) v8_gc = gc;"
+ " GCController = new Object();"
+ " GCController.collect ="
+ " function() {if (v8_gc) v8_gc(); };"
+ " })();");
+ return extension;
+}
+
+} // namespace extensions_v8
+
diff --git a/webkit/port/bindings/v8/extensions/GCController.h b/webkit/extensions/v8/gc_extension.h
index 3466f66..42dd684 100644
--- a/webkit/port/bindings/v8/extensions/GCController.h
+++ b/webkit/extensions/v8/gc_extension.h
@@ -5,19 +5,19 @@
// The GCExtension is a v8 extension to expose a method into JS for triggering
// garbage collection. This should only be used for debugging.
-#ifndef GC_EXTENSION_H__
-#define GC_EXTENSION_H__
+#ifndef WEBKIT_EXTENSIONS_V8_GC_EXTENSION_H_
+#define WEBKIT_EXTENSIONS_V8_GC_EXTENSION_H_
-#include "v8.h"
+#include "v8/include/v8.h"
-namespace WebCore {
+namespace extensions_v8 {
class GCExtension {
public:
static v8::Extension* Get();
};
-}
+} // namespace extensions_v8
-#endif // GC_EXTENSION_H__
+#endif // WEBKIT_EXTENSIONS_V8_GC_EXTENSION_H_
diff --git a/webkit/port/bindings/v8/extensions/Gears.cpp b/webkit/extensions/v8/gears_extension.cc
index 9d36707..f36ac61 100755..100644
--- a/webkit/port/bindings/v8/extensions/Gears.cpp
+++ b/webkit/extensions/v8/gears_extension.cc
@@ -2,10 +2,9 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "config.h"
-#include "Gears.h"
+#include "webkit/extensions/v8/gears_extension.h"
-namespace WebCore {
+namespace extensions_v8 {
const char* kGearsExtensionName = "v8/Gears";
@@ -33,13 +32,13 @@ const char* kGearsExtensionScript =
"})();";
class GearsExtensionWrapper : public v8::Extension {
-public:
- GearsExtensionWrapper() :
- v8::Extension(kGearsExtensionName, kGearsExtensionScript) {}
+ public:
+ GearsExtensionWrapper()
+ : v8::Extension(kGearsExtensionName, kGearsExtensionScript) {}
};
v8::Extension* GearsExtension::Get() {
return new GearsExtensionWrapper();
}
-}
+} // namespace extensions_v8
diff --git a/webkit/port/bindings/v8/extensions/Gears.h b/webkit/extensions/v8/gears_extension.h
index 4e6c07d..6f62787 100755..100644
--- a/webkit/port/bindings/v8/extensions/Gears.h
+++ b/webkit/extensions/v8/gears_extension.h
@@ -6,19 +6,19 @@
// on the page, which, when accessed, lazily inserts the gears plugin into
// the page and attaches it to the factory variable.
-#ifndef GEARS_EXTENSION_H__
-#define GEARS_EXTENSION_H__
+#ifndef WEBKIT_EXTENSIONS_V8_GEARS_EXTENSION_H_
+#define WEBKIT_EXTENSIONS_V8_GEARS_EXTENSION_H_
-#include "v8.h"
+#include "v8/include/v8.h"
-namespace WebCore {
+namespace extensions_v8 {
class GearsExtension {
public:
static v8::Extension* Get();
};
-}
+} // namespace extensions_v8
-#endif // GEARS_EXTENSION_H__
+#endif // WEBKIT_EXTENSIONS_V8_GEARS_EXTENSION_H_
diff --git a/webkit/extensions/v8/interval_extension.cc b/webkit/extensions/v8/interval_extension.cc
new file mode 100644
index 0000000..4f6072a
--- /dev/null
+++ b/webkit/extensions/v8/interval_extension.cc
@@ -0,0 +1,59 @@
+// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "webkit/extensions/v8/interval_extension.h"
+#include "base/time.h"
+
+namespace extensions_v8 {
+
+const char* kIntervalExtensionName = "v8/Interval";
+
+class IntervalExtensionWrapper : public v8::Extension {
+ public:
+ IntervalExtensionWrapper()
+ : v8::Extension(
+ kIntervalExtensionName,
+ "var chromium;"
+ "if (!chromium)"
+ " chromium = {};"
+ "chromium.Interval = function() {"
+ " var start_ = 0;"
+ " var stop_ = 0;"
+ " native function HiResTime();"
+ " this.start = function() {"
+ " stop_ = 0;"
+ " start_ = HiResTime();"
+ " };"
+ " this.stop = function() {"
+ " stop_ = HiResTime();"
+ " if (start_ == 0)"
+ " stop_ = 0;"
+ " };"
+ " this.microseconds = function() {"
+ " var stop = stop_;"
+ " if (stop == 0 && start_ != 0)"
+ " stop = HiResTime();"
+ " return Math.ceil((stop - start_) * 1000000);"
+ " };"
+ "}") {}
+
+ virtual v8::Handle<v8::FunctionTemplate> GetNativeFunction(
+ v8::Handle<v8::String> name) {
+ if (name->Equals(v8::String::New("HiResTime"))) {
+ return v8::FunctionTemplate::New(HiResTime);
+ }
+ return v8::Handle<v8::FunctionTemplate>();
+ }
+
+ static v8::Handle<v8::Value> HiResTime(const v8::Arguments& args) {
+ return v8::Number::New(base::Time::Now().ToDoubleT());
+ }
+};
+
+v8::Extension* IntervalExtension::Get() {
+ return new IntervalExtensionWrapper();
+}
+
+} // namespace extensions_v8
+
diff --git a/webkit/port/bindings/v8/extensions/Interval.h b/webkit/extensions/v8/interval_extension.h
index c009302..36da067 100644
--- a/webkit/port/bindings/v8/extensions/Interval.h
+++ b/webkit/extensions/v8/interval_extension.h
@@ -5,19 +5,19 @@
// The IntervalExtension is a v8 extension to implement a simple interval
// class for measuring microsecond intervals.
-#ifndef INTERVAL_EXTENSION_H__
-#define INTERVAL_EXTENSION_H__
+#ifndef WEBKIT_EXTENSIONS_V8_INTERVAL_EXTENSION_H_
+#define WEBKIT_EXTENSIONS_V8_INTERVAL_EXTENSION_H_
-#include "v8.h"
+#include "v8/include/v8.h"
-namespace WebCore {
+namespace extensions_v8 {
class IntervalExtension {
public:
static v8::Extension* Get();
};
-}
+} // namespace extensions_v8
-#endif // INTERVAL_EXTENSION_H__
+#endif // WEBKIT_EXTENSIONS_V8_INTERVAL_EXTENSION_H_
diff --git a/webkit/extensions/v8/playback_extension.cc b/webkit/extensions/v8/playback_extension.cc
new file mode 100644
index 0000000..82d0b8a
--- /dev/null
+++ b/webkit/extensions/v8/playback_extension.cc
@@ -0,0 +1,30 @@
+// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "webkit/extensions/v8/playback_extension.h"
+
+namespace extensions_v8 {
+
+const char* kPlaybackExtensionName = "v8/PlaybackMode";
+
+v8::Extension* PlaybackExtension::Get() {
+ v8::Extension* extension = new v8::Extension(
+ kPlaybackExtensionName,
+ "(function () {"
+ " var orig_date = Date;"
+ " Math.random = function() {"
+ " return 0.5;"
+ " };"
+ " Date.__proto__.now = function() {"
+ " return new orig_date(1204251968254);"
+ " };"
+ " Date = function() {"
+ " return Date.now();"
+ " };"
+ "})()");
+ return extension;
+}
+
+} // namespace extensions_v8
+
diff --git a/webkit/port/bindings/v8/extensions/Playback.h b/webkit/extensions/v8/playback_extension.h
index a60079c..3e50976 100644
--- a/webkit/port/bindings/v8/extensions/Playback.h
+++ b/webkit/extensions/v8/playback_extension.h
@@ -2,15 +2,12 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-// The IntervalExtension is a v8 extension to implement a simple interval
-// class for measuring microsecond intervals.
+#ifndef WEBKIT_EXTENSIONS_V8_PLAYBACK_EXTENSION_H_
+#define WEBKIT_EXTENSIONS_V8_PLAYBACK_EXTENSION_H_
-#ifndef PLAYBACK_EXTENSION_H__
-#define PLAYBACK_EXTENSION_H__
+#include "v8/include/v8.h"
-#include "v8.h"
-
-namespace WebCore {
+namespace extensions_v8 {
// Inject code which overrides a few common JS functions for implementing
// randomness. In order to implement effective record & playback of
@@ -28,7 +25,7 @@ class PlaybackExtension {
static v8::Extension* Get();
};
-}
+} // namespace extensions_v8
-#endif // PLAYBACK_EXTENSION_H__
+#endif // WEBKIT_EXTENSIONS_V8_PLAYBACK_EXTENSION_H_
diff --git a/webkit/glue/webkit_glue.cc b/webkit/glue/webkit_glue.cc
index 30c1ed0..3ee3a8e 100644
--- a/webkit/glue/webkit_glue.cc
+++ b/webkit/glue/webkit_glue.cc
@@ -64,18 +64,6 @@ void SetJavaScriptFlags(const std::wstring& str) {
#endif
}
-void SetRecordPlaybackMode(bool value) {
-#if USE(V8)
- WebCore::ScriptController::setRecordPlaybackMode(value);
-#endif
-}
-
-void SetShouldExposeGCController(bool enable) {
-#if USE(V8)
- WebCore::ScriptController::setShouldExposeGCController(enable);
-#endif
-}
-
void EnableWebCoreNotImplementedLogging() {
WebCore::LogNotYetImplemented.state = WTFLogChannelOn;
}
diff --git a/webkit/glue/webkit_glue.h b/webkit/glue/webkit_glue.h
index 003b0da..0ddee38 100644
--- a/webkit/glue/webkit_glue.h
+++ b/webkit/glue/webkit_glue.h
@@ -58,8 +58,6 @@ struct ScreenInfo;
//---- BEGIN FUNCTIONS IMPLEMENTED BY WEBKIT/GLUE -----------------------------
void SetJavaScriptFlags(const std::wstring& flags);
-void SetRecordPlaybackMode(bool value);
-void SetShouldExposeGCController(bool enable);
// Turn on the logging for notImplemented() calls from WebCore.
void EnableWebCoreNotImplementedLogging();
diff --git a/webkit/port/bindings/v8/ScriptController.cpp b/webkit/port/bindings/v8/ScriptController.cpp
index 4da169b..9dff0b8 100644
--- a/webkit/port/bindings/v8/ScriptController.cpp
+++ b/webkit/port/bindings/v8/ScriptController.cpp
@@ -74,9 +74,6 @@ NPRuntimeFunctions npruntime_functions = {
namespace WebCore {
-bool ScriptController::m_recordPlaybackMode = false;
-bool ScriptController::m_shouldExposeGCController = false;
-
void ScriptController::setFlags(const char* str, int length)
{
v8::V8::SetFlagsFromString(str, length);
diff --git a/webkit/port/bindings/v8/ScriptController.h b/webkit/port/bindings/v8/ScriptController.h
index be4c6b4..1d580fe 100644
--- a/webkit/port/bindings/v8/ScriptController.h
+++ b/webkit/port/bindings/v8/ScriptController.h
@@ -211,29 +211,6 @@ public:
static void gcProtectJSWrapper(void* object);
static void gcUnprotectJSWrapper(void* object);
- // Get/Set RecordPlaybackMode flag.
- // This is a special mode where JS helps the browser implement
- // playback/record mode. Generally, in this mode, some functions
- // of client-side randomness are removed. For example, in
- // this mode Math.random() and Date.getTime() may not return
- // values which vary.
- 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);
@@ -259,9 +236,6 @@ public:
#endif
private:
- static bool m_recordPlaybackMode;
- static bool m_shouldExposeGCController;
-
Frame* m_frame;
const String* m_sourceURL;
diff --git a/webkit/port/bindings/v8/extensions/GCController.cpp b/webkit/port/bindings/v8/extensions/GCController.cpp
deleted file mode 100644
index 1074b15..0000000
--- a/webkit/port/bindings/v8/extensions/GCController.cpp
+++ /dev/null
@@ -1,26 +0,0 @@
-// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "config.h"
-#include "GCController.h"
-
-namespace WebCore {
-
-const char* kGCExtensionName = "v8/GCController";
-
-v8::Extension* GCExtension::Get() {
- v8::Extension* extension = new v8::Extension(
- kGCExtensionName,
- "(function () {"
- " var v8_gc;"
- " if (gc) v8_gc = gc;"
- " GCController = new Object();"
- " GCController.collect ="
- " function() {if (v8_gc) v8_gc(); };"
- " })()");
- return extension;
-}
-
-}
-
diff --git a/webkit/port/bindings/v8/extensions/Interval.cpp b/webkit/port/bindings/v8/extensions/Interval.cpp
deleted file mode 100644
index b09847c..0000000
--- a/webkit/port/bindings/v8/extensions/Interval.cpp
+++ /dev/null
@@ -1,57 +0,0 @@
-// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "config.h"
-#include "Interval.h"
-#include "wtf/CurrentTime.h"
-
-namespace WebCore {
-
-const char* kIntervalExtensionName = "v8/Interval";
-
-class IntervalExtensionWrapper : public v8::Extension {
-public:
- IntervalExtensionWrapper() :
- v8::Extension(kIntervalExtensionName,
- "var chromium;"
- "if (!chromium)"
- " chromium = {};"
- "chromium.Interval = function() {"
- " var start_ = 0;"
- " var stop_ = 0;"
- " native function HiResTime();"
- " this.start = function() {"
- " stop_ = 0;"
- " start_ = HiResTime();"
- " };"
- " this.stop = function() {"
- " stop_ = HiResTime();"
- " if (start_ == 0)"
- " stop_ = 0;"
- " };"
- " this.microseconds = function() {"
- " var stop = stop_;"
- " if (stop == 0 && start_ != 0)"
- " stop = HiResTime();"
- " return Math.ceil((stop - start_) * 1000000);"
- " };"
- "}") {};
-
- virtual v8::Handle<v8::FunctionTemplate> GetNativeFunction(v8::Handle<v8::String> name) {
- if (name->Equals(v8::String::New("HiResTime")))
- return v8::FunctionTemplate::New(HiResTime);
- return v8::Handle<v8::FunctionTemplate>();
- }
-
- static v8::Handle<v8::Value> HiResTime(const v8::Arguments& args) {
- return v8::Number::New(WTF::currentTime());
- }
-};
-
-v8::Extension* IntervalExtension::Get() {
- return new IntervalExtensionWrapper();
-}
-
-}
-
diff --git a/webkit/port/bindings/v8/extensions/Playback.cpp b/webkit/port/bindings/v8/extensions/Playback.cpp
deleted file mode 100644
index 4a50230..0000000
--- a/webkit/port/bindings/v8/extensions/Playback.cpp
+++ /dev/null
@@ -1,31 +0,0 @@
-// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "config.h"
-#include "Playback.h"
-
-namespace WebCore {
-
-const char* kPlaybackExtensionName = "v8/PlaybackMode";
-
-v8::Extension* PlaybackExtension::Get() {
- v8::Extension* extension = new v8::Extension(
- kPlaybackExtensionName,
- "(function () {"
- " var orig_date = Date;"
- " Math.random = function() {"
- " return 0.5;"
- " };"
- " Date.__proto__.now = function() {"
- " return new orig_date(1204251968254);"
- " };"
- " Date = function() {"
- " return Date.now();"
- " };"
- "})()");
- return extension;
-}
-
-}
-
diff --git a/webkit/port/bindings/v8/v8_proxy.cpp b/webkit/port/bindings/v8/v8_proxy.cpp
index c303a08..aa2ecc6 100644
--- a/webkit/port/bindings/v8/v8_proxy.cpp
+++ b/webkit/port/bindings/v8/v8_proxy.cpp
@@ -205,11 +205,6 @@
#include "XPathEvaluator.h"
#endif
-#include "extensions/GCController.h"
-#include "extensions/Gears.h"
-#include "extensions/Interval.h"
-#include "extensions/Playback.h"
-
namespace WebCore {
@@ -2331,14 +2326,6 @@ void V8Proxy::InitContextIfNeeded()
v8::V8::SetFailedAccessCheckCallbackFunction(ReportUnsafeJavaScriptAccess);
- // Register known extensions
- RegisterExtension(GearsExtension::Get());
- RegisterExtension(IntervalExtension::Get());
- if (ScriptController::shouldExposeGCController())
- RegisterExtension(GCExtension::Get());
- if (ScriptController::RecordPlaybackMode())
- RegisterExtension(PlaybackExtension::Get());
-
v8_initialized = true;
}
diff --git a/webkit/tools/test_shell/node_leak_test.cc b/webkit/tools/test_shell/node_leak_test.cc
index 8b1c815..91ee6e8 100644
--- a/webkit/tools/test_shell/node_leak_test.cc
+++ b/webkit/tools/test_shell/node_leak_test.cc
@@ -36,8 +36,6 @@ class NodeLeakTest : public TestShellTest {
parsed_command_line.GetSwitchValue(test_shell::kJavaScriptFlags);
js_flags += L" --expose-gc";
webkit_glue::SetJavaScriptFlags(js_flags);
- // Expose GCController to JavaScript as well.
- webkit_glue::SetShouldExposeGCController(true);
std::wstring cache_path =
parsed_command_line.GetSwitchValue(test_shell::kCacheDir);
diff --git a/webkit/tools/test_shell/test_shell_main.cc b/webkit/tools/test_shell/test_shell_main.cc
index 859fd5f..fee33cf 100644
--- a/webkit/tools/test_shell/test_shell_main.cc
+++ b/webkit/tools/test_shell/test_shell_main.cc
@@ -27,6 +27,8 @@
#include "net/url_request/url_request_context.h"
#include "webkit/glue/webkit_glue.h"
#include "webkit/glue/window_open_disposition.h"
+#include "webkit/extensions/v8/gc_extension.h"
+#include "webkit/extensions/v8/playback_extension.h"
#include "webkit/tools/test_shell/simple_resource_loader_bridge.h"
#include "webkit/tools/test_shell/test_shell.h"
#include "webkit/tools/test_shell/test_shell_platform_delegate.h"
@@ -100,6 +102,12 @@ int main(int argc, char* argv[]) {
base::TraceLog::StartTracing();
net::HttpCache::Mode cache_mode = net::HttpCache::NORMAL;
+
+ // This is a special mode where JS helps the browser implement
+ // playback/record mode. Generally, in this mode, some functions
+ // of client-side randomness are removed. For example, in
+ // this mode Math.random() and Date.getTime() may not return
+ // values which vary.
bool playback_mode =
parsed_command_line.HasSwitch(test_shell::kPlaybackMode);
bool record_mode =
@@ -178,8 +186,8 @@ int main(int argc, char* argv[]) {
// Test shell always exposes the GC.
js_flags += L" --expose-gc";
webkit_glue::SetJavaScriptFlags(js_flags);
- // Also expose GCController to JavaScript.
- webkit_glue::SetShouldExposeGCController(true);
+ // Expose GCController to JavaScript.
+ WebKit::registerExtension(extensions_v8::GCExtension::Get());
// Load and initialize the stats table. Attempt to construct a somewhat
// unique name to isolate separate instances from each other.
@@ -195,8 +203,7 @@ int main(int argc, char* argv[]) {
if (TestShell::CreateNewWindow(uri, &shell)) {
if (record_mode || playback_mode) {
platform.SetWindowPositionForRecording(shell);
- // Tell webkit as well.
- webkit_glue::SetRecordPlaybackMode(true);
+ WebKit::registerExtension(extensions_v8::PlaybackExtension::Get());
}
shell->Show(shell->webView(), NEW_WINDOW);
diff --git a/webkit/tools/test_shell/test_shell_webkit_init.h b/webkit/tools/test_shell/test_shell_webkit_init.h
index dd98b33..d3f5d0b 100644
--- a/webkit/tools/test_shell/test_shell_webkit_init.h
+++ b/webkit/tools/test_shell/test_shell_webkit_init.h
@@ -9,6 +9,8 @@
#include "webkit/glue/simple_webmimeregistry_impl.h"
#include "webkit/glue/webkit_glue.h"
#include "webkit/glue/webkitclient_impl.h"
+#include "webkit/extensions/v8/gears_extension.h"
+#include "webkit/extensions/v8/interval_extension.h"
#include "webkit/tools/test_shell/simple_resource_loader_bridge.h"
#include "WebKit.h"
@@ -22,6 +24,8 @@ class TestShellWebKitInit : public webkit_glue::WebKitClientImpl {
WebKit::setLayoutTestMode(layout_test_mode);
WebKit::registerURLSchemeAsLocal(
ASCIIToUTF16(webkit_glue::GetUIResourceProtocol()));
+ WebKit::registerExtension(extensions_v8::GearsExtension::Get());
+ WebKit::registerExtension(extensions_v8::IntervalExtension::Get());
}
~TestShellWebKitInit() {
diff --git a/webkit/webkit.gyp b/webkit/webkit.gyp
index 591a3a1..98d2dae 100644
--- a/webkit/webkit.gyp
+++ b/webkit/webkit.gyp
@@ -1021,14 +1021,14 @@
'../third_party/WebKit/WebCore/bindings/v8/ScriptValue.h',
'../third_party/WebKit/WebCore/bindings/v8/V8Binding.h',
'../third_party/WebKit/WebCore/bindings/v8/V8Proxy.h',
- 'port/bindings/v8/extensions/GCController.cpp',
- 'port/bindings/v8/extensions/GCController.h',
- 'port/bindings/v8/extensions/Gears.cpp',
- 'port/bindings/v8/extensions/Gears.h',
- 'port/bindings/v8/extensions/Interval.cpp',
- 'port/bindings/v8/extensions/Interval.h',
- 'port/bindings/v8/extensions/Playback.cpp',
- 'port/bindings/v8/extensions/Playback.h',
+ 'extensions/v8/gc_extension.cc',
+ 'extensions/v8/gc_extension.h',
+ 'extensions/v8/gears_extension.cc',
+ 'extensions/v8/gears_extension.h',
+ 'extensions/v8/interval_extension.cc',
+ 'extensions/v8/interval_extension.h',
+ 'extensions/v8/playback_extension.cc',
+ 'extensions/v8/playback_extension.h',
'port/bindings/v8/JSDOMBinding.cpp',
'port/bindings/v8/JSDOMBinding.h',
'port/bindings/v8/JSXPathNSResolver.cpp',