3 <title>Test XMLHttpRequest exceptions
</title>
4 <meta http-equiv=
"content-type" content=
"text/html;charset=utf-8">
6 <p>Test that XMLHttpRequest raises exceptions when it should.
</p>
10 testRunner
.dumpAsText();
12 var console_messages
= document
.createElement("ul");
13 document
.body
.appendChild(console_messages
);
17 var item
= document
.createElement("li");
18 item
.appendChild(document
.createTextNode(message
));
19 console_messages
.appendChild(item
);
22 function shouldThrow(_a
, _e
) {
28 exception
= e
.description
? e
.description
: e
;
36 if (typeof _e
== "undefined" || exception
== _ev
)
37 log("PASS: " + _a
+ " threw exception " + exception
+ ".");
39 log("FAIL: " + _a
+ " should throw exception " + _ev
+ ". Threw exception " + exception
+ ".");
40 } else if (typeof _av
== "undefined")
41 log("FAIL: " + _a
+ " should throw exception " + _e
+ ". Was undefined.");
43 log("FAIL: " + _a
+ " should throw exception " + _e
+ ". Was " + _av
+ ".");
46 // -------------------------
48 if (window
.XMLHttpRequest
) {
49 req
= new XMLHttpRequest();
52 req
= new ActiveXObject("Msxml2.XMLHTTP");
54 req
= new ActiveXObject("Microsoft.XMLHTTP");
57 log("new XMLHttpRequest()");
59 shouldThrow('req.setRequestHeader("Foo", "bar")');
60 shouldThrow('req.send(null)');
62 req
.open('GET', 'resources/zero-length.txt', false);
65 shouldThrow('req.setRequestHeader()');
66 shouldThrow('req.setRequestHeader("Foo")');
71 shouldThrow('req.send(null)');
72 shouldThrow('req.setRequestHeader("Foo", "bar")');
73 shouldThrow('req.getResponseHeader()');
75 shouldThrow('req.open()');
76 shouldThrow('req.open(null)');