aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlon Zakai <alonzakai@gmail.com>2012-09-13 18:06:56 -0700
committerAlon Zakai <alonzakai@gmail.com>2012-09-13 18:06:56 -0700
commite8244f94918827381775158ce07cebcc69716885 (patch)
treea9f40f3fdb5f32aaff341d850e940f4ecc8f575f
parentc6d27b59bdcf0626ee272a5a3d74180d045d3890 (diff)
do not consume randoms, dnows or pnows in 'workers' in shell replay
-rwxr-xr-xtools/reproduceriter.py11
1 files changed, 7 insertions, 4 deletions
diff --git a/tools/reproduceriter.py b/tools/reproduceriter.py
index 2255b210..2f09efc0 100755
--- a/tools/reproduceriter.py
+++ b/tools/reproduceriter.py
@@ -345,10 +345,12 @@ if (typeof nagivator == 'undefined') {
});
};
var Worker = function(path) {
- // XXX We need to sandbox more securely. In particular Date.now() and performance.now() need to be unpatched during calls to worker code (right now they consume recorded values!)
path = fixPath(path);
var workerCode = read(path);
- workerCode = workerCode.replace(/Module/g, 'zzModuleyy' + (Worker.id++)); // prevent collision with the global Module object. Note that this becomes global, so we need unique ids
+ workerCode = workerCode.replace(/Module/g, 'zzModuleyy' + (Worker.id++)). // prevent collision with the global Module object. Note that this becomes global, so we need unique ids
+ replace(/Date.now/g, 'Recorder.dnow'). // recorded values are just for the "main thread" - workers were not recorded, and should not consume
+ replace(/performance.now/g, 'Recorder.pnow').
+ replace(/Math.random/g, 'Recorder.random');
print('loading worker ' + path + ' : ' + workerCode.substring(0, 50));
eval(workerCode); // will implement onmessage()
@@ -431,9 +433,9 @@ var Recorder = (function() {
};
// Math.random
recorder.randoms = [];
- var random = Math.random;
+ recorder.random = Math.random;
Math.random = function() {
- var ret = random();
+ var ret = recorder.random();
recorder.randoms.push(ret);
return ret;
};
@@ -545,6 +547,7 @@ var Recorder = (function() {
count();
};
// Math.random
+ recorder.random = Math.random;
Math.random = function() {
if (recorder.randoms.length > 0) {
return recorder.randoms.pop();