Index: sdk/lib/_internal/js_runtime/lib/isolate_patch.dart |
diff --git a/sdk/lib/_internal/js_runtime/lib/isolate_patch.dart b/sdk/lib/_internal/js_runtime/lib/isolate_patch.dart |
index 82ef73fc79cc0e303c2f0a93b3a0ad311b1af70a..907f275fd3e26ed99e8b097836312582e962a014 100644 |
--- a/sdk/lib/_internal/js_runtime/lib/isolate_patch.dart |
+++ b/sdk/lib/_internal/js_runtime/lib/isolate_patch.dart |
@@ -41,6 +41,9 @@ class Isolate { |
{bool paused: false, bool checked, Uri packageRoot, bool errorsAreFatal, |
SendPort onExit, SendPort onError}) { |
if (packageRoot != null) throw new UnimplementedError("packageRoot"); |
+ bool forcePause = (errorsAreFatal != null) || |
+ (onExit != null) || |
+ (onError != null); |
try { |
if (args is List<String>) { |
for (int i = 0; i < args.length; i++) { |
@@ -51,10 +54,30 @@ class Isolate { |
} else if (args != null) { |
throw new ArgumentError("Args must be a list of Strings $args"); |
} |
- return IsolateNatives.spawnUri(uri, args, message, paused) |
- .then((msg) => new Isolate(msg[1], |
- pauseCapability: msg[2], |
- terminateCapability: msg[3])); |
+ // TODO: Consider passing the errorsAreFatal/onExit/onError values |
+ // as arguments to the internal spawnUri instead of setting |
+ // them after the isolate has been created. |
+ return IsolateNatives.spawnUri(uri, args, message, paused || forcePause) |
+ .then((msg) { |
+ var isolate = new Isolate(msg[1], |
+ pauseCapability: msg[2], |
+ terminateCapability: msg[3]); |
+ if (forcePause) { |
+ if (errorsAreFatal != null) { |
+ isolate.setErrorsFatal(errorsAreFatal); |
+ } |
+ if (onExit != null) { |
+ isolate.addOnExitListener(onExit); |
+ } |
+ if (onError != null) { |
+ isolate.addOnErrorListener(onError); |
+ } |
+ if (!paused) { |
+ isolate.resume(Isolate.pauseCapability); |
+ } |
+ } |
+ return isolate; |
+ }); |
} catch (e, st) { |
return new Future<Isolate>.error(e, st); |
} |