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

Side by Side Diff: tests/compiler/dart2js_extra/deferred_fail_and_retry_worker_test.dart

Issue 2345083003: dart2js: run dartfmt on tests (Closed)
Patch Set: revert another multipart test 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 // Test that when a deferred import from a worker fails to load, it is possible 5 // Test that when a deferred import from a worker fails to load, it is possible
6 // to retry. 6 // to retry.
7 7
8 import "deferred_fail_and_retry_lib.dart" deferred as lib; 8 import "deferred_fail_and_retry_lib.dart" deferred as lib;
9 import "package:expect/expect.dart"; 9 import "package:expect/expect.dart";
10 import "package:async_helper/async_helper.dart"; 10 import "package:async_helper/async_helper.dart";
11 import "dart:isolate"; 11 import "dart:isolate";
12 import "dart:js" as js; 12 import "dart:js" as js;
13 13
14 void test(SendPort sendPort) { 14 void test(SendPort sendPort) {
15 // Patch XMLHttpRequest to fail on first load. 15 // Patch XMLHttpRequest to fail on first load.
16 js.context.callMethod("eval", [""" 16 js.context.callMethod("eval", [
17 """
17 oldXMLHttpRequest = XMLHttpRequest; 18 oldXMLHttpRequest = XMLHttpRequest;
18 XMLHttpRequest = function() { 19 XMLHttpRequest = function() {
19 XMLHttpRequest = oldXMLHttpRequest; 20 XMLHttpRequest = oldXMLHttpRequest;
20 var instance = new XMLHttpRequest(); 21 var instance = new XMLHttpRequest();
21 this.addEventListener = function(x, y, z) { 22 this.addEventListener = function(x, y, z) {
22 instance.addEventListener(x, y, z); 23 instance.addEventListener(x, y, z);
23 } 24 }
24 this.send = function() { 25 this.send = function() {
25 instance.send(); 26 instance.send();
26 } 27 }
27 this.open = function(x, uri) { 28 this.open = function(x, uri) {
28 instance.open(x, "non_existing.js"); 29 instance.open(x, "non_existing.js");
29 } 30 }
30 } 31 }
31 """]); 32 """
33 ]);
32 lib.loadLibrary().then((_) { 34 lib.loadLibrary().then((_) {
33 sendPort.send("Library should not have loaded"); 35 sendPort.send("Library should not have loaded");
34 }, onError: (error) { 36 }, onError: (error) {
35 sendPort.send("failed"); 37 sendPort.send("failed");
36 lib.loadLibrary().then((_) { 38 lib.loadLibrary().then((_) {
37 sendPort.send(lib.foo()); 39 sendPort.send(lib.foo());
38 }, onError: (error) { 40 }, onError: (error) {
39 sendPort.send("Library should have loaded this time $error"); 41 sendPort.send("Library should have loaded this time $error");
40 }); 42 });
41 }); 43 });
42 } 44 }
43 45
44
45 main() { 46 main() {
46 ReceivePort receivePort = new ReceivePort(); 47 ReceivePort receivePort = new ReceivePort();
47 asyncStart(); 48 asyncStart();
48 bool receivedFailed = false; 49 bool receivedFailed = false;
49 receivePort.listen((message) { 50 receivePort.listen((message) {
50 if (!receivedFailed) { 51 if (!receivedFailed) {
51 Expect.equals("failed", message); 52 Expect.equals("failed", message);
52 receivedFailed = true; 53 receivedFailed = true;
53 } else { 54 } else {
54 Expect.equals("loaded", message); 55 Expect.equals("loaded", message);
55 asyncEnd(); 56 asyncEnd();
56 } 57 }
57 }); 58 });
58 Isolate.spawn(test, receivePort.sendPort); 59 Isolate.spawn(test, receivePort.sendPort);
59 } 60 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698