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

Side by Side Diff: lib/src/runner/browser/static/host.dart

Issue 2272223003: Stop JSON-encoding cross-frame messages. (Closed) Base URL: git@github.com:dart-lang/test@master
Patch Set: Created 4 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
OLDNEW
1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2015, 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 import 'dart:async'; 5 import 'dart:async';
6 import 'dart:convert'; 6 import 'dart:convert';
7 import 'dart:html'; 7 import 'dart:html';
8 import 'dart:js' as js; 8 import 'dart:js' as js;
9 9
10 import 'package:stack_trace/stack_trace.dart'; 10 import 'package:stack_trace/stack_trace.dart';
11 import 'package:stream_channel/stream_channel.dart'; 11 import 'package:stream_channel/stream_channel.dart';
12 12
13 /// The iframes created for each loaded test suite, indexed by the suite id. 13 /// The iframes created for each loaded test suite, indexed by the suite id.
14 final _iframes = new Map<int, IFrameElement>(); 14 final _iframes = new Map<int, IFrameElement>();
15 15
16 // TODO(nweiz): test this once we can run browser tests.
17 /// Code that runs in the browser and loads test suites at the server's behest. 16 /// Code that runs in the browser and loads test suites at the server's behest.
18 /// 17 ///
19 /// One instance of this runs for each browser. When the server tells it to load 18 /// One instance of this runs for each browser. When the server tells it to load
20 /// a test, it starts an iframe pointing at that test's code; from then on, it 19 /// a test, it starts an iframe pointing at that test's code; from then on, it
21 /// just relays messages between the two. 20 /// just relays messages between the two.
22 /// 21 ///
23 /// The browser uses two layers of [MultiChannel]s when communicating with the 22 /// The browser uses two layers of [MultiChannel]s when communicating with the
24 /// server: 23 /// server:
25 /// 24 ///
26 /// server 25 /// server
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after
157 if (message.data["ready"] == true) { 156 if (message.data["ready"] == true) {
158 readyCompleter.complete(); 157 readyCompleter.complete();
159 } else { 158 } else {
160 controller.local.sink.add(message.data["data"]); 159 controller.local.sink.add(message.data["data"]);
161 } 160 }
162 }); 161 });
163 162
164 controller.local.stream.listen((message) async { 163 controller.local.stream.listen((message) async {
165 await readyCompleter.future; 164 await readyCompleter.future;
166 165
167 // JSON-encode the message to work around sdk#25636, which caused the 166 iframe.contentWindow.postMessage(message, window.location.origin);
168 // structured clone algorithm to be broken with Window.postMessage in
169 // 1.14.{0,1,2}. Once we no longer care about these Dartiums, stop encoding.
170 iframe.contentWindow.postMessage(
171 JSON.encode(message), window.location.origin);
172 }); 167 });
173 168
174 return controller.foreign; 169 return controller.foreign;
175 } 170 }
OLDNEW
« no previous file with comments | « lib/src/runner/browser/post_message_channel.dart ('k') | lib/src/runner/browser/static/host.dart.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698