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

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

Issue 226903002: tests/html: removed usage of deprecated unittest features (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 8 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/mutationobserver_test.dart ('k') | tests/html/url_test.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 postmessage_js_test; 5 library postmessage_js_test;
6 import '../../pkg/unittest/lib/unittest.dart'; 6 import '../../pkg/unittest/lib/unittest.dart';
7 import '../../pkg/unittest/lib/html_individual_config.dart'; 7 import '../../pkg/unittest/lib/html_individual_config.dart';
8 import 'dart:html'; 8 import 'dart:html';
9 import 'dart:collection'; // SplayTreeMap 9 import 'dart:collection'; // SplayTreeMap
10 import 'dart:typed_data'; 10 import 'dart:typed_data';
(...skipping 20 matching lines...) Expand all
31 if (typeof data == 'string') return; 31 if (typeof data == 'string') return;
32 if (data.recipient != 'JS') return; 32 if (data.recipient != 'JS') return;
33 window.console.log(data.data); 33 window.console.log(data.data);
34 var response = {recipient: 'DART', data: data.data}; 34 var response = {recipient: 'DART', data: data.data};
35 window.removeEventListener('message', handler); 35 window.removeEventListener('message', handler);
36 window.postMessage(response, '*'); 36 window.postMessage(response, '*');
37 } 37 }
38 """; 38 """;
39 var completed = false; 39 var completed = false;
40 var subscription = null; 40 var subscription = null;
41 subscription = window.onMessage.listen(expectAsyncUntil1( 41 subscription = window.onMessage.listen(expectAsyncUntil(
42 (e) { 42 (e) {
43 var data = e.data; 43 var data = e.data;
44 if (data is String) return; // Messages from unit test protocol. 44 if (data is String) return; // Messages from unit test protocol.
45 if (data['recipient'] != 'DART') return; // Not for me. 45 if (data['recipient'] != 'DART') return; // Not for me.
46 completed = true; 46 completed = true;
47 subscription.cancel(); 47 subscription.cancel();
48 expect(data, isMap); 48 expect(data, isMap);
49 var returnedValue = data['data']; 49 var returnedValue = data['data'];
50 expect(returnedValue, isNot(same(value))); 50 expect(returnedValue, isNot(same(value)));
51 verifyGraph(value, returnedValue); 51 verifyGraph(value, returnedValue);
52 }, 52 },
53 () => completed)); 53 () => completed));
54 injectSource(JS_CODE); 54 injectSource(JS_CODE);
55 window.postMessage({'recipient': 'JS', 'data': value}, '*'); 55 window.postMessage({'recipient': 'JS', 'data': value}, '*');
56 }); 56 });
57 57
58 group('primitives', () { 58 group('primitives', () {
59 test('js-to-dart-postmessage', () { 59 test('js-to-dart-postmessage', () {
60 // Pass an object literal from JavaScript. It should be seen as a Dart 60 // Pass an object literal from JavaScript. It should be seen as a Dart
61 // Map. 61 // Map.
62 62
63 final JS_CODE = """ 63 final JS_CODE = """
64 window.postMessage({eggs: 3}, '*'); 64 window.postMessage({eggs: 3}, '*');
65 """; 65 """;
66 var completed = false; 66 var completed = false;
67 var subscription = null; 67 var subscription = null;
68 subscription = window.onMessage.listen(expectAsyncUntil1( 68 subscription = window.onMessage.listen(expectAsyncUntil(
69 (e) { 69 (e) {
70 var data = e.data; 70 var data = e.data;
71 if (data is String) return; // Messages from unit test protocol. 71 if (data is String) return; // Messages from unit test protocol.
72 completed = true; 72 completed = true;
73 subscription.cancel(); 73 subscription.cancel();
74 expect(data, isMap); 74 expect(data, isMap);
75 expect(data['eggs'], equals(3)); 75 expect(data['eggs'], equals(3));
76 }, 76 },
77 () => completed)); 77 () => completed));
78 injectSource(JS_CODE); 78 injectSource(JS_CODE);
79 }); 79 });
80 80
81 test('dart-to-js-to-dart-postmessage', () { 81 test('dart-to-js-to-dart-postmessage', () {
82 // Pass dictionaries between Dart and JavaScript. 82 // Pass dictionaries between Dart and JavaScript.
83 83
84 final JS_CODE = """ 84 final JS_CODE = """
85 window.addEventListener('message', handler); 85 window.addEventListener('message', handler);
86 function handler(e) { 86 function handler(e) {
87 var data = e.data; 87 var data = e.data;
88 if (typeof data == 'string') return; 88 if (typeof data == 'string') return;
89 if (data.recipient != 'JS') return; 89 if (data.recipient != 'JS') return;
90 var response = {recipient: 'DART'}; 90 var response = {recipient: 'DART'};
91 response[data['curry']] = 50; 91 response[data['curry']] = 50;
92 window.removeEventListener('message', handler); 92 window.removeEventListener('message', handler);
93 window.postMessage(response, '*'); 93 window.postMessage(response, '*');
94 } 94 }
95 """; 95 """;
96 var completed = false; 96 var completed = false;
97 var subscription = null; 97 var subscription = null;
98 subscription = window.onMessage.listen(expectAsyncUntil1( 98 subscription = window.onMessage.listen(expectAsyncUntil(
99 (e) { 99 (e) {
100 var data = e.data; 100 var data = e.data;
101 if (data is String) return; // Messages from unit test protocol. 101 if (data is String) return; // Messages from unit test protocol.
102 if (data['recipient'] != 'DART') return; // Hearing the sent message. 102 if (data['recipient'] != 'DART') return; // Hearing the sent message.
103 completed = true; 103 completed = true;
104 subscription.cancel(); 104 subscription.cancel();
105 expect(data, isMap); 105 expect(data, isMap);
106 expect(data['peas'], equals(50)); 106 expect(data['peas'], equals(50));
107 }, 107 },
108 () => completed)); 108 () => completed));
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
143 var typed_arrays_list = [view_a, array_buffer, view_b]; 143 var typed_arrays_list = [view_a, array_buffer, view_b];
144 144
145 // Note that FF is failing this test because in the sent message: 145 // Note that FF is failing this test because in the sent message:
146 // view_a.buffer == array_buffer 146 // view_a.buffer == array_buffer
147 // But in the response: 147 // But in the response:
148 // view_a.buffer != array_buffer 148 // view_a.buffer != array_buffer
149 go('typed_arrays_list', typed_arrays_list); 149 go('typed_arrays_list', typed_arrays_list);
150 }); 150 });
151 151
152 } 152 }
OLDNEW
« no previous file with comments | « tests/html/mutationobserver_test.dart ('k') | tests/html/url_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698