OLD | NEW |
---|---|
1 function enableAllTextTracks(textTracks) { | 1 function enableAllTextTracks(textTracks) { |
2 for (var i = 0; i < textTracks.length; i++) { | 2 for (var i = 0; i < textTracks.length; i++) { |
3 var track = textTracks[i]; | 3 var track = textTracks[i]; |
4 if (track.mode == "disabled") | 4 if (track.mode == "disabled") |
5 track.mode = "hidden"; | 5 track.mode = "hidden"; |
6 } | 6 } |
7 } | 7 } |
8 | 8 |
9 function assert_cues_equal(cues, expected) { | 9 function assert_cues_equal(cues, expected) { |
10 assert_equals(cues.length, expected.length); | 10 assert_equals(cues.length, expected.length); |
(...skipping 27 matching lines...) Expand all Loading... | |
38 func(trackElement.track); | 38 func(trackElement.track); |
39 }); | 39 }); |
40 }, "Check cues from " + src); | 40 }, "Check cues from " + src); |
41 } | 41 } |
42 | 42 |
43 function assert_cue_fragment(cue, children) { | 43 function assert_cue_fragment(cue, children) { |
44 var fragment = createFragment(children); | 44 var fragment = createFragment(children); |
45 assert_true(fragment.isEqualNode(cue.getCueAsHTML())); | 45 assert_true(fragment.isEqualNode(cue.getCueAsHTML())); |
46 } | 46 } |
47 | 47 |
48 function assert_cue_fragment_text(cue, children) { | |
fs
2016/06/10 12:52:18
Maybe '...as_text' or '...as_textcontent'?
Srirama
2016/06/10 15:19:09
Done.
| |
49 var fragment = createFragment(children); | |
50 assert_equals(cue.getCueAsHTML().textContent, fragment.textContent); | |
51 } | |
52 | |
53 function assert_cue_fragment_with_style(cue, children, style) { | |
Srirama
2016/06/10 11:53:51
Should we merge this with "assert_cue_fragment" wi
fs
2016/06/10 12:52:18
Merging sounds like a good idea. Maybe even make i
Srirama
2016/06/10 13:57:04
"Maybe even make it so that style can more" is som
fs
2016/06/10 14:04:38
No =). 'it' refers to the (helper) function. Does
Srirama
2016/06/10 15:19:09
Understood :)
| |
54 var fragment = createFragment(children); | |
55 for (var attr of Object.getOwnPropertyNames(style)) | |
56 fragment.querySelector("span")[attr] = style[attr]; | |
57 assert_true(fragment.isEqualNode(cue.getCueAsHTML())); | |
58 } | |
59 | |
48 function createFragment(children) { | 60 function createFragment(children) { |
49 var fragment = document.createDocumentFragment(); | 61 var fragment = document.createDocumentFragment(); |
50 cloneChildrenToFragment(fragment, children); | 62 cloneChildrenToFragment(fragment, children); |
51 return fragment; | 63 return fragment; |
52 } | 64 } |
53 | 65 |
54 function cloneChildrenToFragment(root, children) { | 66 function cloneChildrenToFragment(root, children) { |
55 for (var child of children) { | 67 for (var child of children) { |
56 var childElement; | 68 var childElement; |
57 if (child.type == "text") { | 69 if (child.type == "text") { |
58 childElement = document.createTextNode(child.value); | 70 childElement = document.createTextNode(child.value); |
59 } else { | 71 } else { |
60 childElement = document.createElement(child.type); | 72 childElement = document.createElement(child.type); |
61 cloneChildrenToFragment(childElement, child.value); | 73 cloneChildrenToFragment(childElement, child.value); |
62 } | 74 } |
63 root.appendChild(childElement); | 75 root.appendChild(childElement); |
64 } | 76 } |
65 } | 77 } |
OLD | NEW |