aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlon Zakai <alonzakai@gmail.com>2012-09-13 17:53:43 -0700
committerAlon Zakai <alonzakai@gmail.com>2012-09-13 17:53:43 -0700
commitc6d27b59bdcf0626ee272a5a3d74180d045d3890 (patch)
tree740fc88d959b95acce9ca4fdc45247e0e04da69e
parent5f140f2ce26ca7c380a16c98c461fb5dfbe9814e (diff)
magic jsoning for typed arrays in shell replay
-rwxr-xr-xtools/reproduceriter.py13
1 files changed, 11 insertions, 2 deletions
diff --git a/tools/reproduceriter.py b/tools/reproduceriter.py
index 5b9c7243..2255b210 100755
--- a/tools/reproduceriter.py
+++ b/tools/reproduceriter.py
@@ -352,11 +352,20 @@ if (typeof nagivator == 'undefined') {
print('loading worker ' + path + ' : ' + workerCode.substring(0, 50));
eval(workerCode); // will implement onmessage()
+ function duplicateJSON(json) {
+ function handleTypedArrays(key, value) {
+ if (value && value.toString && value.toString().substring(0, 8) == '[object ' && value.length && value.byteLength) {
+ return Array.prototype.slice.call(value);
+ }
+ return value;
+ }
+ return JSON.parse(JSON.stringify(json, handleTypedArrays))
+ }
this.terminate = function(){};
this.postMessage = function(msg) {
window.setTimeout(function() {
print('worker ' + path + ' receiving onmessage');
- onmessage({ data: msg });
+ onmessage({ data: duplicateJSON(msg) });
});
};
var thisWorker = this;
@@ -364,7 +373,7 @@ if (typeof nagivator == 'undefined') {
if (thisWorker.onmessage) {
window.setTimeout(function() {
print('main thread receiving message from ' + path);
- thisWorker.onmessage({ data: msg });
+ thisWorker.onmessage({ data: duplicateJSON(msg) });
});
}
};