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

Unified Diff: lib/src/runner/browser/static/host.dart

Issue 1080103002: Add support for running tests on Dartium. (Closed) Base URL: git@github.com:dart-lang/test@wip.dartium
Patch Set: Code review changes 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 side-by-side diff with in-line comments
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 »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: lib/src/runner/browser/static/host.dart
diff --git a/lib/src/runner/browser/static/host.dart b/lib/src/runner/browser/static/host.dart
index 4b6673b13eefe5cb5c8609dd4a1942f180ef3ab2..8f6d6154e4feca2d73d63b5fc238564895760618 100644
--- a/lib/src/runner/browser/static/host.dart
+++ b/lib/src/runner/browser/static/host.dart
@@ -106,31 +106,31 @@ StreamChannel _connectToIframe(String url) {
var inputController = new StreamController(sync: true);
var outputController = new StreamController(sync: true);
- iframe.onLoad.first.then((_) {
- // TODO(nweiz): use MessageChannel once Firefox supports it
- // (http://caniuse.com/#search=MessageChannel).
-
- // Send an initial command to give the iframe something to reply to.
- iframe.contentWindow.postMessage(
- {"command": "connect"},
- window.location.origin);
-
- window.onMessage.listen((message) {
- // A message on the Window can theoretically come from any website. It's
- // very unlikely that a malicious site would care about hacking someone's
- // unit tests, let alone be able to find the test server while it's
- // running, but it's good practice to check the origin anyway.
- if (message.origin != window.location.origin) return;
-
- // TODO(nweiz): Stop manually checking href here once issue 22554 is
- // fixed.
- if (message.data["href"] != iframe.src) return;
-
- message.stopPropagation();
- inputController.add(message.data["data"]);
- });
- outputController.stream.listen((message) =>
+ // Use this to avoid sending a message to the iframe before it's sent a
+ // message to us. This ensures that no messages get dropped on the floor.
+ var readyCompleter = new Completer();
+
+ // TODO(nweiz): use MessageChannel once Firefox supports it
+ // (http://caniuse.com/#search=MessageChannel).
+ window.onMessage.listen((message) {
+ // A message on the Window can theoretically come from any website. It's
+ // very unlikely that a malicious site would care about hacking someone's
+ // unit tests, let alone be able to find the test server while it's
+ // running, but it's good practice to check the origin anyway.
+ if (message.origin != window.location.origin) return;
+
+ // TODO(nweiz): Stop manually checking href here once issue 22554 is
+ // fixed.
+ if (message.data["href"] != iframe.src) return;
+
+ message.stopPropagation();
+ inputController.add(message.data["data"]);
+ readyCompleter.complete();
+ });
+
+ outputController.stream.listen((message) {
+ readyCompleter.future.then((_) =>
iframe.contentWindow.postMessage(message, window.location.origin));
});
« 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