blob: a3ce7b5b544296944d8721e80fd17139bb7bbc40 [file] [log] [blame]
Anne van Kesteren66b54172010-08-11 18:02:171<!doctype html>
2<html>
3 <head>
4 <title>XMLHttpRequest: responseXML basic test</title>
5 <script src="/resources/testharness.js"></script>
Ms2ger6f083e72012-08-05 08:38:146 <script src="/resources/testharnessreport.js"></script>
Ms2ger91fef142014-11-01 09:24:377 <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]" />
Anne van Kesteren66b54172010-08-11 18:02:179 </head>
10 <body>
11 <div id="log"></div>
12 <script>
13 test(function() {
14 var client = new XMLHttpRequest()
Hallvord R. M. Steen9ac6d662013-05-14 15:33:0015 assert_equals(client.responseXML, null)
Anne van Kesteren66b54172010-08-11 18:02:1716 client.open("GET", "resources/well-formed.xml", false)
Hallvord R. M. Steen9ac6d662013-05-14 15:33:0017 assert_equals(client.responseXML, null)
Anne van Kesteren66b54172010-08-11 18:02:1718 client.send(null)
Hallvord Reiar M. Steene3ce86d2013-04-30 10:15:4019 assert_equals(client.responseXML.documentElement.localName, "html", 'localName is html')
20 assert_equals(client.responseXML.documentElement.childNodes.length, 5, 'childNodes is 5')
Anne van Kesteren66b54172010-08-11 18:02:1721 assert_equals(client.responseXML.getElementById("n1").localName, client.responseXML.documentElement.childNodes[1].localName)
jgrahamcb0c8ce2016-10-06 18:31:2022 assert_equals(client.responseXML.getElementById("n2"), client.responseXML.documentElement.childNodes[3], 'getElementById("n2")')
Hallvord Reiar M. Steene3ce86d2013-04-30 10:15:4023 assert_equals(client.responseXML.getElementsByTagName("p")[1].namespaceURI, "namespacesarejuststrings", 'namespaceURI')
Anne van Kesteren66b54172010-08-11 18:02:1724 })
Hallvord R. M. Steen9ac6d662013-05-14 15:33:0025 test(function() {
26 var client = new XMLHttpRequest()
James Graham234a6722013-09-17 17:54:3827 client.open("GET", "resources/status.py?type=application/xml", false)
Hallvord R. M. Steen9ac6d662013-05-14 15:33:0028 client.send(null)
29 assert_equals(client.responseXML, null)
30 }, 'responseXML on empty response documents')
Anne van Kesteren66b54172010-08-11 18:02:1731 </script>
32 </body>
33</html>