OLD | NEW |
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "config.h" | |
6 #include "webkit/extensions/v8/playback_extension.h" | 5 #include "webkit/extensions/v8/playback_extension.h" |
7 | 6 |
8 namespace extensions_v8 { | 7 namespace extensions_v8 { |
9 | 8 |
10 const char* kPlaybackExtensionName = "v8/PlaybackMode"; | 9 const char* kPlaybackExtensionName = "v8/PlaybackMode"; |
11 | 10 |
12 v8::Extension* PlaybackExtension::Get() { | 11 v8::Extension* PlaybackExtension::Get() { |
13 v8::Extension* extension = new v8::Extension( | 12 v8::Extension* extension = new v8::Extension( |
14 kPlaybackExtensionName, | 13 kPlaybackExtensionName, |
15 "(function () {" | 14 "(function () {" |
16 " var orig_date = Date;" | 15 " var orig_date = Date;" |
17 " var x = 0;" | 16 " var x = 0;" |
18 " var time_seed = 1204251968254;" | 17 " var time_seed = 1204251968254;" |
19 " Math.random = function() {" | 18 " Math.random = function() {" |
20 " x += .1;" | 19 " x += .1;" |
21 " return (x % 1);" | 20 " return (x % 1);" |
22 " };" | 21 " };" |
23 " Date.__proto__.now = function() {" | 22 " Date.__proto__.now = function() {" |
24 " time_seed += 50;" | 23 " time_seed += 50;" |
25 " return new orig_date(time_seed);" | 24 " return new orig_date(time_seed);" |
26 " };" | 25 " };" |
27 " Date = function() {" | 26 " Date = function() {" |
28 " return Date.now();" | 27 " return Date.now();" |
29 " };" | 28 " };" |
30 "})()"); | 29 "})()"); |
31 return extension; | 30 return extension; |
32 } | 31 } |
33 | 32 |
34 } // namespace extensions_v8 | 33 } // namespace extensions_v8 |
OLD | NEW |