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

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

Issue 1080193002: Add content shell support. (Closed) Base URL: git@github.com:dart-lang/test@master
Patch Set: Created 5 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
« no previous file with comments | « lib/src/runner/browser/server.dart ('k') | lib/src/runner/browser/static/host.dart.js » ('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 library test.runner.browser.host; 5 library test.runner.browser.host;
6 6
7 import 'dart:async'; 7 import 'dart:async';
8 import 'dart:convert'; 8 import 'dart:convert';
9 import 'dart:html'; 9 import 'dart:html';
10 import 'dart:js' as js;
10 11
11 import 'package:stack_trace/stack_trace.dart'; 12 import 'package:stack_trace/stack_trace.dart';
12 import 'package:test/src/util/multi_channel.dart'; 13 import 'package:test/src/util/multi_channel.dart';
13 import 'package:test/src/util/stream_channel.dart'; 14 import 'package:test/src/util/stream_channel.dart';
14 15
15 // TODO(nweiz): test this once we can run browser tests. 16 // TODO(nweiz): test this once we can run browser tests.
16 /// 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.
17 /// 18 ///
18 /// 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
19 /// 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
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
58 /// running". A new connection is also created whenever a test begins running to 59 /// running". A new connection is also created whenever a test begins running to
59 /// send status messages about its progress. 60 /// send status messages about its progress.
60 /// 61 ///
61 /// It's of particular note that the suite's [MultiChannel] connection uses the 62 /// It's of particular note that the suite's [MultiChannel] connection uses the
62 /// host's purely as a transport layer; neither is aware that the other is also 63 /// host's purely as a transport layer; neither is aware that the other is also
63 /// using [MultiChannel]. This is necessary, since the host doesn't share memory 64 /// using [MultiChannel]. This is necessary, since the host doesn't share memory
64 /// with the suites and thus can't share its [MultiChannel] with them, but it 65 /// with the suites and thus can't share its [MultiChannel] with them, but it
65 /// does mean that the server needs to be sure to nest its [MultiChannel]s at 66 /// does mean that the server needs to be sure to nest its [MultiChannel]s at
66 /// the same place the client does. 67 /// the same place the client does.
67 void main() { 68 void main() {
69 // This tells content_shell not to close immediately after the page has
70 // rendered.
71 var testRunner = js.context['testRunner'];
72 if (testRunner != null) testRunner.callMethod('waitUntilDone', []);
73
68 runZoned(() { 74 runZoned(() {
69 var serverChannel = _connectToServer(); 75 var serverChannel = _connectToServer();
70 serverChannel.stream.listen((message) { 76 serverChannel.stream.listen((message) {
71 assert(message['command'] == 'loadSuite'); 77 assert(message['command'] == 'loadSuite');
72 var suiteChannel = serverChannel.virtualChannel(message['channel']); 78 var suiteChannel = serverChannel.virtualChannel(message['channel']);
73 var iframeChannel = _connectToIframe(message['url']); 79 var iframeChannel = _connectToIframe(message['url']);
74 suiteChannel.pipe(iframeChannel); 80 suiteChannel.pipe(iframeChannel);
75 }); 81 });
76 }, onError: (error, stackTrace) { 82 }, onError: (error, stackTrace) {
77 print("$error\n${new Trace.from(stackTrace).terse}"); 83 print("$error\n${new Trace.from(stackTrace).terse}");
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
129 readyCompleter.complete(); 135 readyCompleter.complete();
130 }); 136 });
131 137
132 outputController.stream.listen((message) { 138 outputController.stream.listen((message) {
133 readyCompleter.future.then((_) => 139 readyCompleter.future.then((_) =>
134 iframe.contentWindow.postMessage(message, window.location.origin)); 140 iframe.contentWindow.postMessage(message, window.location.origin));
135 }); 141 });
136 142
137 return new StreamChannel(inputController.stream, outputController.sink); 143 return new StreamChannel(inputController.stream, outputController.sink);
138 } 144 }
OLDNEW
« no previous file with comments | « lib/src/runner/browser/server.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