| OLD | NEW |
| (Empty) |
| 1 #import('../../../../../dart/client/testing/unittest/unittest.dart'); | |
| 2 #import('dart:dom'); | |
| 3 | |
| 4 isolateMain(port) { | |
| 5 port.receive((msg, replyTo) { | |
| 6 if (msg != 'check') { | |
| 7 replyTo.send('wrong msg: $msg'); | |
| 8 } | |
| 9 replyTo.send(window.location.toString()); | |
| 10 port.close(); | |
| 11 }); | |
| 12 } | |
| 13 | |
| 14 isolateMainTrampoline(port) { | |
| 15 final childPortFuture = spawnDomIsolate(window, 'isolateMain'); | |
| 16 port.receive((msg, parentPort) { | |
| 17 childPortFuture.then((childPort) { | |
| 18 childPort.call(msg).receive((response, _) { | |
| 19 parentPort.send(response); | |
| 20 port.close(); | |
| 21 }); | |
| 22 }); | |
| 23 }); | |
| 24 } | |
| 25 | |
| 26 main() { | |
| 27 forLayoutTests(); | |
| 28 | |
| 29 final iframe = document.createElement('iframe'); | |
| 30 document.body.appendChild(iframe); | |
| 31 | |
| 32 asyncTest('Simple DOM isolate test', 1, () { | |
| 33 spawnDomIsolate(iframe.contentWindow, 'isolateMain').then((sendPort) { | |
| 34 sendPort.call('check').receive((msg, replyTo) { | |
| 35 Expect.equals('about:blank', msg); | |
| 36 callbackDone(); | |
| 37 }); | |
| 38 }); | |
| 39 }); | |
| 40 | |
| 41 asyncTest('Nested DOM isolates test', 1, () { | |
| 42 spawnDomIsolate(iframe.contentWindow, 'isolateMainTrampoline').then((sendPor
t) { | |
| 43 sendPort.call('check').receive((msg, replyTo) { | |
| 44 Expect.equals('about:blank', msg); | |
| 45 callbackDone(); | |
| 46 }); | |
| 47 }); | |
| 48 }); | |
| 49 | |
| 50 test('Null as target window', () { | |
| 51 expectThrow(() => spawnDomIsolate(null, 'isolateMain')); | |
| 52 }); | |
| 53 | |
| 54 test('Not window as target window', () { | |
| 55 expectThrow(() => spawnDomIsolate(document, 'isolateMain')); | |
| 56 }); | |
| 57 } | |
| OLD | NEW |