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

Unified 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: Fixing up recent test additions. Created 7 years, 4 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
Index: tests/html/utils.dart
diff --git a/tests/html/utils.dart b/tests/html/utils.dart
index 38ed07337551b56388a02579581ede014c9080c3..12e3c2d39297d14ba0fe94536f9d77bb0d266a5e 100644
--- a/tests/html/utils.dart
+++ b/tests/html/utils.dart
@@ -123,3 +123,39 @@ verifyGraph(expected, actual) {
walk('', expected, actual);
}
+
+
+/**
+ * Sanitizer which does nothing.
+ */
+class NullTreeSanitizer implements NodeTreeSanitizer {
+ void sanitizeTree(Node node) {}
+}
+
+
+/**
+ * Validate that two DOM trees are equivalent.
+ */
+void validateNodeTree(Node a, Node b, [String path = '']) {
+ path = '${path}${a.runtimeType}';
+ expect(a.nodeType, b.nodeType, reason: '$path nodeTypes differ');
+ expect(a.nodeValue, b.nodeValue, reason: '$path nodeValues differ');
+ expect(a.text, b.text, reason: '$path texts differ');
+ expect(a.nodes.length, b.nodes.length, reason: '$path nodes.lengths differ');
+
+ if (a is Element) {
+ Element bE = b;
+ Element aE = a;
+
+ expect(aE.tagName, bE.tagName, reason: '$path tagNames differ');
+ expect(aE.attributes.length, bE.attributes.length,
+ reason: '$path attributes.lengths differ');
+ for (var key in aE.attributes.keys) {
+ expect(aE.attributes[key], bE.attributes[key],
+ reason: '$path attribute [$key] values differ');
+ }
+ }
+ for (var i = 0; i < a.nodes.length; ++i) {
+ validateNodeTree(a.nodes[i], b.nodes[i], '$path[$i].');
+ }
+}

Powered by Google App Engine
This is Rietveld 408576698