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

Unified 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « tests/html/html.status ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tests/html/mutationobserver_test.dart
diff --git a/tests/html/mutationobserver_test.dart b/tests/html/mutationobserver_test.dart
new file mode 100644
index 0000000000000000000000000000000000000000..87a46eeeb3011c115649e5944a42c961e19f206d
--- /dev/null
+++ b/tests/html/mutationobserver_test.dart
@@ -0,0 +1,108 @@
+// Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file
vsm 2012/07/19 01:12:30 2012
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+
+#library('mutationobserver_test');
+#import('../../lib/unittest/unittest.dart');
+#import('../../lib/unittest/html_config.dart');
+#import('dart:html');
+
+/**
+ * Test suite for Mutation Observers. This is just a small set of sanity
+ * checks, not a complete test suite.
+ */
+main() {
+ useHtmlConfiguration();
+
+ group('childList', () {
+
+ mutationCallback(count, expectation) {
+ var done = false;
+ var nodes = [];
+
+ callback(mutations, observer) {
+ for (MutationRecord mutation in mutations) {
+ for (Node node in mutation.addedNodes) {
+ nodes.add(node);
+ }
+ }
+ if (nodes.length >= count) {
+ done = true;
+ expect(nodes.length, count);
+ expect(nodes, expectation);
+ }
+ }
+
+ return expectAsyncUntil2(callback, () => done);
+ }
+
+ test('empty options is syntax error', () {
+ var mutationObserver = new MutationObserver(
+ (mutations, observer) { expect(false, 'Should not be reached'); });
+ expect(() { mutationObserver.observe(document, {}); },
+ throws);
+ });
+
+ test('direct-parallel options-map', () {
+ var container = new DivElement();
+ var div1 = new DivElement();
+ var div2 = new DivElement();
+ var mutationObserver = new MutationObserver(
+ mutationCallback(2, orderedEquals([div1, div2])));
+ mutationObserver.observe(container, {'childList': true});
+
+ container.nodes.add(div1);
+ container.nodes.add(div2);
+ });
+
+ test('direct-parallel options-named', () {
+ var container = new DivElement();
+ var div1 = new DivElement();
+ var div2 = new DivElement();
+ var mutationObserver = new MutationObserver(
+ mutationCallback(2, orderedEquals([div1, div2])));
+ mutationObserver.observe(container, childList: true);
+
+ container.nodes.add(div1);
+ container.nodes.add(div2);
+ });
+
+ test('direct-nested options-named', () {
+ var container = new DivElement();
+ var div1 = new DivElement();
+ var div2 = new DivElement();
+ var mutationObserver =
+ new MutationObserver(mutationCallback(1, orderedEquals([div1])));
+ mutationObserver.observe(container, childList: true);
+
+ container.nodes.add(div1);
+ div1.nodes.add(div2);
+ });
+
+
+ test('subtree options-map', () {
+ var container = new DivElement();
+ var div1 = new DivElement();
+ var div2 = new DivElement();
+ var mutationObserver = new MutationObserver(
+ mutationCallback(2, orderedEquals([div1, div2])));
+ mutationObserver.observe(container,
+ {'childList': true, 'subtree': true});
+
+ container.nodes.add(div1);
+ div1.nodes.add(div2);
+ });
+
+ test('subtree options-named', () {
+ var container = new DivElement();
+ var div1 = new DivElement();
+ var div2 = new DivElement();
+ var mutationObserver = new MutationObserver(
+ mutationCallback(2, orderedEquals([div1, div2])));
+ mutationObserver.observe(container, childList: true, subtree: true);
+
+ container.nodes.add(div1);
+ div1.nodes.add(div2);
+ });
+ });
+}
« 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