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

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, 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
« no previous file with comments | « tests/html/svgelement_test.dart ('k') | tools/dom/scripts/htmlrenamer.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tests/html/utils.dart
diff --git a/tests/html/utils.dart b/tests/html/utils.dart
index 38ed07337551b56388a02579581ede014c9080c3..2533f24997b2a34e3694967f82611187efaafa29 100644
--- a/tests/html/utils.dart
+++ b/tests/html/utils.dart
@@ -3,7 +3,7 @@ library TestUtils;
import 'dart:async';
import 'dart:html';
import 'dart:typed_data';
-import '../../pkg/unittest/lib/unittest.dart';
+import 'package:unittest/unittest.dart';
/**
* Verifies that [actual] has the same graph structure as [expected].
@@ -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].');
+ }
+}
« no previous file with comments | « tests/html/svgelement_test.dart ('k') | tools/dom/scripts/htmlrenamer.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698