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

Unified Diff: tests/lib_strong/html/js_typed_interop_dynamic_test.dart

Issue 2668543002: Fix dynamic calls on JS interop classes. (Closed)
Patch Set: Created 3 years, 11 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 | « pkg/dev_compiler/tool/input_sdk/private/js_mirrors.dart ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tests/lib_strong/html/js_typed_interop_dynamic_test.dart
diff --git a/tests/lib_strong/html/js_typed_interop_dynamic_test.dart b/tests/lib_strong/html/js_typed_interop_dynamic_test.dart
new file mode 100644
index 0000000000000000000000000000000000000000..9c77cd8ad5a65c67b0fba788aeeaa145e81937fb
--- /dev/null
+++ b/tests/lib_strong/html/js_typed_interop_dynamic_test.dart
@@ -0,0 +1,55 @@
+// Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+
+@JS()
+library js_typed_interop_anonymous_test;
+
+import 'dart:html';
+import 'dart:js' as js;
+
+import 'package:js/js.dart';
+import 'package:js/js_util.dart' as js_util;
+import 'package:expect/minitest.dart';
+
+@JS()
+@anonymous
+class Literal {
+ external factory Literal({int x, String y, num z, Function foo});
+
+ external int get x;
+ external String get y;
+ external num get z;
+ external Function get foo;
+}
+
+@JS()
+@anonymous
+class FunctionWithExpando {
+ external int call();
+ external String get myExpando;
+}
+
+main() {
+ test('object', () {
+ dynamic l = new Literal(x: 3, y: 'foo', foo: allowInterop((x) => x * 2));
+ expect(l.x, equals(3));
+ expect(l.y, equals('foo'));
+ expect(l.z, isNull);
+ expect(l.foo(4), equals(8));
+ });
+
+ test('function', () {
+ // Get a JS function.
+ dynamic f = js_util.getProperty(window, 'addEventListener');
+ js_util.setProperty(f, 'myExpando', 'foo');
+ expect(f.myExpando, equals('foo'));
+ });
+
+ test('dart object', () {
+ dynamic o = new Object();
+ js_util.setProperty(o, 'x', 3);
+ expect(() => o.x, throwsNoSuchMethodError);
+ expect(() => o.foo(), throwsNoSuchMethodError);
+ });
+}
« no previous file with comments | « pkg/dev_compiler/tool/input_sdk/private/js_mirrors.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698