test_progress_events_for_gzip_data.html (1130B)
1 <!DOCTYPE HTML> 2 <html> 3 <head> 4 <title>Test progess events in case of gzipped data.</title> 5 <script src="/tests/SimpleTest/SimpleTest.js"></script> 6 <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/> 7 </head> 8 <body onload="onLoadData()"> 9 <script class="testbody" type="text/javascript">"use strict"; 10 SimpleTest.waitForExplicitFinish(); 11 12 var url = "send_gzip_content.sjs"; 13 var loaded = 0; 14 var total = 0; 15 16 function onProgress(e) { 17 if(e.lengthComputable) { 18 loaded = e.loaded; 19 total = e.total; 20 if (loaded > total) { 21 ok(false, "We have loaded more bytes (" + loaded + 22 ") than the total amount of bytes (" + total + 23 ") available!!!"); 24 } 25 } 26 } 27 28 function onLoadData() { 29 var xhr = new XMLHttpRequest(); 30 xhr.addEventListener('progress', onProgress); 31 xhr.open('GET', url, true); 32 xhr.onreadystatechange = function() { 33 if (xhr.readyState == 4) { 34 is(loaded, total, "loaded should be equal to total"); 35 isnot(loaded, 0, "loaded should be bigger than 0"); 36 SimpleTest.finish(); 37 } 38 } 39 xhr.send(null); 40 } 41 42 </script> 43 </body> 44 </html>