Index: client/tests/client/dom/DOMIsolatesTest.dart |
diff --git a/client/tests/client/dom/DOMIsolatesTest.dart b/client/tests/client/dom/DOMIsolatesTest.dart |
new file mode 100644 |
index 0000000000000000000000000000000000000000..210496a1c0745ee0108a4cb74314f2bfb7df4f12 |
--- /dev/null |
+++ b/client/tests/client/dom/DOMIsolatesTest.dart |
@@ -0,0 +1,58 @@ |
+#library('DOMIsolatesTest'); |
+#import('../../../testing/unittest/unittest.dart'); |
+#import('dart:dom'); |
+ |
+isolateMain(port) { |
+ port.receive((msg, replyTo) { |
+ if (msg != 'check') { |
+ replyTo.send('wrong msg: $msg'); |
+ } |
+ replyTo.send(window.location.toString()); |
+ port.close(); |
+ }); |
+} |
+ |
+isolateMainTrampoline(port) { |
+ final childPortFuture = spawnDomIsolate(window, 'isolateMain'); |
+ port.receive((msg, parentPort) { |
+ childPortFuture.then((childPort) { |
+ childPort.call(msg).receive((response, _) { |
+ parentPort.send(response); |
+ port.close(); |
+ }); |
+ }); |
+ }); |
+} |
+ |
+main() { |
+ forLayoutTests(); |
+ |
+ final iframe = document.createElement('iframe'); |
+ document.body.appendChild(iframe); |
+ |
+ asyncTest('Simple DOM isolate test', 1, () { |
+ spawnDomIsolate(iframe.contentWindow, 'isolateMain').then((sendPort) { |
+ sendPort.call('check').receive((msg, replyTo) { |
+ Expect.equals('about:blank', msg); |
+ callbackDone(); |
+ }); |
+ }); |
+ }); |
+ |
+ asyncTest('Nested DOM isolates test', 1, () { |
+ spawnDomIsolate(iframe.contentWindow, 'isolateMainTrampoline').then((sendPort) { |
+ sendPort.call('check').receive((msg, replyTo) { |
+ Expect.equals('about:blank', msg); |
+ callbackDone(); |
+ }); |
+ }); |
+ }); |
+ |
+ test('Null as target window', () { |
+ expectThrow(() => spawnDomIsolate(null, 'isolateMain')); |
+ }); |
+ |
+ test('Not window as target window', () { |
+ expectThrow(() => spawnDomIsolate(document, 'isolateMain')); |
+ }); |
+} |