OLD | NEW |
---|---|
1 var namespaces = { | 1 var namespaces = { |
2 "html":"http://www.w3.org/1999/xhtml", | 2 "html":"http://www.w3.org/1999/xhtml", |
3 "mathml":"http://www.w3.org/1998/Math/MathML", | 3 "mathml":"http://www.w3.org/1998/Math/MathML", |
4 "svg":"http://www.w3.org/2000/svg", | 4 "svg":"http://www.w3.org/2000/svg", |
5 "xlink":"http://www.w3.org/1999/xlink", | 5 "xlink":"http://www.w3.org/1999/xlink", |
6 "xml":"http://www.w3.org/XML/1998/namespace", | 6 "xml":"http://www.w3.org/XML/1998/namespace", |
7 "xmlns":"http://www.w3.org/2000/xmlns/" | 7 "xmlns":"http://www.w3.org/2000/xmlns/" |
8 }; | 8 }; |
9 | 9 |
10 var prefixes = {}; | 10 var prefixes = {}; |
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
102 indent += 2; | 102 indent += 2; |
103 Array.prototype.forEach.call(element.childNodes, | 103 Array.prototype.forEach.call(element.childNodes, |
104 function(node) { | 104 function(node) { |
105 serialize_element(node, indent); | 105 serialize_element(node, indent); |
106 }); | 106 }); |
107 } | 107 } |
108 serialize_element(element, 0); | 108 serialize_element(element, 0); |
109 return lines.join("\n"); | 109 return lines.join("\n"); |
110 } | 110 } |
111 | 111 |
112 function mark_diffs(expected, actual) { | |
113 var expected_lines = expected.split("\n"); | |
114 var actual_lines = actual.split("\n"); | |
115 | |
116 var max_length = Math.max(expected_lines.length, actual_lines.length); | |
117 | |
118 var expected_diff = ["code", {}]; | |
119 var actual_diff = ["code", {}]; | |
120 | |
121 for (var i=0; i<max_length; i++) { | |
122 if (expected_lines[i] === actual_lines[i]) { | |
123 expected_diff.push(expected_lines[i] + "\n"); | |
124 actual_diff.push(actual_lines[i] + "\n"); | |
125 } else { | |
126 if (expected_lines[i]) { | |
127 expected_diff.push(["span", {style:"color:red"}, expected_lines[i] + "\n "]); | |
128 } | |
129 if (actual_lines[i]) { | |
130 actual_diff.push(["span", {style:"color:red"}, actual_lines[i] + "\n"]); | |
131 } | |
132 } | |
133 } | |
134 return [expected_diff, actual_diff]; | |
135 } | |
136 | |
112 function print_diffs(test_id, uri_encoded_input, expected, actual, container) { | 137 function print_diffs(test_id, uri_encoded_input, expected, actual, container) { |
113 container = container ? container : null; | 138 container = container ? container : null; |
114 if (actual) { | 139 if (actual) { |
115 var diffs = mark_diffs(expected, actual); | 140 var diffs = mark_diffs(expected, actual); |
116 var expected_text = diffs[0]; | 141 var expected_text = diffs[0]; |
117 var actual_text = diffs[1]; | 142 var actual_text = diffs[1]; |
118 } else { | 143 } else { |
119 var expected_text = expected; | 144 var expected_text = expected; |
120 var actual_text = ""; | 145 var actual_text = ""; |
121 } | 146 } |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
164 }); | 189 }); |
165 }); | 190 }); |
166 } | 191 } |
167 | 192 |
168 function trackLoaded(e) { | 193 function trackLoaded(e) { |
169 var track = e.target; | 194 var track = e.target; |
170 setTimeout(removeElm, 0, track.parentNode); | 195 setTimeout(removeElm, 0, track.parentNode); |
171 var cue = track.track.cues[0]; | 196 var cue = track.track.cues[0]; |
172 var frag = cue.getCueAsHTML(); | 197 var frag = cue.getCueAsHTML(); |
173 var got = test_serializer(frag); | 198 var got = test_serializer(frag); |
174 if (got !== this.expected) { | 199 // For friendlier output on failures, expose the template.render() function from |
175 print_diffs(this.test_id, this.url_encoded_input, this.expected, got); | 200 // testharness.js, and enable this block. |
176 } | 201 // if (got !== this.expected) { |
jochen (gone - plz use gerrit)
2013/11/19 16:06:46
what about making this configurable by defining a
| |
202 // print_diffs(this.test_id, this.url_encoded_input, this.expected, got) ; | |
203 // } | |
177 assert_equals(got, this.expected); | 204 assert_equals(got, this.expected); |
178 this.done(); | 205 this.done(); |
179 } | 206 } |
180 | 207 |
181 function trackError(e) { | 208 function trackError(e) { |
182 setTimeout(removeElm, 0, e.target.parentNode); | 209 setTimeout(removeElm, 0, e.target.parentNode); |
183 assert_unreached('got error event'); | 210 assert_unreached('got error event'); |
184 this.done(); | 211 this.done(); |
185 } | 212 } |
186 | 213 |
187 function removeElm(elm) { | 214 function removeElm(elm) { |
188 document.body.removeChild(elm); | 215 document.body.removeChild(elm); |
189 } | 216 } |
OLD | NEW |