diff options
author | Janus <ysangkok@gmail.com> | 2012-10-11 14:01:54 +0200 |
---|---|---|
committer | Janus <ysangkok@gmail.com> | 2012-10-11 14:01:54 +0200 |
commit | 140dccb5663212c2c8027aa12597a095f1356a89 (patch) | |
tree | 425572319d357bc9bc936053104b124827a5ba45 /src/shell.js | |
parent | b614f2bc5d9fc421565824b1ceb9a3384f26f35f (diff) |
fix synchronous xhr in webworkers by reintroducing code deleted in be163123
Diffstat (limited to 'src/shell.js')
-rw-r--r-- | src/shell.js | 26 |
1 files changed, 22 insertions, 4 deletions
diff --git a/src/shell.js b/src/shell.js index 891a6328..065462e1 100644 --- a/src/shell.js +++ b/src/shell.js @@ -44,7 +44,9 @@ if (ENVIRONMENT_IS_NODE) { if (!Module['arguments']) { Module['arguments'] = process['argv'].slice(2); } -} else if (ENVIRONMENT_IS_SHELL) { +} + +if (ENVIRONMENT_IS_SHELL) { Module['print'] = print; if (typeof printErr != 'undefined') Module['printErr'] = printErr; // not present in v8 or older sm @@ -62,7 +64,9 @@ if (ENVIRONMENT_IS_NODE) { Module['arguments'] = arguments; } } -} else if (ENVIRONMENT_IS_WEB) { +} + +if (ENVIRONMENT_IS_WEB) { if (!Module['print']) { Module['print'] = function(x) { console.log(x); @@ -74,7 +78,9 @@ if (ENVIRONMENT_IS_NODE) { console.log(x); }; } +} +if (ENVIRONMENT_IS_WEB || ENVIRONMENT_IS_WORKER) { Module['read'] = function(url) { var xhr = new XMLHttpRequest(); xhr.open('GET', url, false); @@ -87,12 +93,24 @@ if (ENVIRONMENT_IS_NODE) { Module['arguments'] = arguments; } } -} else if (ENVIRONMENT_IS_WORKER) { +} + +if (ENVIRONMENT_IS_WORKER) { // We can do very little here... + var TRY_USE_DUMP = false; + if (!Module['print']) { + Module['print'] = (TRY_USE_DUMP && (typeof(dump) !== "undefined") ? (function(x) { + dump(x); + }) : (function(x) { + self.postMessage(x); + })); + } Module['load'] = importScripts; +} -} else { +if (!ENVIRONMENT_IS_WORKER && !ENVIRONMENT_IS_WEB && !ENVIRONMENT_IS_NODE && !ENVIRONMENT_IS_SHELL) { + // Unreachable because SHELL is dependant on the others throw 'Unknown runtime environment. Where are we?'; } |