https://github.com/web-platform-tests/wpt
Raw File
Tip revision: fcd7eab70b2fc21f6db9d436fcc75c4b148265aa authored by Anne van Kesteren on 24 August 2018, 13:30:16 UTC
XHR: responseURL with fragment
Tip revision: fcd7eab
responsexml-non-document-types.htm
<!doctype html>
<html>
  <head>
    <title>XMLHttpRequest: responseXML/responseText on other responseType</title>
    <script src="/resources/testharness.js"></script>
    <script src="/resources/testharnessreport.js"></script>
    <link rel="help" href="https://xhr.spec.whatwg.org/#the-responsexml-attribute" data-tested-assertations="following::ol[1]/li[1]" />
    <link rel="help" href="https://xhr.spec.whatwg.org/#the-responsetext-attribute" data-tested-assertations="following::ol[1]/li[1]" />
    <link rel="help" href="https://xhr.spec.whatwg.org/#the-responsetype-attribute" data-tested-assertations="following::ol[1]/li[4]" />
  </head>
  <body>
    <div id="log"></div>
    <script>
      function request(type) {
        var test = async_test(document.title+' ('+type+')')
        test.step(function() {
          var client = new XMLHttpRequest()
          client.responseType = type
          client.open("GET", "resources/well-formed.xml", true)
          client.onload = function(){
            test.step(function(){
                if(type !== 'document'){
                  assert_throws("InvalidStateError", function() {
                    var x = client.responseXML;
                  }, 'responseXML throw for '+type)
                }
                if(type !== 'text'){
                  assert_throws("InvalidStateError", function() {
                    var x = client.responseText;
                  }, 'responseText throws for '+type)
                }
                test.done()
            })
          }
          client.send(null)
        })
      }
      request("arraybuffer")
      request("blob")
      request("json")
      request("text")
      request("document")
    </script>
  </body>
</html>
back to top