responsexml-basic.htm (1762B)
1 <!doctype html> 2 <html> 3 <head> 4 <title>XMLHttpRequest: responseXML basic test</title> 5 <script src="/resources/testharness.js"></script> 6 <script src="/resources/testharnessreport.js"></script> 7 <link rel="help" href="https://xhr.spec.whatwg.org/#the-responsexml-attribute" data-tested-assertations="following::ol[1]/li[2] following::ol[1]/li[4]" /> 8 <link rel="help" href="https://xhr.spec.whatwg.org/#document-response-entity-body" data-tested-assertations="following::ol[1]/li[1] following::ol[1]/li[6] following::ol[1]/li[10]" /> 9 </head> 10 <body> 11 <div id="log"></div> 12 <script> 13 test(function() { 14 var client = new XMLHttpRequest() 15 assert_equals(client.responseXML, null) 16 client.open("GET", "resources/well-formed.xml", false) 17 assert_equals(client.responseXML, null) 18 client.send(null) 19 assert_equals(client.responseXML.documentElement.localName, "html", 'localName is html') 20 assert_equals(client.responseXML.documentElement.childNodes.length, 5, 'childNodes is 5') 21 assert_equals(client.responseXML.getElementById("n1").localName, client.responseXML.documentElement.childNodes[1].localName) 22 assert_equals(client.responseXML.getElementById("n2"), client.responseXML.documentElement.childNodes[3], 'getElementById("n2")') 23 assert_equals(client.responseXML.getElementsByTagName("p")[1].namespaceURI, "namespacesarejuststrings", 'namespaceURI') 24 }) 25 test(function() { 26 var client = new XMLHttpRequest() 27 client.open("GET", "resources/status.py?type=application/xml", false) 28 client.send(null) 29 assert_equals(client.responseXML, null) 30 }, 'responseXML on empty response documents') 31 </script> 32 </body> 33 </html>