| 51 | |
| 52 | xmlHttpRequest: function(details, callback, onreadychange, onerr, done) { |
| 53 | var cb = function(req) { |
| 54 | if (EMV) console.log("emu: req (" + id + " -" + details.url + " returned: " + req); |
| 55 | |
| 56 | if (req.onLoad && callback) { |
| 57 | if (req.r_id) { |
| 58 | // TODO: Waaaaaaaaaaahhhhhhhhh, bypass special objects like ArrayBuffer, cause they are destroyed when sent by an event |
| 59 | req.response.response = window[req.r_id]; |
| 60 | delete window[req.r_id]; |
| 61 | } |
| 62 | callback(req.response); |
| 63 | } |
| 64 | |
| 65 | if (req.onReadyStateChange && onreadychange) onreadychange(req.response); |
| 66 | if (req.onError && onerr) onerr(req.response); |
| 67 | if (req.onDone && done) done(req.response); |
| 68 | }; |
| 69 | var id = chromeEmu.getResponseId(cb); |
| 70 | var d; |
| 71 | if (typeof details.data === 'object') { |