OLD | NEW |
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file |
2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
3 // BSD-style license that can be found in the LICENSE file | 3 // BSD-style license that can be found in the LICENSE file |
4 | 4 |
5 library DOMIsolatesTest; | 5 library DOMIsolatesTest; |
6 import '../../pkg/unittest/lib/unittest.dart'; | 6 import '../../pkg/unittest/lib/unittest.dart'; |
7 import '../../pkg/unittest/lib/html_config.dart'; | 7 import '../../pkg/unittest/lib/html_config.dart'; |
8 import 'dart:html'; | 8 import 'dart:html'; |
9 import 'dart:isolate'; | 9 import 'dart:isolate'; |
10 | 10 |
(...skipping 18 matching lines...) Expand all Loading... |
29 }); | 29 }); |
30 }); | 30 }); |
31 } | 31 } |
32 | 32 |
33 dummy() => print('Bad invocation of top-level function'); | 33 dummy() => print('Bad invocation of top-level function'); |
34 | 34 |
35 main() { | 35 main() { |
36 useHtmlConfiguration(); | 36 useHtmlConfiguration(); |
37 | 37 |
38 test('Simple DOM isolate test', () { | 38 test('Simple DOM isolate test', () { |
39 spawnDomFunction(childDomIsolate).then((sendPort) { | 39 spawnDomFunction(childDomIsolate).then(expectAsync1( |
40 expect(sendPort.call('check'), completion('${window.location}')); | 40 (sendPort) { |
41 }); | 41 expect(sendPort.call('check'), completion('${window.location}')); |
| 42 } |
| 43 )); |
42 }); | 44 }); |
43 | 45 |
44 test('Nested DOM isolates test', () { | 46 test('Nested DOM isolates test', () { |
45 spawnDomFunction(trampolineIsolate).then((sendPort) { | 47 spawnDomFunction(trampolineIsolate).then(expectAsync1( |
46 expect(sendPort.call('check'), completion('${window.location}')); | 48 (sendPort) { |
47 }); | 49 expect(sendPort.call('check'), completion('${window.location}')); |
| 50 } |
| 51 )); |
48 }); | 52 }); |
49 | 53 |
50 test('Spawn DOM isolate from pure', () { | 54 test('Spawn DOM isolate from pure', () { |
51 expect(spawnFunction(trampolineIsolate).call('check'), | 55 expect(spawnFunction(trampolineIsolate).call('check'), |
52 completion('${window.location}')); | 56 completion('${window.location}')); |
53 }); | 57 }); |
54 | 58 |
| 59 test('Spawn DOM by uri', () { |
| 60 spawnDomUri('dom_isolates_test.dart.child_isolate.dart').then(expectAsync1( |
| 61 (sendPort) { |
| 62 expect(sendPort.call('check'), completion('${window.location}')); |
| 63 } |
| 64 )); |
| 65 }); |
| 66 |
55 test('Not function', () { | 67 test('Not function', () { |
56 expect(() => spawnDomFunction(42), throws); | 68 expect(() => spawnDomFunction(42), throws); |
57 }); | 69 }); |
58 | 70 |
59 test('Not topLevelFunction', () { | 71 test('Not topLevelFunction', () { |
60 var closure = guardAsync(() {}); | 72 var closure = guardAsync(() {}); |
61 expect(() => spawnDomFunction(closure), throws); | 73 expect(() => spawnDomFunction(closure), throws); |
62 }); | 74 }); |
63 | 75 |
64 test('Masked local function', () { | 76 test('Masked local function', () { |
65 var local = 42; | 77 var local = 42; |
66 dummy() => print('Bad invocation of local function: $local'); | 78 dummy() => print('Bad invocation of local function: $local'); |
67 expect(() => spawnDomFunction(dummy), throws); | 79 expect(() => spawnDomFunction(dummy), throws); |
68 }); | 80 }); |
69 } | 81 } |
OLD | NEW |