Index: third_party/WebKit/LayoutTests/media/track/track-helpers.js |
diff --git a/third_party/WebKit/LayoutTests/media/track/track-helpers.js b/third_party/WebKit/LayoutTests/media/track/track-helpers.js |
index c8ee628dedb02ab781a0773ca65aaba140a590a1..a377ae0628c054457dfd5bb0b4ea884d6ced089a 100644 |
--- a/third_party/WebKit/LayoutTests/media/track/track-helpers.js |
+++ b/third_party/WebKit/LayoutTests/media/track/track-helpers.js |
@@ -38,4 +38,28 @@ function check_cues_from_track(src, func) { |
func(trackElement.track); |
}); |
}, "Check cues from " + src); |
+} |
+ |
+function assert_cue_fragment(cue, children) { |
+ var fragment = createFragment(children); |
+ assert_true(fragment.isEqualNode(cue.getCueAsHTML())); |
+} |
+ |
+function createFragment(children) { |
+ var fragment = document.createDocumentFragment(); |
+ cloneChildrenToFragment(fragment, children); |
+ return fragment; |
+} |
+ |
+function cloneChildrenToFragment(root, children) { |
+ for (var child of children) { |
+ var childElement; |
+ if (child.type == "text") { |
+ childElement = document.createTextNode(child.value); |
+ } else { |
+ childElement = document.createElement(child.type); |
+ cloneChildrenToFragment(childElement, child.value); |
+ } |
+ root.appendChild(childElement); |
+ } |
} |