diff options
author | Alon Zakai <alonzakai@gmail.com> | 2012-09-12 15:24:56 -0700 |
---|---|---|
committer | Alon Zakai <alonzakai@gmail.com> | 2012-09-12 15:24:56 -0700 |
commit | c351a4faf3f5e8bcc3103bfa67bdef18847a8b80 (patch) | |
tree | cbb959a72f7ee44f3ec04739a528b37ae61ce076 /tools | |
parent | 341ea63b6f109adf914689d9d9a399b363419ba1 (diff) |
Worker and misc fixes in shell replay
Diffstat (limited to 'tools')
-rwxr-xr-x | tools/reproduceriter.py | 45 |
1 files changed, 40 insertions, 5 deletions
diff --git a/tools/reproduceriter.py b/tools/reproduceriter.py index 255dbb2d..ff7dd253 100755 --- a/tools/reproduceriter.py +++ b/tools/reproduceriter.py @@ -146,7 +146,7 @@ if (typeof nagivator == 'undefined') { setTimeout: function(func, ms) { window.timeouts.push({ func: func, - when: window.fakeNow + ms + when: window.fakeNow + (ms || 0) }); window.timeouts.sort(function(x, y) { return y.when - x.when }); }, @@ -222,6 +222,10 @@ if (typeof nagivator == 'undefined') { }, }; }, + styleSheets: [{ + cssRules: [], + insertRule: function(){}, + }], }; //*/ var alert = function(x) { @@ -233,13 +237,18 @@ if (typeof nagivator == 'undefined') { return Date.now(); // XXX XXX XXX }, }; + function fixPath(path) { + if (path[0] == '/') path = path.substring(1); + var dirsToDrop = %d; // go back to root dir if first_js is in a subdir + for (var i = 0; i < dirsToDrop; i++) { + path = '../' + path; + } + return path + } var XMLHttpRequest = function() { return { open: function(mode, path, async) { - if (path[0] == '/') path = path.substring(1); - for (var i = 0; i < %d; i++) { - path = '../' + path; // go back to root dir if first_js is in a subdir - } + path = fixPath(path); this.mode = mode; this.path = path; this.async = async; @@ -267,6 +276,32 @@ if (typeof nagivator == 'undefined') { var Audio = function() { return { play: function(){} }; }; + var Worker = function(path) { + path = fixPath(path); + var workerCode = read(path); + eval(workerCode); // will implement onmessage() + + this.terminate = function(){}; + this.postMessage = function(msg) { + window.setTimeout(function() { + onmessage(msg); + }); + }; + var thisWorker = this; + var postMessage = function(msg) { + if (thisWorker.onmessage) { + window.setTimeout(function() { + thisWorker.onmessage(msg); + }); + } + }; + }; + var screen = { + width: 800, + height: 600, + availWidth: 800, + availHeight: 600, + }; } var Recorder = (function() { |