OLD | NEW |
---|---|
(Empty) | |
1 <!DOCTYPE html> | |
2 <title>document.contentType</title> | |
3 <link rel="help" href="http://dom.spec.whatwg.org/#dom-document-contenttype"> | |
4 <script src="/js-test-resources/js-test.js"></script> | |
5 <body> | |
6 | |
7 <script> | |
8 window.jsTestIsAsync = true; | |
9 | |
10 var to_test = [ | |
11 { mt: "text/html", uri: "resources/send-mime-type.php?m=text/html" }, | |
12 { mt: "text/xml", uri: "resources/send-mime-type.php?m=text/xml" }, | |
13 { mt: "application/xml", uri: "resources/send-mime-type.php?m=applicatio n/xml" }, | |
14 { mt: "text/html", uri: "resources/send-mime-type.php?m=text/html;charse t=utf-8" }, | |
15 { mt: "text/xml", uri: "resources/send-mime-type.php?m=text/xml;charset= utf-8" }, | |
16 { mt: "application/xml", uri: "resources/send-mime-type.php?m=applicatio n/xml;charset=utf-8" } | |
17 ]; | |
18 | |
19 function _(s) { return '"' + s + '"'; }; | |
arv (Not doing code reviews)
2014/02/11 16:36:10
Use descriptive names
| |
20 | |
21 function onrequestload(expected_mt) { | |
22 shouldBe(_(this.status), _(200)); | |
23 | |
24 if (this.responseXML) | |
25 shouldBe(_(this.responseXML.contentType), _(expected_mt)); | |
26 else | |
27 testFailed("Null document for mime-type " + expected_mt); | |
28 | |
29 step_test(); | |
30 } | |
31 | |
32 function step_test() { | |
33 var this_test = to_test.shift(); | |
34 if (this_test) { | |
35 var x = new XMLHttpRequest(); | |
36 x.open('GET', this_test.uri, true); | |
37 x.responseType = 'document'; | |
38 x.onload = onrequestload.bind(x, this_test.mt); | |
39 x.send(''); | |
40 } | |
41 else | |
42 finishJSTest(); | |
43 } | |
44 | |
45 step_test(); | |
46 | |
47 </script> | |
OLD | NEW |