Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- diff --git a/XMLHttpRequest/progress-events-response-data-gzip.htm b/XMLHttpRequest/progress-events-response-data-gzip.htm
- index dc166a2..0580646 100644
- --- a/XMLHttpRequest/progress-events-response-data-gzip.htm
- +++ b/XMLHttpRequest/progress-events-response-data-gzip.htm
- @@ -36,17 +36,20 @@
- * If lengthComputable is true:
- * Event.total must match Content-length header
- - * event.loaded should be a smaller number while resource is loading
- - and match Content-length when loading is finished
- - * Setting event.loaded to equal event.total for each progress event if the
- - resource is not fully downloaded would be cheating
- + * event.loaded must only ever increase in progress events
- + (and may never repeat its value).
- + * event.loaded must never exceed the Content-length.
- * If lengthComputable is false:
- * event.total should be 0
- + * event.loaded must only ever increase in progress events
- + (and may never repeat its value).
- * event.loaded should be the length of the decompressed content, i.e.
- bigger than Content-length header value when finished loading
- */
- + var lastTotal;
- + var lastLoaded = -1;
- client.addEventListener('loadend', test.step_func(function(e){
- var len = parseInt(client.getResponseHeader('content-length'), 10)
- if(e.lengthComputable){
- @@ -59,14 +62,17 @@
- test.done();
- }), false)
- client.addEventListener('progress', test.step_func(function(e){
- - if(e.lengthComputable && e.total && e.loaded && e.target.readyState < 4){
- - assert_not_equals(e.total, e.loaded, 'total should not equal loaded while download/decode is incomplete')
- - // We should only do this assertation once
- - // it's theoretically possible that all the data would get in
- - // and a progress event fire before the readyState switches from 3 to 4 -
- - // in this case we might report bogus and random failures. Better to remove the event listener again..
- - client.removeEventListener('progress', arguments.callee, false);
- + if(lastTotal === undefined){
- + lastTotal = e.total;
- }
- + if(e.lengthComputable && e.total && e.loaded){
- + assert_equals(e.total, lastTotal, 'event.total should remain invariant')
- + assert_less_than_equal(e.loaded, lastTotal, 'event.loaded should not exceed content-length')
- + }else{
- + assert_equals(e.total, 0, 'event.total should be 0')
- + }
- + assert_greater_than(e.loaded, lastLoaded, 'event.loaded should only ever increase')
- + lastLoaded = e.loaded;
- }), false)
- // image.gif is 165375 bytes compressed. Sending 45000 bytes at a time with 1 second delay will load it in 4 seconds
- client.open("GET", "resources/image.gif?pipe=gzip|trickle(45000:d1:r2)", true)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement