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

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

Issue 23868034: Remove spawnDomFunction from dart:html (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 3 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
« no previous file with comments | « tests/html/html.status ('k') | tools/dom/src/native_DOMImplementation.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 JsInterop4Test; 5 library JsInterop4Test;
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:async'; 8 import 'dart:async';
9 import 'dart:html'; 9 import 'dart:html';
10 import 'dart:isolate'; 10 import 'dart:isolate';
11 11
12 const testData = const [1, '2', 'true']; 12 const testData = const [1, '2', 'true'];
13 13
14 void testIsolateEntry() {
15 var fun1 = window.lookupPort('fun1');
16 var result = fun1.callSync(testData);
17
18 var fun2 = window.lookupPort('fun2');
19 fun2.callSync(result);
20 }
21
22 main() { 14 main() {
23 useHtmlConfiguration(); 15 useHtmlConfiguration();
24 16
25 // Test that our interop scheme also works from Dart to Dart. 17 // Test that our interop scheme also works from Dart to Dart.
26 test('dart-to-dart-same-isolate', () { 18 test('dart-to-dart-same-isolate', () {
27 var fun = expectAsync1((message) { 19 var fun = expectAsync1((message) {
28 expect(message, orderedEquals(testData)); 20 expect(message, orderedEquals(testData));
29 return message.length; 21 return message.length;
30 }); 22 });
31 23
32 var port1 = new ReceivePortSync(); 24 var port1 = new ReceivePortSync();
33 port1.receive(fun); 25 port1.receive(fun);
34 window.registerPort('fun', port1.toSendPort()); 26 window.registerPort('fun', port1.toSendPort());
35 27
36 var port2 = window.lookupPort('fun'); 28 var port2 = window.lookupPort('fun');
37 var result = port2.callSync(testData); 29 var result = port2.callSync(testData);
38 expect(result, 3); 30 expect(result, 3);
39 }); 31 });
40
41 // Test across isolate boundary.
42 test('dart-to-dart-cross-isolate', () {
43 var fun1 = (message) {
44 expect(message, orderedEquals(testData));
45 return message.length;
46 };
47
48 var port1 = new ReceivePortSync();
49 port1.receive(fun1);
50 window.registerPort('fun1', port1.toSendPort());
51
52 // TODO(vsm): Investigate why this needs to be called asynchronously.
53 var done = expectAsync0(() {});
54 var fun2 = (message) {
55 expect(message, 3);
56 Timer.run(done);
57 };
58
59 var port2 = new ReceivePortSync();
60 port2.receive(fun2);
61 window.registerPort('fun2', port2.toSendPort());
62
63 spawnDomFunction(testIsolateEntry);
64 });
65 } 32 }
OLDNEW
« no previous file with comments | « tests/html/html.status ('k') | tools/dom/src/native_DOMImplementation.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698