blob: 9e7b0919bc422aa00896d6cf7f2276acdad32c02 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
|
<!doctype html>
<html>
<head>
<title>XMLHttpRequest: responseXML content-type test</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<link rel="help" href="https://xhr.spec.whatwg.org/#dom-xmlhttprequest-responsexml"/>
</head>
<body>
</body>
<script>
function parseBlob(blob) {
return new Promise(resolve => {
let xhr = new XMLHttpRequest();
xhr.open("GET", URL.createObjectURL(blob));
xhr.onload = () => {
resolve(xhr.responseXML);
}
xhr.send();
});
}
promise_test(async function() {
let blob = new Blob(["<x></x>"]);
let responseXML = await parseBlob(blob);
assert_not_equals(responseXML, null);
}, "Empty MIME type should be equivalent to text/xml")
promise_test(async function() {
let blob = new Blob(["<x></x>"], {type: "text/html"});
let responseXML = await parseBlob(blob);
assert_equals(responseXML, null);
}, "HTML content type should return null")
promise_test(async function() {
let blob = new Blob(["<x></x>"], {type: "text/plain"});
let responseXML = await parseBlob(blob);
assert_equals(responseXML, null);
}, "Non XML or HTML content type should return null")
promise_test(async function() {
let blob = new Blob(["<x></x>"], {type: "text/xml"});
let responseXML = await parseBlob(blob);
assert_not_equals(responseXML, null);
}, "XML content type should parse")
</script>
</html>
|