Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / third_party / WebKit / LayoutTests / http / tests / xmlhttprequest / readystatechange.html
blob09b4afcf399aefbacbcdbdbd9da8fa7b0e318185
1 <html>
2 <body>
3 <p>Tests for <a href="https://bugs.webkit.org/show_bug.cgi?id=15102">bug 15102</a> -
4 XMLHttpRequest should dispatch readystatechange event.</p>
5 <p>If this passes you should see alerts for onreadystatechange and for a readystatechange listener.</p>
6 <script>
7 if (window.testRunner)
8 testRunner.dumpAsText();
10 function called1(evt) {
11 alert("onreadystatechange called");
12 alert("evt.constructor = " + evt.constructor);
13 if (evt instanceof XMLHttpRequestProgressEvent) {
14 alert("FAIL: evt must not be an instance of XMLHttpRequestProgressEvent");
16 evt.foo = "bar";
19 function called2(evt) {
20 evt.stopPropagation(); // stopPropagation shouldn't have any effect, as we don't have an hierarchy to traverse
23 function called3(evt) {
24 if (evt.foo == "bar")
25 alert("readystatechange listener called");
26 else
27 alert("ERROR: readystatechange listener called, but the event object is not the same as in onreadystatechange!");
30 try {
31 var XHR = new XMLHttpRequest();
32 XHR.onreadystatechange = called1;
33 XHR.addEventListener("readystatechange", called2, false);
34 XHR.addEventListener("readystatechange", called3, false);
36 XHR.open("GET", "readystatechange.html", true);
37 } catch (ex) {
38 alert(ex);
40 </script>
41 </body>
42 </html>