Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
branch: master
Fetching contributors…

Cannot retrieve contributors at this time

40 lines (36 sloc) 1.419 kb
<!DOCTYPE html>
<title>DOMParser</title>
<link rel="author" title="Ms2ger" href="mailto:ms2ger@gmail.com">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<div id="log"></div>
<script>
function isErrorDocument(doc, contentType) {
assert_true(doc instanceof Document)
assert_true(doc instanceof XMLDocument)
assert_equals(doc.documentElement.namespaceURI, "http://www.mozilla.org/newlayout/xml/parsererror.xml");
assert_equals(doc.documentElement.localName, "parsererror");
assert_equals(doc.documentElement.tagName, "parsererror");
assert_equals(doc.URL, null)
assert_equals(doc.documentURI, null)
assert_equals(doc.characterSet, "UTF-8")
assert_equals(doc.contentType, contentType)
}
var allowedTypes = ["text/xml", "application/xml", "application/xhtml+xml", "image/svg+xml"]
test(function() {
var p = new DOMParser();
var doc = p.parseFromString("<foo/>", "text/xml")
assert_true(doc instanceof Document)
assert_equals(doc.URL, null)
assert_equals(doc.documentURI, null)
assert_equals(doc.characterSet, "UTF-8")
assert_equals(doc.contentType, "text/xml")
})
allowedTypes.forEach(function(type) {
test(function() {
var p = new DOMParser();
var doc = p.parseFromString("<foo>", type)
isErrorDocument(doc, type);
}, "Should return an error document for XML wellformedness errors in type " + type)
})
</script>
Jump to Line
Something went wrong with that request. Please try again.