From 460c7c54f83c19ac84f54b8d79f71fcfa0b73d91 Mon Sep 17 00:00:00 2001 From: Tor Andersson Date: Fri, 14 Feb 2014 11:33:38 +0100 Subject: pdf-js.c: Cluster test fixes. Use a fixed number for Math.random(). Return a fixed date for Date.now() and Date.UTC(). --- source/pdf/js/pdf-js.c | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) (limited to 'source/pdf') diff --git a/source/pdf/js/pdf-js.c b/source/pdf/js/pdf-js.c index 04cef9d7..ee7f979b 100644 --- a/source/pdf/js/pdf-js.c +++ b/source/pdf/js/pdf-js.c @@ -749,12 +749,19 @@ static void declare_dom(pdf_js *js) static void preload_helpers(pdf_js *js) { - /* When testing on the cluster, redefine the Date object - * to use a fixed date */ + /* When testing on the cluster: + * Use a fixed date for "new Date" and Date.now(). + * Sadly, this breaks uses of the Date function without the new keyword. + * Return a fixed number from Math.random(). + */ #ifdef CLUSTER pdf_jsimp_execute(js->imp, "var MuPDFOldDate = Date\n" -"Date = function() { return new MuPDFOldDate(1979,5,15); }\n" +"Date = function() { return new MuPDFOldDate(298252800000); }\n" +"Date.now = function() { return 298252800000; }\n" +"Date.UTC = function() { return 298252800000; }\n" +"Date.parse = MuPDFOldDate.parse;\n" +"Math.random = function() { return 0.4; }\n" ); #endif -- cgit v1.2.3