diff options
-rw-r--r-- | src/proxyClient.js | 11 | ||||
-rw-r--r-- | src/proxyWorker.js | 5 |
2 files changed, 16 insertions, 0 deletions
diff --git a/src/proxyClient.js b/src/proxyClient.js index 645ccca6..e3e2dfea 100644 --- a/src/proxyClient.js +++ b/src/proxyClient.js @@ -3,3 +3,14 @@ var worker = new Worker('{{{ filename }}}.js'); +worker.onmessage = function(event) { + var data = event.data; + switch (data.target) { + case 'window': { + window[data.method](); + break; + } + default: throw 'what?'; + } +}; + diff --git a/src/proxyWorker.js b/src/proxyWorker.js index 2798b3d0..e69882a9 100644 --- a/src/proxyWorker.js +++ b/src/proxyWorker.js @@ -9,6 +9,11 @@ function EventListener() { }; var window = new EventListener(); + +window.close = function() { + postMessage({ target: 'window', method: 'close' }); +}; + var document = new EventListener(); document.createElement = function(what) { |