| 1 | <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> |
|---|
| 2 | <html> |
|---|
| 3 | <head> |
|---|
| 4 | <script type="text/javascript"> |
|---|
| 5 | var djConfig = {isDebug: true}; |
|---|
| 6 | </script> |
|---|
| 7 | <script type="text/javascript" src="../../dojo.js"></script> |
|---|
| 8 | <script language="JavaScript" type="text/javascript"> |
|---|
| 9 | dojo.require("dojo.io.*"); |
|---|
| 10 | </script> |
|---|
| 11 | <script> |
|---|
| 12 | var calls = 0; |
|---|
| 13 | |
|---|
| 14 | var url = location.href; |
|---|
| 15 | var pos = location.href.lastIndexOf("/") || location.href.lastIndexOf("\\"); |
|---|
| 16 | var url = url.substr(pos + 1); |
|---|
| 17 | |
|---|
| 18 | function bind(){ |
|---|
| 19 | calls++; |
|---|
| 20 | var c = Number(calls); |
|---|
| 21 | return dojo.io.bind({ |
|---|
| 22 | url: url, |
|---|
| 23 | async: true, |
|---|
| 24 | load: function(type, data){ |
|---|
| 25 | dojo.debug(+c+" downloaded, check that "+c+" has'nt been aborted."); |
|---|
| 26 | check(c); |
|---|
| 27 | }, |
|---|
| 28 | error: function(type, err){ |
|---|
| 29 | dojo.debug("Error getting "+url); |
|---|
| 30 | dojo.debugShallow(err); |
|---|
| 31 | } |
|---|
| 32 | }); |
|---|
| 33 | } |
|---|
| 34 | |
|---|
| 35 | function check(downloaded){ |
|---|
| 36 | var div = dojo.byId("check"); |
|---|
| 37 | if(typeof downloaded == "number"){ |
|---|
| 38 | if((downloaded==3 || downloaded==6) && (div.firstChild.nodeValue != "Failure...")){ |
|---|
| 39 | div.style.backgroundColor = "green"; |
|---|
| 40 | div.firstChild.nodeValue = "Success!"; |
|---|
| 41 | }else{ |
|---|
| 42 | div.style.backgroundColor = "red"; |
|---|
| 43 | div.firstChild.nodeValue = "Failure..."; |
|---|
| 44 | } |
|---|
| 45 | } |
|---|
| 46 | } |
|---|
| 47 | |
|---|
| 48 | dojo.addOnLoad(function(){ |
|---|
| 49 | dojo.debug("requesting 1"); |
|---|
| 50 | var one = bind(); |
|---|
| 51 | one.abort();dojo.debug("1 aborted"); |
|---|
| 52 | dojo.debug("requesting 2"); |
|---|
| 53 | var two = bind(); |
|---|
| 54 | two.abort();dojo.debug("2 aborted"); |
|---|
| 55 | dojo.debug("requesting 3"); |
|---|
| 56 | var three = bind(); |
|---|
| 57 | dojo.debug("requesting 4"); |
|---|
| 58 | var four = bind(); |
|---|
| 59 | four.abort();dojo.debug("4 aborted"); |
|---|
| 60 | dojo.debug("requesting 5"); |
|---|
| 61 | var five = bind(); |
|---|
| 62 | five.abort();dojo.debug("5 aborted"); |
|---|
| 63 | dojo.debug("requesting 6"); |
|---|
| 64 | var six = bind(); |
|---|
| 65 | }); |
|---|
| 66 | </script> |
|---|
| 67 | </head> |
|---|
| 68 | <body> |
|---|
| 69 | <h2>Check that we have exactly one downloaded file, no more no less.<h2/> |
|---|
| 70 | <div id="check" style="background-color: yellow;">Probing....</div> |
|---|
| 71 | </body> |
|---|
| 72 | </html> |
|---|