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

Unified Diff: tests/html/js_interop_2_test.dart

Issue 10696092: Initial tests for JS interop (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years, 6 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
Index: tests/html/js_interop_2_test.dart
diff --git a/tests/html/js_interop_2_test.dart b/tests/html/js_interop_2_test.dart
new file mode 100644
index 0000000000000000000000000000000000000000..6f2ff247a6723936eba68e06c79909bc51b35d05
--- /dev/null
+++ b/tests/html/js_interop_2_test.dart
@@ -0,0 +1,43 @@
+#library('JsInterop2Test');
kasperl 2012/07/04 05:13:00 Add copyright notice.
vsm 2012/07/04 07:43:09 Done.
+#import('../../lib/unittest/unittest.dart');
+#import('../../lib/unittest/html_config.dart');
+#import('dart:html');
+#import('dart:json');
+
+injectSource(code) {
+ final script = new ScriptElement();
+ script.type = 'text/javascript';
+ script.innerHTML = code;
+ document.body.nodes.add(script);
+}
+
+isolateTest = """
+ function test(data) {
+ if (data == 'sent')
+ return 'received';
+ }
+
+ var port = new ReceivePortSync(test);
+ window.registerPort('test', port.toSendPort());
+""";
+
+main() {
+ useHtmlConfiguration();
+ var callback;
+ test('dart.js', () {
+ callback = expectAsync1((e) {
kasperl 2012/07/04 05:13:00 The indentation is a bit messed up here too (all c
vsm 2012/07/04 07:43:09 Done.
+ Expect.isTrue(e.data);
+ window.on.message.remove(callback);
+ });
+ window.on.message.add(callback);
+ injectSource(@"window.postMessage(window._$dart$initialized, '*');");
+ });
+
+ test('isolateTest', () {
+ injectSource(isolateTest);
+
+ var port = window.lookupPort('test');
+ var result = port.call('sent');
+ Expect.equals('received', result);
kasperl 2012/07/04 05:13:00 Check that port.call('fish') is null?
vsm 2012/07/04 07:43:09 Done.
+ });
+}

Powered by Google App Engine
This is Rietveld 408576698