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

Unified Diff: tests/html/js_test.dart

Issue 26270003: Cleanup JS() expressions. New Constructor for JsObject that preserves the correct prototype. Type c… (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 2 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 | « sdk/lib/js/dartium/js_dartium.dart ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tests/html/js_test.dart
diff --git a/tests/html/js_test.dart b/tests/html/js_test.dart
index 290a0fbb85e5b77cdcd43b4cacc06109668ef362..d4294168001eb555fcdc573eae0831e9fbf27efc 100644
--- a/tests/html/js_test.dart
+++ b/tests/html/js_test.dart
@@ -124,6 +124,10 @@ function Baz(p1,p2,p3,p4,p5,p6,p7,p8,p9,p10,p11) {
this.f10 = p10;
this.f11 = p11;
}
+
+function identical(o1, o2) {
+ return o1 === o2;
+}
""";
document.body.append(script);
}
@@ -147,14 +151,63 @@ class Color implements Serializable<String> {
String toJs() => this._value;
}
+class TestDartObject {}
+
main() {
_injectJs();
useHtmlConfiguration();
- test('context instances should be identical', () {
- var c1 = context;
- var c2 = context;
- expect(identical(c1, c2), isTrue);
+ group('identity', () {
+
+ test('context instances should be identical', () {
+ var c1 = context;
+ var c2 = context;
+ expect(identical(c1, c2), isTrue);
+ });
+
+ test('identical JS objects should have identical proxies', () {
+ var o1 = new JsObject(context['Foo'], [1]);
+ context['f1'] = o1;
+ var o2 = context['f1'];
+ expect(identical(o1, o2), isTrue);
+ });
+
+ test('identical JS functions should have identical proxies', () {
+ var f1 = context['Object'];
+ var f2 = context['Object'];
+ expect(identical(f1, f2), isTrue);
+ });
+
+ test('identical Dart objects should have identical proxies', () {
+ var o1 = new TestDartObject();
+ expect(context.callMethod('identical', [o1, o1]), isTrue);
+ });
+
+ test('identical Dart functions should have identical proxies', () {
+ var f1 = () => print("I'm a Function!");
+ expect(context.callMethod('identical', [f1, f1]), isTrue);
+ });
+
+ // TODO(justinfagnani): old tests duplicate checks above, remove
+ // on test next cleanup pass
+ test('test proxy equality', () {
+ var foo1 = new JsObject(context['Foo'], [1]);
+ var foo2 = new JsObject(context['Foo'], [2]);
+ context['foo1'] = foo1;
+ context['foo2'] = foo2;
+ expect(foo1, isNot(equals(context['foo2'])));
+ expect(foo2, same(context['foo2']));
+ context.deleteProperty('foo1');
+ context.deleteProperty('foo2');
+ });
+
+ test('retrieve same dart Object', () {
+ final date = new DateTime.now();
+ context['dartDate'] = date;
+ expect(context['dartDate'], same(date));
+ context.deleteProperty('dartDate');
+ });
+
});
test('read global field', () {
@@ -275,8 +328,9 @@ main() {
test('js instantiation : >10 parameters', () {
final o = new JsObject(context['Baz'], [1,2,3,4,5,6,7,8,9,10,11]);
for (var i = 1; i <= 11; i++) {
- o["f$i"] = i;
+ expect(o["f$i"], i);
}
+ expect(o['constructor'], same(context['Baz']));
});
test('write global field', () {
@@ -411,15 +465,6 @@ main() {
expect(result, 42);
});
- test('test proxy equality', () {
- var foo1 = new JsObject(context['Foo'], [1]);
- var foo2 = new JsObject(context['Foo'], [2]);
- context['foo'] = foo1;
- context['foo'] = foo2;
- expect(foo1, isNot(equals(context['foo'])));
- expect(foo2, equals(context['foo']));
- });
-
test('test instanceof', () {
var foo = new JsObject(context['Foo'], [1]);
expect(foo.instanceof(context['Foo']), isTrue);
@@ -461,12 +506,6 @@ main() {
expect(context['Bar']['foo'], "property_value");
});
- test('retrieve same dart Object', () {
- final date = new DateTime.now();
- context['dartDate'] = date;
- expect(context['dartDate'], equals(date));
- });
-
test('usage of Serializable', () {
final red = Color.RED;
context['color'] = red;
« no previous file with comments | « sdk/lib/js/dartium/js_dartium.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698