Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / third_party / WebKit / LayoutTests / http / tests / xmlhttprequest / xmlhttprequest-responseXML-exception.html
blob6b9290fee1f0c24bea9d717ee8ce82ea548f0352
1 <html>
2 <head></head>
3 <body>
5 <p>Test bug 12914 : Trying to access XMLHttpRequest.responseText or responseXML when they are not available should raise an exception </p>
6 <p>Should see "PASS" four times:</p>
7 <div id="ans"></div>
9 <script type="text/javascript">
10 function log(message) {
11 document.getElementById("ans").appendChild(document.createTextNode(message));
12 document.getElementById("ans").appendChild(document.createElement("br"));
15 function test(num)
17 var xhr;
19 if (window.XMLHttpRequest) {
20 xhr = new XMLHttpRequest();
21 } else {
22 try {
23 xhr = new ActiveXObject("Msxml2.XMLHTTP");
24 } catch (ex) {
25 xhr = new ActiveXObject("Microsoft.XMLHTTP");
29 xhr.onreadystatechange = function () {
30 if (this.readyState == num) {
31 ++finishedTests;
32 try {
33 // Force evaluation for Opera
34 var response = this.responseXML;
35 log("PASS");
36 } catch (e) {
37 log("FAILED");
41 if (finishedTests == 4 && window.testRunner)
42 testRunner.notifyDone();
45 xhr.open("GET", "resources/1251.html", true);
46 if (num != 1)
47 xhr.send(null);
50 if (window.testRunner) {
51 testRunner.dumpAsText();
52 testRunner.waitUntilDone();
55 var finishedTests = 0;
57 for (i = 1; i < 5; i++) {
58 test(i);
61 </script>
62 </body>
63 </html>