aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAlon Zakai <alonzakai@gmail.com>2013-09-08 15:39:38 -0700
committerAlon Zakai <alonzakai@gmail.com>2013-09-08 15:39:38 -0700
commit4b23f881076704b5279657d43f4f599a15de9750 (patch)
tree223280ef46f1a088d7eb1ae0edf5332c19d4945b /src
parent1a7cf7ee13d06ea3c95818fe7d3262e155e4e61d (diff)
proxy window.close
Diffstat (limited to 'src')
-rw-r--r--src/proxyClient.js11
-rw-r--r--src/proxyWorker.js5
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) {