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

Unified Diff: tests/html/node_test.dart

Issue 15007011: Revert "Revert "dart2js native mixin application should extend 'Interface', not 'Object'"" (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 7 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/web_sql/dart2js/web_sql_dart2js.dart ('k') | tools/dom/scripts/systemhtml.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tests/html/node_test.dart
diff --git a/tests/html/node_test.dart b/tests/html/node_test.dart
index 083478f87b04c33a9a9ab0c38956dec148f90093..107055487d967329ca7340c1810577002078aca2 100644
--- a/tests/html/node_test.dart
+++ b/tests/html/node_test.dart
@@ -335,28 +335,90 @@ main() {
});
});
- group('_NodeList', () {
+ group('NodeList', () {
+ // Tests for methods on the DOM class 'NodeList'.
+ //
+ // There are two interesting things that are checked here from the viewpoint
+ // of the dart2js implementation of a 'native' class:
+ //
+ // 1. Some methods are implementated from by 'Object' or 'Interceptor';
+ // some of these tests simply check that a method can be called.
+ // 2. Some methods are implemented by mixins.
+
List<Node> makeNodeList() =>
- makeNodeWithChildren().nodes.where((_) => true).toList();
+ (new Element.html("<div>Foo<br/><!--baz--><br/><br/></div>"))
+ .$dom_getElementsByTagName('br');
+ // Our WebKit-derived bindings declare getElementsByTagName as returning
+ // NodeList.
+ //
+ // WebKit browsers returns NodeList.
+ // Firefox and IE return HtmlCollection.
+ // This is messed-up since the two types are disjoint. We could make
+ // HtmlCollection extend NodeList but we would require better optimizations
+ // to recognize when NodeList_methods can be used.
+
+ test('trueNodeList', () {
+ var nodes = makeNodeList();
+ expect(nodes is NodeList || nodes is HtmlCollection, true);
+ });
+
+ test('hashCode', () {
+ var nodes = makeNodeList();
+ var hash = nodes.hashCode;
+ final int N = 1000;
+ int matchCount = 0;
+ for (int i = 0; i < N; i++) {
+ if (makeNodeList().hashCode == hash) matchCount++;
+ }
+ expect(matchCount, lessThan(N));
+ });
+
+ test('operator==', () {
+ var a = [makeNodeList(), makeNodeList(), null];
+ for (int i = 0; i < a.length; i++) {
+ for (int j = 0; j < a.length; j++) {
+ expect(i == j, a[i] == a[j]);
+ }
+ }
+ });
+
+ test('runtimeType', () {
+ var nodes1 = makeNodeList();
+ var nodes2 = makeNodeList();
+ var type1 = nodes1.runtimeType;
+ var type2 = nodes2.runtimeType;
+ expect(type1 == type2, true);
+ String name = '$type1';
+ if (name.length > 3) {
+ expect(name.contains('NodeList') || name.contains('HtmlCollection'),
+ true);
+ }
+ });
test('first', () {
var nodes = makeNodeList();
- expect(nodes.first, isText);
+ expect(nodes.first, isBRElement);
+ });
+
+ test('last', () {
+ var nodes = makeNodeList();
+ expect(nodes.last, isBRElement);
});
test('where', () {
var filtered = makeNodeList().where((n) => n is BRElement).toList();
- expect(filtered.length, 1);
+ expect(filtered.length, 3);
expect(filtered[0], isBRElement);
expect(filtered, isNodeList);
});
test('sublist', () {
var range = makeNodeList().sublist(1, 3);
- expect(range, isNodeList);
+ expect(range.length, 2);
expect(range[0], isBRElement);
- expect(range[1], isComment);
+ expect(range[1], isBRElement);
});
+
});
group('iterating', () {
« no previous file with comments | « sdk/lib/web_sql/dart2js/web_sql_dart2js.dart ('k') | tools/dom/scripts/systemhtml.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698