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

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: 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 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 24e77117db277415330e0f9fe225c6f664d4c552..db2a8b2853d3a7683ad87e6156d0174f96a1725d 100644
--- a/tests/html/utils.dart
+++ b/tests/html/utils.dart
@@ -93,3 +93,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