From b6c50b006d92a1dd5049780799ed5a37f0328d46 Mon Sep 17 00:00:00 2001 From: "jnd@chromium.org" Date: Fri, 14 May 2010 08:54:41 +0000 Subject: Land patch for WangXianzhu. See http://codereview.chromium.org/1556005/show for the details. BUG=39768 TBR=Wangxianzhu Review URL: http://codereview.chromium.org/2080002 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@47254 0039d316-1c4b-4281-b951-d872f2087c98 --- webkit/extensions/v8/playback_extension.cc | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) (limited to 'webkit/extensions') diff --git a/webkit/extensions/v8/playback_extension.cc b/webkit/extensions/v8/playback_extension.cc index 63838fb..8751d36 100644 --- a/webkit/extensions/v8/playback_extension.cc +++ b/webkit/extensions/v8/playback_extension.cc @@ -19,12 +19,25 @@ v8::Extension* PlaybackExtension::Get() { " x += .1;" " return (x % 1);" " };" - " Date.__proto__.now = function() {" - " time_seed += 50;" - " return new orig_date(time_seed);" - " };" " Date = function() {" - " return Date.now();" + " if (this instanceof Date) {" + " switch (arguments.length) {" + " case 0: return new orig_date(time_seed += 50);" + " case 1: return new orig_date(arguments[0]);" + " default: return new orig_date(arguments[0], arguments[1]," + " arguments.length >= 3 ? arguments[2] : 1," + " arguments.length >= 4 ? arguments[3] : 0," + " arguments.length >= 5 ? arguments[4] : 0," + " arguments.length >= 6 ? arguments[5] : 0," + " arguments.length >= 7 ? arguments[6] : 0);" + " }" + " }" + " return new Date().toString();" + " };" + " Date.__proto__ = orig_date;" + " Date.prototype.constructor = Date;" + " orig_date.now = function() {" + " return new Date().getTime();" " };" "})()"); return extension; -- cgit v1.1