Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 #library('JsInterop2Test'); | |
|
kasperl
2012/07/04 05:13:00
Add copyright notice.
vsm
2012/07/04 07:43:09
Done.
| |
| 2 #import('../../lib/unittest/unittest.dart'); | |
| 3 #import('../../lib/unittest/html_config.dart'); | |
| 4 #import('dart:html'); | |
| 5 #import('dart:json'); | |
| 6 | |
| 7 injectSource(code) { | |
| 8 final script = new ScriptElement(); | |
| 9 script.type = 'text/javascript'; | |
| 10 script.innerHTML = code; | |
| 11 document.body.nodes.add(script); | |
| 12 } | |
| 13 | |
| 14 isolateTest = """ | |
| 15 function test(data) { | |
| 16 if (data == 'sent') | |
| 17 return 'received'; | |
| 18 } | |
| 19 | |
| 20 var port = new ReceivePortSync(test); | |
| 21 window.registerPort('test', port.toSendPort()); | |
| 22 """; | |
| 23 | |
| 24 main() { | |
| 25 useHtmlConfiguration(); | |
| 26 var callback; | |
| 27 test('dart.js', () { | |
| 28 callback = expectAsync1((e) { | |
|
kasperl
2012/07/04 05:13:00
The indentation is a bit messed up here too (all c
vsm
2012/07/04 07:43:09
Done.
| |
| 29 Expect.isTrue(e.data); | |
| 30 window.on.message.remove(callback); | |
| 31 }); | |
| 32 window.on.message.add(callback); | |
| 33 injectSource(@"window.postMessage(window._$dart$initialized, '*');"); | |
| 34 }); | |
| 35 | |
| 36 test('isolateTest', () { | |
| 37 injectSource(isolateTest); | |
| 38 | |
| 39 var port = window.lookupPort('test'); | |
| 40 var result = port.call('sent'); | |
| 41 Expect.equals('received', result); | |
|
kasperl
2012/07/04 05:13:00
Check that port.call('fish') is null?
vsm
2012/07/04 07:43:09
Done.
| |
| 42 }); | |
| 43 } | |
| OLD | NEW |