forked from mozilla/gecko-dev
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Bug 1846780: responseXML is populated for a blob with an empty type. …
…r=twisniewski A blob with an empty content type or any other invalid content type should return a value for responseXML. Differential Revision: https://phabricator.services.mozilla.com/D185185
- Loading branch information
1 parent
a117230
commit 2e71051
Showing
2 changed files
with
52 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
49 changes: 49 additions & 0 deletions
49
testing/web-platform/mozilla/tests/xml/responsexml-content-type.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,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> |