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

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

Issue 886673002: Check for null prototype in isJavaScriptSimpleObject (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Eliminate common sub-expression Created 5 years, 10 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 | « sdk/lib/html/html_common/conversions.dart ('k') | no next file » | 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 'package:unittest/unittest.dart'; 6 import 'package:unittest/unittest.dart';
7 import 'package:unittest/html_individual_config.dart'; 7 import 'package:unittest/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 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
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('js-to-dart--null-prototype-eventdata', () {
82 // Pass an object with a null prototype from JavaScript.
83 // It should be seen as a Dart Map.
84 final JS_CODE = """
85 // Call anonymous function to create a local scope.
86 (function() {
87 var o = Object.create(null);
88 o.eggs = 3;
89 var foo = new MessageEvent('stuff', {data: o});
90 window.dispatchEvent(foo);
91 })();
92 """;
93 var completed = false;
94 var subscription = null;
95 subscription = window.on['stuff'].listen(expectAsyncUntil(
96 (MessageEvent e) {
97 var data = e.data;
98 if (data is String) return; // Messages from unit test protocol.
99 completed = true;
100 subscription.cancel();
101 expect(data, isMap);
102 expect(data['eggs'], equals(3));
103 },
104 () => completed));
105 injectSource(JS_CODE);
106 });
107
81 test('dart-to-js-to-dart-postmessage', () { 108 test('dart-to-js-to-dart-postmessage', () {
82 // Pass dictionaries between Dart and JavaScript. 109 // Pass dictionaries between Dart and JavaScript.
83 110
84 final JS_CODE = """ 111 final JS_CODE = """
85 window.addEventListener('message', handler); 112 window.addEventListener('message', handler);
86 function handler(e) { 113 function handler(e) {
87 var data = e.data; 114 var data = e.data;
88 if (typeof data == 'string') return; 115 if (typeof data == 'string') return;
89 if (data.recipient != 'JS') return; 116 if (data.recipient != 'JS') return;
90 var response = {recipient: 'DART'}; 117 var response = {recipient: 'DART'};
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
156 iframe.contentWindow.postMessage(new HashMap<String,num>(), '*'); 183 iframe.contentWindow.postMessage(new HashMap<String,num>(), '*');
157 }); 184 });
158 iframe.src = 'about:blank'; 185 iframe.src = 'about:blank';
159 document.body.append(iframe); 186 document.body.append(iframe);
160 187
161 return future; 188 return future;
162 }); 189 });
163 }); 190 });
164 191
165 } 192 }
OLDNEW
« no previous file with comments | « sdk/lib/html/html_common/conversions.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698