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

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

Issue 16374007: First rev of Safe DOM (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 6 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
OLDNEW
1 library TestUtils; 1 library TestUtils;
2 2
3 import 'dart:async'; 3 import 'dart:async';
4 import 'dart:html'; 4 import 'dart:html';
5 import 'dart:typed_data'; 5 import 'dart:typed_data';
6 import '../../pkg/unittest/lib/unittest.dart'; 6 import '../../pkg/unittest/lib/unittest.dart';
7 7
8 /** 8 /**
9 * Verifies that [actual] has the same graph structure as [expected]. 9 * Verifies that [actual] has the same graph structure as [expected].
10 * Detects cycles and DAG structure in Maps and Lists. 10 * Detects cycles and DAG structure in Maps and Lists.
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
86 } 86 }
87 } 87 }
88 return; 88 return;
89 } 89 }
90 90
91 expect(false, isTrue, reason: 'Unhandled type: $expected'); 91 expect(false, isTrue, reason: 'Unhandled type: $expected');
92 } 92 }
93 93
94 walk('', expected, actual); 94 walk('', expected, actual);
95 } 95 }
96
97
98 /**
99 * Sanitizer which does nothing.
100 */
101 class NullTreeSanitizer implements NodeTreeSanitizer {
102 void sanitizeTree(Node node) {}
103 }
104
105
106 /**
107 * Validate that two DOM trees are equivalent.
108 */
109 void validateNodeTree(Node a, Node b, [String path = '']) {
110 path = '${path}${a.runtimeType}';
111 expect(a.nodeType, b.nodeType, reason: '$path nodeTypes differ');
112 expect(a.nodeValue, b.nodeValue, reason: '$path nodeValues differ');
113 expect(a.text, b.text, reason: '$path texts differ');
114 expect(a.nodes.length, b.nodes.length, reason: '$path nodes.lengths differ');
115
116 if (a is Element) {
117 Element bE = b;
118 Element aE = a;
119
120 expect(aE.tagName, bE.tagName, reason: '$path tagNames differ');
121 expect(aE.attributes.length, bE.attributes.length,
122 reason: '$path attributes.lengths differ');
123 for (var key in aE.attributes.keys) {
124 expect(aE.attributes[key], bE.attributes[key],
125 reason: '$path attribute [$key] values differ');
126 }
127 }
128 for (var i = 0; i < a.nodes.length; ++i) {
129 validateNodeTree(a.nodes[i], b.nodes[i], '$path[$i].');
130 }
131 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698