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

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

Issue 1664433002: Support shelf 0.7.0. (Closed) Base URL: git@github.com:dart-lang/test@master
Patch Set: Code review changes Created 4 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
« no previous file with comments | « lib/src/runner/browser/iframe_test.dart ('k') | lib/src/runner/browser/suite.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) 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:test/src/util/multi_channel.dart'; 11 import 'package:stream_channel/stream_channel.dart';
12 import 'package:test/src/util/stream_channel.dart';
13 12
14 /// 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.
15 final _iframes = new Map<int, IFrameElement>(); 14 final _iframes = new Map<int, IFrameElement>();
16 15
17 // TODO(nweiz): test this once we can run browser tests. 16 // TODO(nweiz): test this once we can run browser tests.
18 /// Code that runs in the browser and loads test suites at the server's behest. 17 /// Code that runs in the browser and loads test suites at the server's behest.
19 /// 18 ///
20 /// One instance of this runs for each browser. When the server tells it to load 19 /// One instance of this runs for each browser. When the server tells it to load
21 /// a test, it starts an iframe pointing at that test's code; from then on, it 20 /// a test, it starts an iframe pointing at that test's code; from then on, it
22 /// just relays messages between the two. 21 /// just relays messages between the two.
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
109 108
110 var inputController = new StreamController(sync: true); 109 var inputController = new StreamController(sync: true);
111 webSocket.onMessage.listen((message) { 110 webSocket.onMessage.listen((message) {
112 inputController.add(JSON.decode(message.data)); 111 inputController.add(JSON.decode(message.data));
113 }); 112 });
114 113
115 var outputController = new StreamController(sync: true); 114 var outputController = new StreamController(sync: true);
116 outputController.stream.listen( 115 outputController.stream.listen(
117 (message) => webSocket.send(JSON.encode(message))); 116 (message) => webSocket.send(JSON.encode(message)));
118 117
119 return new MultiChannel(inputController.stream, outputController.sink); 118 return new MultiChannel(
119 new StreamChannel(inputController.stream, outputController.sink));
120 } 120 }
121 121
122 /// Creates an iframe with `src` [url] and establishes a connection to it using 122 /// Creates an iframe with `src` [url] and establishes a connection to it using
123 /// `postMessage`. 123 /// `postMessage`.
124 /// 124 ///
125 /// [id] identifies the suite loaded in this iframe. 125 /// [id] identifies the suite loaded in this iframe.
126 StreamChannel _connectToIframe(String url, int id) { 126 StreamChannel _connectToIframe(String url, int id) {
127 var iframe = new IFrameElement(); 127 var iframe = new IFrameElement();
128 _iframes[id] = iframe; 128 _iframes[id] = iframe;
129 iframe.src = url; 129 iframe.src = url;
(...skipping 24 matching lines...) Expand all
154 if (!readyCompleter.isCompleted) readyCompleter.complete(); 154 if (!readyCompleter.isCompleted) readyCompleter.complete();
155 }); 155 });
156 156
157 outputController.stream.listen((message) async { 157 outputController.stream.listen((message) async {
158 await readyCompleter.future; 158 await readyCompleter.future;
159 iframe.contentWindow.postMessage(message, window.location.origin); 159 iframe.contentWindow.postMessage(message, window.location.origin);
160 }); 160 });
161 161
162 return new StreamChannel(inputController.stream, outputController.sink); 162 return new StreamChannel(inputController.stream, outputController.sink);
163 } 163 }
OLDNEW
« no previous file with comments | « lib/src/runner/browser/iframe_test.dart ('k') | lib/src/runner/browser/suite.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698