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

Side by Side 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 unified diff | Download patch | Annotate | Revision Log
« 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 »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 library NodeTest; 5 library NodeTest;
6 import '../../pkg/unittest/lib/unittest.dart'; 6 import '../../pkg/unittest/lib/unittest.dart';
7 import '../../pkg/unittest/lib/html_individual_config.dart'; 7 import '../../pkg/unittest/lib/html_individual_config.dart';
8 import 'dart:html'; 8 import 'dart:html';
9 import 'dart:svg' as svg; 9 import 'dart:svg' as svg;
10 10
(...skipping 317 matching lines...) Expand 10 before | Expand all | Expand 10 after
328 328
329 testUnsupported('fillRange', () { 329 testUnsupported('fillRange', () {
330 makeNodeWithChildren().nodes.fillRange(0, 1, null); 330 makeNodeWithChildren().nodes.fillRange(0, 1, null);
331 }); 331 });
332 332
333 testUnsupported('setAll', () { 333 testUnsupported('setAll', () {
334 makeNodeWithChildren().nodes.setAll(0, [new InputElement()]); 334 makeNodeWithChildren().nodes.setAll(0, [new InputElement()]);
335 }); 335 });
336 }); 336 });
337 337
338 group('_NodeList', () { 338 group('NodeList', () {
339 // Tests for methods on the DOM class 'NodeList'.
340 //
341 // There are two interesting things that are checked here from the viewpoint
342 // of the dart2js implementation of a 'native' class:
343 //
344 // 1. Some methods are implementated from by 'Object' or 'Interceptor';
345 // some of these tests simply check that a method can be called.
346 // 2. Some methods are implemented by mixins.
347
339 List<Node> makeNodeList() => 348 List<Node> makeNodeList() =>
340 makeNodeWithChildren().nodes.where((_) => true).toList(); 349 (new Element.html("<div>Foo<br/><!--baz--><br/><br/></div>"))
350 .$dom_getElementsByTagName('br');
351 // Our WebKit-derived bindings declare getElementsByTagName as returning
352 // NodeList.
353 //
354 // WebKit browsers returns NodeList.
355 // Firefox and IE return HtmlCollection.
356 // This is messed-up since the two types are disjoint. We could make
357 // HtmlCollection extend NodeList but we would require better optimizations
358 // to recognize when NodeList_methods can be used.
359
360 test('trueNodeList', () {
361 var nodes = makeNodeList();
362 expect(nodes is NodeList || nodes is HtmlCollection, true);
363 });
364
365 test('hashCode', () {
366 var nodes = makeNodeList();
367 var hash = nodes.hashCode;
368 final int N = 1000;
369 int matchCount = 0;
370 for (int i = 0; i < N; i++) {
371 if (makeNodeList().hashCode == hash) matchCount++;
372 }
373 expect(matchCount, lessThan(N));
374 });
375
376 test('operator==', () {
377 var a = [makeNodeList(), makeNodeList(), null];
378 for (int i = 0; i < a.length; i++) {
379 for (int j = 0; j < a.length; j++) {
380 expect(i == j, a[i] == a[j]);
381 }
382 }
383 });
384
385 test('runtimeType', () {
386 var nodes1 = makeNodeList();
387 var nodes2 = makeNodeList();
388 var type1 = nodes1.runtimeType;
389 var type2 = nodes2.runtimeType;
390 expect(type1 == type2, true);
391 String name = '$type1';
392 if (name.length > 3) {
393 expect(name.contains('NodeList') || name.contains('HtmlCollection'),
394 true);
395 }
396 });
341 397
342 test('first', () { 398 test('first', () {
343 var nodes = makeNodeList(); 399 var nodes = makeNodeList();
344 expect(nodes.first, isText); 400 expect(nodes.first, isBRElement);
401 });
402
403 test('last', () {
404 var nodes = makeNodeList();
405 expect(nodes.last, isBRElement);
345 }); 406 });
346 407
347 test('where', () { 408 test('where', () {
348 var filtered = makeNodeList().where((n) => n is BRElement).toList(); 409 var filtered = makeNodeList().where((n) => n is BRElement).toList();
349 expect(filtered.length, 1); 410 expect(filtered.length, 3);
350 expect(filtered[0], isBRElement); 411 expect(filtered[0], isBRElement);
351 expect(filtered, isNodeList); 412 expect(filtered, isNodeList);
352 }); 413 });
353 414
354 test('sublist', () { 415 test('sublist', () {
355 var range = makeNodeList().sublist(1, 3); 416 var range = makeNodeList().sublist(1, 3);
356 expect(range, isNodeList); 417 expect(range.length, 2);
357 expect(range[0], isBRElement); 418 expect(range[0], isBRElement);
358 expect(range[1], isComment); 419 expect(range[1], isBRElement);
359 }); 420 });
421
360 }); 422 });
361 423
362 group('iterating', () { 424 group('iterating', () {
363 test('NodeIterator', () { 425 test('NodeIterator', () {
364 var root = makeNodeWithChildren(); 426 var root = makeNodeWithChildren();
365 var nodeIterator = new NodeIterator(root, NodeFilter.SHOW_COMMENT); 427 var nodeIterator = new NodeIterator(root, NodeFilter.SHOW_COMMENT);
366 expect(nodeIterator.nextNode(), isComment); 428 expect(nodeIterator.nextNode(), isComment);
367 expect(nodeIterator.nextNode(), isNull); 429 expect(nodeIterator.nextNode(), isNull);
368 }); 430 });
369 431
370 test('TreeWalker', () { 432 test('TreeWalker', () {
371 var root = makeNodeWithChildren(); 433 var root = makeNodeWithChildren();
372 var treeWalker = new TreeWalker(root, NodeFilter.SHOW_COMMENT); 434 var treeWalker = new TreeWalker(root, NodeFilter.SHOW_COMMENT);
373 expect(treeWalker.nextNode(), isComment); 435 expect(treeWalker.nextNode(), isComment);
374 expect(treeWalker.nextNode(), isNull); 436 expect(treeWalker.nextNode(), isNull);
375 }); 437 });
376 }); 438 });
377 } 439 }
OLDNEW
« 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