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

Unified Diff: test/js/browser_tests.dart

Issue 12457030: [js-interop] Fix function binding and avoid noSuchMethod when using map notation (Closed) Base URL: https://github.com/dart-lang/js-interop.git@master
Patch Set: Fix for constructors plus cleanup Created 7 years, 8 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: test/js/browser_tests.dart
diff --git a/test/js/browser_tests.dart b/test/js/browser_tests.dart
index 051b71ddbbda233b90d29884fbc79cd5aa41837b..227169b360c16c7267837b5a29b696529d42087f 100644
--- a/test/js/browser_tests.dart
+++ b/test/js/browser_tests.dart
@@ -52,6 +52,15 @@ main() {
});
});
+ test('js instantiation : new Foo()', () {
+ js.scoped(() {
+ final Foo2 = js.context.container.Foo;
+ final foo = new js.Proxy(Foo2, 42);
+ expect(foo.a, 42);
+ expect(Foo2.b, 38);
+ });
+ });
+
test('js instantiation : new Array()', () {
js.scoped(() {
final a = new js.Proxy(js.context.Array);
@@ -128,6 +137,28 @@ main() {
});
});
+ test('js instantiation via map notation : new Array()', () {
+ js.scoped(() {
+ final a = new js.Proxy(js.context['Array']);
+ expect(a, isNotNull);
+ expect(a['length'], equals(0));
+
+ a['push']("value 1");
+ expect(a['length'], equals(1));
+ expect(a[0], equals("value 1"));
+
+ a['pop']();
+ expect(a['length'], equals(0));
+ });
+ });
+
+ test('js instantiation via map notation : new Date()', () {
+ js.scoped(() {
+ final a = new js.Proxy(js.context['Date']);
+ expect(a['getTime'](), isNotNull);
+ });
+ });
+
test('js instantiation : typed array', () {
js.scoped(() {
final codeUnits = "test".codeUnits;
@@ -161,6 +192,20 @@ main() {
});
});
+ test('call JS function via map notation', () {
+ js.scoped(() {
+ expect(js.context['razzle'](), equals(42));
+ expect(() => js.context['dazzle'](), throwsA(isNoSuchMethodError));
+ });
+ });
+
+ test('call JS function with varargs', () {
+ js.scoped(() {
+ expect(js.context.varArgs(1, 2, 3, 4, 5, 6, 7, 8, 9, 10),
+ equals(55));
+ });
+ });
+
test('allocate JS object', () {
js.scoped(() {
var foo = new js.Proxy(js.context.Foo, 42);
« lib/js.dart ('K') | « lib/js.dart ('k') | test/js/browser_tests_bootstrap.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698