Chromium Code Reviews| Index: tests/html/dom_isolates_test.dart |
| diff --git a/tests/html/dom_isolates_test.dart b/tests/html/dom_isolates_test.dart |
| index 794c250a568c486cb2c896078ca671af8c80fa4c..c44ca87e98eed0aea84cacac36bd9a6800e2ccae 100644 |
| --- a/tests/html/dom_isolates_test.dart |
| +++ b/tests/html/dom_isolates_test.dart |
| @@ -4,59 +4,62 @@ |
| #import('dart:html'); |
| #import('dart:isolate'); |
| -isolateMain(port) { |
| +isolateMain() { |
| port.receive((msg, replyTo) { |
| if (msg != 'check') { |
| replyTo.send('wrong msg: $msg'); |
| } |
| - replyTo.send(window.location.toString()); |
| + replyTo.send(42); |
|
Anton Muhin
2012/08/07 12:55:29
why it's 42? Intent of window.location.toString()
vsm
2012/08/10 00:06:43
Good point. I changed it because it's no longer '
|
| port.close(); |
| }); |
| } |
| -isolateMainTrampoline(port) { |
| - final childPortFuture = spawnDomIsolate(window, 'isolateMain'); |
| +isolateMainTrampoline() { |
| + final childPort = spawnDomFunction(isolateMain); |
| port.receive((msg, parentPort) { |
| - childPortFuture.then((childPort) { |
| - childPort.call(msg).then((response) { |
| - parentPort.send(response); |
| - port.close(); |
| - }); |
| + childPort.call(msg).then((response) { |
| + parentPort.send(response); |
| + port.close(); |
| }); |
| }); |
| } |
| +dummy() => print("Bad invocation of top-level function"); |
| + |
| main() { |
| useHtmlConfiguration(); |
| - final iframe = new Element.tag('iframe'); |
| - document.body.nodes.add(iframe); |
| - |
| test('Simple DOM isolate test', () { |
| - spawnDomIsolate(iframe.contentWindow, 'isolateMain').then( |
| - expectAsync1((sendPort) { |
| - sendPort.call('check').then( |
| - expectAsync1((msg) { |
| - Expect.equals('about:blank', msg); |
| - })); |
| + var sendPort = spawnDomFunction(isolateMain); |
| + sendPort.call('check').then( |
| + expectAsync1((msg) { |
| + expect(msg, equals(42)); |
| })); |
| }); |
| test('Nested DOM isolates test', () { |
| - spawnDomIsolate(iframe.contentWindow, 'isolateMainTrampoline').then( |
| - expectAsync1((sendPort) { |
| - sendPort.call('check').then( |
| - expectAsync1((msg) { |
| - Expect.equals('about:blank', msg); |
| - })); |
| + var sendPort = spawnDomFunction(isolateMainTrampoline); |
|
Anton Muhin
2012/08/07 12:55:29
do you need sendPort at all? spawnDomFunction(iso
vsm
2012/08/10 00:06:43
Done.
|
| + sendPort.call('check').then( |
| + expectAsync1((msg) { |
| + expect(msg, equals(42)); |
| })); |
| }); |
|
Siggi Cherem (dart-lang)
2012/08/03 17:30:57
one more case to test would be a static method in
vsm
2012/08/10 00:06:43
I'll add in a separate CL.
On 2012/08/03 17:30:57
|
| - test('Null as target window', () { |
| - expectThrow(() => spawnDomIsolate(null, 'isolateMain')); |
| + test('Not function', () { |
| + expect(() => spawnDomFunction(42), throws); |
| }); |
| - test('Not window as target window', () { |
| - expectThrow(() => spawnDomIsolate(document, 'isolateMain')); |
| + test('Not topLevelFunction', () { |
| + var closure = guardAsync(() {}); |
| + expect(() => spawnDomFunction(closure), throws); |
| }); |
| + |
| + // TODO(vsm): Enable when 4337 is fixed. |
| + if (false) { |
| + test('Masked local function', () { |
| + var local = 42; |
| + dummy() => print("Bad invocation of local function: $local"); |
| + expect(() => spawnDomFunction(dummy), throws); |
| + }); |
| + } |
| } |