summaryrefslogtreecommitdiff
path: root/source/pdf
diff options
context:
space:
mode:
authorTor Andersson <tor.andersson@artifex.com>2014-02-14 11:33:38 +0100
committerTor Andersson <tor.andersson@artifex.com>2014-02-14 11:35:45 +0100
commit460c7c54f83c19ac84f54b8d79f71fcfa0b73d91 (patch)
tree6e75af7c253ba99c79f3897f503f813057b26007 /source/pdf
parent927d8d998b7f77aa4ed2e839046394627e147673 (diff)
downloadmupdf-460c7c54f83c19ac84f54b8d79f71fcfa0b73d91.tar.xz
pdf-js.c: Cluster test fixes.
Use a fixed number for Math.random(). Return a fixed date for Date.now() and Date.UTC().
Diffstat (limited to 'source/pdf')
-rw-r--r--source/pdf/js/pdf-js.c13
1 files changed, 10 insertions, 3 deletions
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