blob: 9ddbb9b47722de442b3f4e1889eb7ce75acbc79c [file] [log] [blame]
Anne van Kesteren66b54172010-08-11 18:02:171<!doctype html>
2<html>
3 <head>
4 <title>XMLHttpRequest: open() resolving URLs (multi-Window; 4; evil)</title>
5 <script src="/resources/testharness.js"></script>
Ms2ger6f083e72012-08-05 08:38:146 <script src="/resources/testharnessreport.js"></script>
Anne van Kesteren66b54172010-08-11 18:02:177 </head>
8 <body>
9 <div id="log"></div>
10 <script>
Hallvord Reiar M. Steend1bfdec2013-04-29 13:21:1211 /*
12 It's unclear what the pass condition should be for this test.
13 Implementations:
14 Firefox, Opera (Presto): terminate request with no further events when IFRAME is removed.
15 Chrome: completes request to readyState=4 but responseText is "" so it's pretty much terminated with an extra event for "DONE" state
16 Pass condition is now according to my suggested spec text in https://github.com/whatwg/xhr/pull/3 , if that's not accepted we'll have to amend this test
17 */
Anne van Kesteren66b54172010-08-11 18:02:1718 var test = async_test()
19 function init() {
20 test.step(function() {
Youenn Fablete83a28b2014-06-12 09:58:1921 var hasErrorEvent = false
Anne van Kesteren66b54172010-08-11 18:02:1722 var client = new self[0].XMLHttpRequest()
Hallvord Reiar M. Steend1bfdec2013-04-29 13:21:1223 client.onreadystatechange = function() {
Anne van Kesteren66b54172010-08-11 18:02:1724 test.step(function() {
25 if(client.readyState == 4) {
Hallvord Reiar M. Steend1bfdec2013-04-29 13:21:1226 assert_equals(client.responseText, "", "responseText is empty on inactive document error condition")
Anne van Kesteren66b54172010-08-11 18:02:1727 }
28 })
29 }
Hallvord Reiar M. Steend1bfdec2013-04-29 13:21:1230 client.addEventListener('error', function(){
31 test.step(function() {
Youenn Fablete83a28b2014-06-12 09:58:1932 hasErrorEvent = true
Hallvord Reiar M. Steend1bfdec2013-04-29 13:21:1233 assert_equals(client.readyState, 4, "readyState is 4 when error listener fires")
Youenn Fablete83a28b2014-06-12 09:58:1934 })
35 })
36 client.addEventListener('loadend', function(){
37 test.step(function() {
38 assert_true(hasErrorEvent, "should get an error event")
Hallvord Reiar M. Steend1bfdec2013-04-29 13:21:1239 test.done()
40 })
41 })
Anne van Kesteren66b54172010-08-11 18:02:1742 client.open("GET", "folder.txt")
43 client.send(null)
44 document.body.removeChild(document.getElementsByTagName("iframe")[0])
45 })
46 }
47 </script>
48 <iframe src="resources/init.htm"></iframe>
49 </body>
50</html>