Index: tests/html/postmessage_structured_test.dart |
diff --git a/tests/html/postmessage_structured_test.dart b/tests/html/postmessage_structured_test.dart |
index 8581dc280ca6c18cf5e7f4f5a90da94fb249aaa2..b52ecc4573d60c0a132aba1ef91806589b82d2ec 100644 |
--- a/tests/html/postmessage_structured_test.dart |
+++ b/tests/html/postmessage_structured_test.dart |
@@ -26,20 +26,18 @@ main() { |
final JS_CODE = """ |
window.postMessage({eggs: 3}, '*'); |
"""; |
- var callback; |
- var onSuccess = expectAsync1((e) { |
- window.on.message.remove(callback); |
- }); |
- callback = (e) { |
- guardAsync(() { |
- var data = e.data; |
- if (data is String) return; // Messages from unit test protocol. |
- expect(data, isMap); |
- expect(data['eggs'], equals(3)); |
- onSuccess(e); |
- }); |
- }; |
- window.on.message.add(callback); |
+ var completed = false; |
+ var subscription = null; |
+ subscription = window.onMessage.listen(expectAsyncUntil1( |
+ (e) { |
+ var data = e.data; |
+ if (data is String) return; // Messages from unit test protocol. |
+ completed = true; |
+ subscription.cancel(); |
+ expect(data, isMap); |
+ expect(data['eggs'], equals(3)); |
+ }, |
+ () => completed)); |
injectSource(JS_CODE); |
}); |
@@ -58,21 +56,19 @@ main() { |
window.postMessage(response, '*'); |
} |
"""; |
- var callback; |
- var onSuccess = expectAsync1((e) { |
- window.on.message.remove(callback); |
- }); |
- callback = (e) { |
- guardAsync(() { |
- var data = e.data; |
- if (data is String) return; // Messages from unit test protocol. |
- expect(data, isMap); |
- if (data['recipient'] != 'DART') return; // Hearing the sent message. |
- expect(data['peas'], equals(50)); |
- onSuccess(e); |
- }); |
- }; |
- window.on.message.add(callback); |
+ var completed = false; |
+ var subscription = null; |
+ subscription = window.onMessage.listen(expectAsyncUntil1( |
+ (e) { |
+ var data = e.data; |
+ if (data is String) return; // Messages from unit test protocol. |
+ if (data['recipient'] != 'DART') return; // Hearing the sent message. |
+ completed = true; |
+ subscription.cancel(); |
+ expect(data, isMap); |
+ expect(data['peas'], equals(50)); |
+ }, |
+ () => completed)); |
injectSource(JS_CODE); |
window.postMessage({'recipient': 'JS', 'curry': 'peas'}, '*'); |
}); |
@@ -93,22 +89,21 @@ main() { |
window.postMessage(response, '*'); |
} |
"""; |
- var onSuccess = expectAsync0(() {}); |
- callback(e) { |
- guardAsync(() { |
- var data = e.data; |
- if (data is String) return; // Messages from unit test protocol. |
- expect(data, isMap); |
- if (data['recipient'] != 'DART') return; // Not for me. |
- var returnedValue = data['data']; |
- |
- window.on.message.remove(callback); |
- expect(returnedValue, isNot(same(value))); |
- verifyGraph(value, returnedValue); |
- onSuccess(); |
- }); |
- }; |
- window.on.message.add(callback); |
+ var completed = false; |
+ var subscription = null; |
+ subscription = window.onMessage.listen(expectAsyncUntil1( |
+ (e) { |
+ var data = e.data; |
+ if (data is String) return; // Messages from unit test protocol. |
Emily Fortuna
2013/01/28 23:15:18
delete one space here and you can get this line ba
|
+ if (data['recipient'] != 'DART') return; // Not for me. |
+ completed = true; |
+ subscription.cancel(); |
+ expect(data, isMap); |
+ var returnedValue = data['data']; |
+ expect(returnedValue, isNot(same(value))); |
+ verifyGraph(value, returnedValue); |
+ }, |
+ () => completed)); |
injectSource(JS_CODE); |
window.postMessage({'recipient': 'JS', 'data': value}, '*'); |
}); |