Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(74)

Side by Side Diff: tests/html/js_interop_2_test.dart

Issue 10696092: Initial tests for JS interop (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
(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 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698