| OLD | NEW |
| 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 ElementTest; | 5 library ElementTest; |
| 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:async'; | 8 import 'dart:async'; |
| 9 import 'dart:html'; | 9 import 'dart:html'; |
| 10 import 'dart:svg' as svg; | 10 import 'dart:svg' as svg; |
| (...skipping 831 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 842 expect(firedEvent3, true); | 842 expect(firedEvent3, true); |
| 843 | 843 |
| 844 var firedEvent5 = false; | 844 var firedEvent5 = false; |
| 845 queryAll(':root').onClick.matches('.e').listen((event) { | 845 queryAll(':root').onClick.matches('.e').listen((event) { |
| 846 firedEvent5 = true; | 846 firedEvent5 = true; |
| 847 }); | 847 }); |
| 848 expect(firedEvent5, false); | 848 expect(firedEvent5, false); |
| 849 query('.i').click(); | 849 query('.i').click(); |
| 850 expect(firedEvent5, true); | 850 expect(firedEvent5, true); |
| 851 }); | 851 }); |
| 852 |
| 853 test('event ordering', () { |
| 854 var a = new DivElement(); |
| 855 var b = new DivElement(); |
| 856 a.append(b); |
| 857 var c = new DivElement(); |
| 858 b.append(c); |
| 859 |
| 860 var eventOrder = []; |
| 861 |
| 862 a.on['custom_event'].listen((_) { |
| 863 eventOrder.add('a no-capture'); |
| 864 }); |
| 865 |
| 866 a.on['custom_event'].capture((_) { |
| 867 eventOrder.add('a capture'); |
| 868 }); |
| 869 |
| 870 b.on['custom_event'].listen((_) { |
| 871 eventOrder.add('b no-capture'); |
| 872 }); |
| 873 |
| 874 b.on['custom_event'].capture((_) { |
| 875 eventOrder.add('b capture'); |
| 876 }); |
| 877 |
| 878 document.body.append(a); |
| 879 |
| 880 var event = new Event('custom_event', canBubble: true); |
| 881 c.dispatchEvent(event); |
| 882 expect(eventOrder, [ |
| 883 'a capture', |
| 884 'b capture', |
| 885 'b no-capture', |
| 886 'a no-capture' |
| 887 ]); |
| 888 }); |
| 852 }); | 889 }); |
| 853 | 890 |
| 854 group('ElementList', () { | 891 group('ElementList', () { |
| 855 // Tests for methods on the DOM class 'NodeList'. | 892 // Tests for methods on the DOM class 'NodeList'. |
| 856 // | 893 // |
| 857 // There are two interesting things that are checked here from the viewpoint | 894 // There are two interesting things that are checked here from the viewpoint |
| 858 // of the dart2js implementation of a 'native' class: | 895 // of the dart2js implementation of a 'native' class: |
| 859 // | 896 // |
| 860 // 1. Some methods are implementated from by 'Object' or 'Interceptor'; | 897 // 1. Some methods are implementated from by 'Object' or 'Interceptor'; |
| 861 // some of these tests simply check that a method can be called. | 898 // some of these tests simply check that a method can be called. |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 915 | 952 |
| 916 test('sublist', () { | 953 test('sublist', () { |
| 917 var range = makeElementList().sublist(1, 3); | 954 var range = makeElementList().sublist(1, 3); |
| 918 expect(range.length, 2); | 955 expect(range.length, 2); |
| 919 expect(range[0], isBRElement); | 956 expect(range[0], isBRElement); |
| 920 expect(range[1], isBRElement); | 957 expect(range[1], isBRElement); |
| 921 }); | 958 }); |
| 922 | 959 |
| 923 }); | 960 }); |
| 924 } | 961 } |
| OLD | NEW |