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

Side by Side Diff: tests/html/mutationobserver_test.dart

Issue 10696209: MutationObserver (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years, 5 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 | « tests/html/html.status ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file
vsm 2012/07/19 01:12:30 2012
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.
4
5 #library('mutationobserver_test');
6 #import('../../lib/unittest/unittest.dart');
7 #import('../../lib/unittest/html_config.dart');
8 #import('dart:html');
9
10 /**
11 * Test suite for Mutation Observers. This is just a small set of sanity
12 * checks, not a complete test suite.
13 */
14 main() {
15 useHtmlConfiguration();
16
17 group('childList', () {
18
19 mutationCallback(count, expectation) {
20 var done = false;
21 var nodes = [];
22
23 callback(mutations, observer) {
24 for (MutationRecord mutation in mutations) {
25 for (Node node in mutation.addedNodes) {
26 nodes.add(node);
27 }
28 }
29 if (nodes.length >= count) {
30 done = true;
31 expect(nodes.length, count);
32 expect(nodes, expectation);
33 }
34 }
35
36 return expectAsyncUntil2(callback, () => done);
37 }
38
39 test('empty options is syntax error', () {
40 var mutationObserver = new MutationObserver(
41 (mutations, observer) { expect(false, 'Should not be reached'); });
42 expect(() { mutationObserver.observe(document, {}); },
43 throws);
44 });
45
46 test('direct-parallel options-map', () {
47 var container = new DivElement();
48 var div1 = new DivElement();
49 var div2 = new DivElement();
50 var mutationObserver = new MutationObserver(
51 mutationCallback(2, orderedEquals([div1, div2])));
52 mutationObserver.observe(container, {'childList': true});
53
54 container.nodes.add(div1);
55 container.nodes.add(div2);
56 });
57
58 test('direct-parallel options-named', () {
59 var container = new DivElement();
60 var div1 = new DivElement();
61 var div2 = new DivElement();
62 var mutationObserver = new MutationObserver(
63 mutationCallback(2, orderedEquals([div1, div2])));
64 mutationObserver.observe(container, childList: true);
65
66 container.nodes.add(div1);
67 container.nodes.add(div2);
68 });
69
70 test('direct-nested options-named', () {
71 var container = new DivElement();
72 var div1 = new DivElement();
73 var div2 = new DivElement();
74 var mutationObserver =
75 new MutationObserver(mutationCallback(1, orderedEquals([div1])));
76 mutationObserver.observe(container, childList: true);
77
78 container.nodes.add(div1);
79 div1.nodes.add(div2);
80 });
81
82
83 test('subtree options-map', () {
84 var container = new DivElement();
85 var div1 = new DivElement();
86 var div2 = new DivElement();
87 var mutationObserver = new MutationObserver(
88 mutationCallback(2, orderedEquals([div1, div2])));
89 mutationObserver.observe(container,
90 {'childList': true, 'subtree': true});
91
92 container.nodes.add(div1);
93 div1.nodes.add(div2);
94 });
95
96 test('subtree options-named', () {
97 var container = new DivElement();
98 var div1 = new DivElement();
99 var div2 = new DivElement();
100 var mutationObserver = new MutationObserver(
101 mutationCallback(2, orderedEquals([div1, div2])));
102 mutationObserver.observe(container, childList: true, subtree: true);
103
104 container.nodes.add(div1);
105 div1.nodes.add(div2);
106 });
107 });
108 }
OLDNEW
« no previous file with comments | « tests/html/html.status ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698