OLD | NEW |
1 <html> | 1 <html> |
2 <body> | 2 <body> |
3 <p>Tests for <a href="https://bugs.webkit.org/show_bug.cgi?id=15102">bug 15102</
a> - | 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> | 4 XMLHttpRequest should dispatch readystatechange event.</p> |
5 <p>If this passes you should see alerts for onreadystatechange and for a readyst
atechange listener.</p> | 5 <p>If this passes you should see alerts for onreadystatechange and for a readyst
atechange listener.</p> |
6 <script> | 6 <script> |
7 if (window.testRunner) | 7 if (window.testRunner) |
8 testRunner.dumpAsText(); | 8 testRunner.dumpAsText(); |
9 | 9 |
10 function called1(evt) { | 10 function called1(evt) { |
11 alert("onreadystatechange called"); | 11 alert("onreadystatechange called"); |
12 alert("evt.constructor = " + evt.constructor); | 12 alert("evt.constructor = " + evt.constructor); |
13 if (evt instanceof XMLHttpRequestProgressEvent) { | 13 if (evt instanceof ProgressEvent) { |
14 alert("FAIL: evt must not be an instance of XMLHttpRequestProgressEv
ent"); | 14 alert("FAIL: evt must not be an instance of ProgressEvent"); |
15 } | 15 } |
16 evt.foo = "bar"; | 16 evt.foo = "bar"; |
17 } | 17 } |
18 | 18 |
19 function called2(evt) { | 19 function called2(evt) { |
20 evt.stopPropagation(); // stopPropagation shouldn't have any effect, as
we don't have an hierarchy to traverse | 20 evt.stopPropagation(); // stopPropagation shouldn't have any effect, as
we don't have an hierarchy to traverse |
21 } | 21 } |
22 | 22 |
23 function called3(evt) { | 23 function called3(evt) { |
24 if (evt.foo == "bar") | 24 if (evt.foo == "bar") |
25 alert("readystatechange listener called"); | 25 alert("readystatechange listener called"); |
26 else | 26 else |
27 alert("ERROR: readystatechange listener called, but the event object
is not the same as in onreadystatechange!"); | 27 alert("ERROR: readystatechange listener called, but the event object
is not the same as in onreadystatechange!"); |
28 } | 28 } |
29 | 29 |
30 try { | 30 try { |
31 var XHR = new XMLHttpRequest(); | 31 var XHR = new XMLHttpRequest(); |
32 XHR.onreadystatechange = called1; | 32 XHR.onreadystatechange = called1; |
33 XHR.addEventListener("readystatechange", called2, false); | 33 XHR.addEventListener("readystatechange", called2, false); |
34 XHR.addEventListener("readystatechange", called3, false); | 34 XHR.addEventListener("readystatechange", called3, false); |
35 | 35 |
36 XHR.open("GET", "readystatechange.html", true); | 36 XHR.open("GET", "readystatechange.html", true); |
37 } catch (ex) { | 37 } catch (ex) { |
38 alert(ex); | 38 alert(ex); |
39 } | 39 } |
40 </script> | 40 </script> |
41 </body> | 41 </body> |
42 </html> | 42 </html> |
OLD | NEW |