diff options
author | Alon Zakai <alonzakai@gmail.com> | 2012-09-11 17:13:55 -0700 |
---|---|---|
committer | Alon Zakai <alonzakai@gmail.com> | 2012-09-11 17:13:55 -0700 |
commit | 9309a720c907d268546d6048729112f98df4d639 (patch) | |
tree | 956e71ef1012419397fde456949cfad3e2dd43f6 /tools/reproduceriter.py | |
parent | 18bf95e49f0c74e285c40fb779700f0d120c30ad (diff) |
start to add dom shims for shell in reproduceriter
Diffstat (limited to 'tools/reproduceriter.py')
-rwxr-xr-x | tools/reproduceriter.py | 48 |
1 files changed, 44 insertions, 4 deletions
diff --git a/tools/reproduceriter.py b/tools/reproduceriter.py index 675fd5d6..e06cdc72 100755 --- a/tools/reproduceriter.py +++ b/tools/reproduceriter.py @@ -79,18 +79,19 @@ Examples * BananaBread: Unpack into a directory called bb, then one directory up, run - emscripten/tools/reproduceriter.py bb bench js/game-setup.js + emscripten/tools/reproduceriter.py bb bench js/game-setup.js game.html?low,low,reproduce=repro.data ''' import os, sys, shutil, re -assert len(sys.argv) == 4, 'Usage: reproduceriter.py IN_DIR OUT_DIR FIRST_JS' +assert len(sys.argv) >= 4, 'Usage: reproduceriter.py IN_DIR OUT_DIR FIRST_JS [WINDOW_LOCATION]' # Process input args in_dir = sys.argv[1] out_dir = sys.argv[2] first_js = sys.argv[3] +window_location = sys.argv[4] if len(sys.argv) >= 5 else '' if os.path.exists(out_dir): shutil.rmtree(out_dir) @@ -121,6 +122,42 @@ for parent, dirs, files in os.walk(out_dir): print 'add boilerplate...' open(os.path.join(out_dir, first_js), 'w').write(''' + +// environment for shell +if (typeof nagivator == 'undefined') { + var window = { + location: { + toString: function() { + return '%s'; + }, + search: '%s', + }, + rafs: [], + requestAnimationFrame: function(func) { + window.rafs.push(func); + }, + runEventLoop: function() { + while (1) { // run forever until an exception stops this replay + var currRafs = window.rafs; + window.rafs = []; + for (var i = 0; i < currRafs.length; i++) { + currRafs[i](); + } + } + }, + }; + var document = { + getElementById: function(id) { + return null; + }, + }; + var performance = { + now: function() { + return Date.now(); + }, + }; +} + var Recorder = (function() { var recorder; var init = 'reproduce='; @@ -333,8 +370,11 @@ var Recorder = (function() { recorder.replaying = replaying; return recorder; })(); -''' + open(os.path.join(in_dir, first_js)).read() -) +''' % (window_location, window_location.split('?')[-1]) + open(os.path.join(in_dir, first_js)).read() + ''' +if (typeof nagivator == 'undefined') { + window.runEventLoop(); +} +''') print 'done!' |