3 <script src="../js/resources/js-test-pre.js"></script>
4 <style type="text/css">
7 border: 1px solid black;
21 <div id="description"></div>
23 <div class="box"><span class="boxheader">responseText</span>
24 <pre id="id1">@@No result@@</pre>
28 <div id="console"></div>
31 description("Tests XMLHttpRequest 'text' loading with the .responseType and .response attributes.");
36 testPassed('DONE LOADING');
37 testPassed('received response object of type : ' + typeof xhr.response + ".");
39 // Make sure exception is thrown if responseType is set too late in the loading process.
40 // .responseType was previously set to "text". Let's try setting it to "arraybuffer".
42 xhr.responseType = "arraybuffer";
44 testPassed("exception correctly thrown when xhr.responseType is set to valid value too late in the loading process : " + e + ".");
48 document.getElementById("id1").firstChild.nodeValue = xhr.responseText;
50 // .response is really just an alias to .responseText when .responseType is set to "text".
51 // Make sure they're the same.
52 if (xhr.response == xhr.responseText)
53 testPassed("xhr.response == xhr.responseText.");
55 testFailed("xhr.response == xhr.responseText.");
62 if (window.layoutTestController) {
63 layoutTestController.dumpAsText();
64 layoutTestController.waitUntilDone();
67 xhr = new XMLHttpRequest();
69 xhr.open("GET", "resources/xmlhttprequest-get-data.xml", true);
72 if ("responseType" in xhr)
73 testPassed("responseType property exists.");
75 testFailed("responseType property does not exist.");
78 if ("response" in xhr)
79 testPassed("response property exists.");
81 testFailed("response property does not exist.");
83 // Make sure we can set responseType to "text" before send() is called.
85 xhr.responseType = "text";
86 if (xhr.responseType == "text")
87 testPassed("xhr.responseType has been correctly set to 'text'.");
89 testFailed("unable to set xhr.responseType to 'text' " + e + ".");
92 testFailed("Caught exception " + e + ".");
96 window.jsTestIsAsync = true;
103 <script src="../js/resources/js-test-post.js"></script>