open-url-multi-window-4.htm (1947B)
1 <!doctype html> 2 <html> 3 <head> 4 <title>XMLHttpRequest: open() resolving URLs (multi-Window; 4; evil)</title> 5 <script src="/resources/testharness.js"></script> 6 <script src="/resources/testharnessreport.js"></script> 7 </head> 8 <body> 9 <div id="log"></div> 10 <script> 11 /* 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 */ 18 var test = async_test() 19 function init() { 20 test.step(function() { 21 var hasErrorEvent = false 22 var client = new self[0].XMLHttpRequest() 23 client.onreadystatechange = function() { 24 test.step(function() { 25 if(client.readyState == 4) { 26 assert_equals(client.responseText, "", "responseText is empty on inactive document error condition") 27 } 28 }) 29 } 30 client.addEventListener('error', function(){ 31 test.step(function() { 32 hasErrorEvent = true 33 assert_equals(client.readyState, 4, "readyState is 4 when error listener fires") 34 }) 35 }) 36 client.addEventListener('loadend', function(){ 37 test.step(function() { 38 assert_true(hasErrorEvent, "should get an error event") 39 test.done() 40 }) 41 }) 42 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>