- From: berniegp <notifications@github.com>
- Date: Sat, 22 Oct 2016 09:48:18 -0700
- To: whatwg/xhr <xhr@noreply.github.com>
- Message-ID: <whatwg/xhr/issues/95/255539546@github.com>
Here is my test case: ```javascript // Returns an array which contains all events fired by the xhr function recordEvents(xhr) { var xhrEvents = [ 'loadstart', 'progress', 'abort', 'error', 'load', 'timeout', 'loadend', ]; var events = []; var recordEvent = function(e, prefix) { prefix = prefix ? 'upload.' : ''; events.push(prefix + e.type + '(' + e.loaded + ',' + e.total + ',' + e.lengthComputable +')'); }; var recordUploadEvent = function(event) { recordEvent(event, 'upload'); }; for (var i = 0; i < xhrEvents.length; i++) { xhr.addEventListener(xhrEvents[i], recordEvent); xhr.upload.addEventListener(xhrEvents[i], recordUploadEvent); } xhr.addEventListener('readystatechange', function() { events.push('readystatechange(' + this.readyState + ')'); }); return events; } var xhr; // Test-case 1: effect of the upload listener flag on upload progress events xhr = new XMLHttpRequest(); xhr.open('POST', './'); xhr.send('body!'); // listeners added AFTER send() -> upload listener flag === false var events1 = recordEvents(xhr); // Test-case 2: effect of the upload listener flag on upload progress events during abort() xhr = new XMLHttpRequest(); xhr.open('POST', './'); xhr.send('body!'); // listeners added AFTER send() -> upload listener flag === false var events2 = recordEvents(xhr); xhr.abort(); // Wait until requests are done setTimeout(function() { console.log(events1, events2); }, 1000); ``` Results in Firefox: [ "upload.progress(5,5,true)", "upload.load(5,5,true)", "upload.loadend(5,5,true)", "readystatechange(2)", "readystatechange(3)", "progress(1589,1589,true)", "readystatechange(4)", "load(1589,1589,true)", "loadend(1589,1589,true)" ] [ "readystatechange(4)", "abort(0,0,false)", "loadend(0,0,false)", "upload.abort(0,5,true)", "upload.loadend(0,5,true)" ] Results in Chrome: ["readystatechange(2)", "readystatechange(3)", "progress(1589,1589,true)", "readystatechange(4)", "load(1589,1589,true)", "loadend(1589,1589,true)"] ["readystatechange(4)", "upload.progress(0,0,false)", "upload.abort(0,0,false)", "upload.loadend(0,0,false)", "progress(0,0,false)", "abort(0,0,false)", "loadend(0,0,false)"] -- You are receiving this because you are subscribed to this thread. Reply to this email directly or view it on GitHub: https://github.com/whatwg/xhr/issues/95#issuecomment-255539546
Received on Saturday, 22 October 2016 16:48:46 UTC