OLD | NEW |
1 #library('DOMIsolatesTest'); | 1 #library('DOMIsolatesTest'); |
2 #import('../../../../lib/unittest/unittest_dom.dart'); | 2 #import('../../../../lib/unittest/unittest.dart'); |
| 3 #import('../../../../lib/unittest/dom_config.dart'); |
3 #import('dart:dom'); | 4 #import('dart:dom'); |
4 #import('dart:isolate'); | 5 #import('dart:isolate'); |
5 | 6 |
6 isolateMain(port) { | 7 isolateMain(port) { |
7 port.receive((msg, replyTo) { | 8 port.receive((msg, replyTo) { |
8 if (msg != 'check') { | 9 if (msg != 'check') { |
9 replyTo.send('wrong msg: $msg'); | 10 replyTo.send('wrong msg: $msg'); |
10 } | 11 } |
11 replyTo.send(window.location.toString()); | 12 replyTo.send(window.location.toString()); |
12 port.close(); | 13 port.close(); |
13 }); | 14 }); |
14 } | 15 } |
15 | 16 |
16 isolateMainTrampoline(port) { | 17 isolateMainTrampoline(port) { |
17 final childPortFuture = spawnDomIsolate(window, 'isolateMain'); | 18 final childPortFuture = spawnDomIsolate(window, 'isolateMain'); |
18 port.receive((msg, parentPort) { | 19 port.receive((msg, parentPort) { |
19 childPortFuture.then((childPort) { | 20 childPortFuture.then((childPort) { |
20 childPort.call(msg).then((response) { | 21 childPort.call(msg).then((response) { |
21 parentPort.send(response); | 22 parentPort.send(response); |
22 port.close(); | 23 port.close(); |
23 }); | 24 }); |
24 }); | 25 }); |
25 }); | 26 }); |
26 } | 27 } |
27 | 28 |
28 main() { | 29 main() { |
29 forLayoutTests(); | 30 useDomConfiguration(); |
30 | 31 |
31 final iframe = document.createElement('iframe'); | 32 final iframe = document.createElement('iframe'); |
32 document.body.appendChild(iframe); | 33 document.body.appendChild(iframe); |
33 | 34 |
34 asyncTest('Simple DOM isolate test', 1, () { | 35 asyncTest('Simple DOM isolate test', 1, () { |
35 spawnDomIsolate(iframe.contentWindow, 'isolateMain').then((sendPort) { | 36 spawnDomIsolate(iframe.contentWindow, 'isolateMain').then((sendPort) { |
36 sendPort.call('check').then((msg) { | 37 sendPort.call('check').then((msg) { |
37 Expect.equals('about:blank', msg); | 38 Expect.equals('about:blank', msg); |
38 callbackDone(); | 39 callbackDone(); |
39 }); | 40 }); |
(...skipping 10 matching lines...) Expand all Loading... |
50 }); | 51 }); |
51 | 52 |
52 test('Null as target window', () { | 53 test('Null as target window', () { |
53 expectThrow(() => spawnDomIsolate(null, 'isolateMain')); | 54 expectThrow(() => spawnDomIsolate(null, 'isolateMain')); |
54 }); | 55 }); |
55 | 56 |
56 test('Not window as target window', () { | 57 test('Not window as target window', () { |
57 expectThrow(() => spawnDomIsolate(document, 'isolateMain')); | 58 expectThrow(() => spawnDomIsolate(document, 'isolateMain')); |
58 }); | 59 }); |
59 } | 60 } |
OLD | NEW |