Bug 1345457 - Part 1: Fire up an upload abort event when mFlagHadUploadListenersOnSend is true, r=baku

Fire upload.onabort and upload.onloadend when abort() called. Original code
won't fire onabort if mUploadComplete is true.

Per https://xhr.spec.whatwg.org/#request-error-steps xhr.upload.onabort fires before .onabort
This commit is contained in:
Shawn Huang 2017-06-30 10:48:25 -07:00
parent b3685a6ef3
commit f0f1e72503
2 changed files with 14 additions and 2 deletions

View File

@ -218,6 +218,8 @@ var tests =
{ method: "GET", withUpload: none, testAbort: true, testRedirectError: false, testNetworkError: false,
expectedEvents: [{target: XHR, type: "loadstart", optional: false},
{target: XHR, type: "progress", optional: true},
{target: UPLOAD, type: "abort", optional: false},
{target: UPLOAD, type: "loadend", optional: false},
{target: XHR, type: "abort", optional: false},
{target: XHR, type: "loadend", optional: false}]},
{ method: "GET", withUpload: none, testAbort: false, testRedirectError: true, testNetworkError: false,
@ -237,6 +239,8 @@ var tests =
{ method: "GET", withUpload: small, testAbort: true, testRedirectError: false, testNetworkError: false,
expectedEvents: [{target: XHR, type: "loadstart", optional: false},
{target: XHR, type: "progress", optional: true},
{target: UPLOAD, type: "abort", optional: false},
{target: UPLOAD, type: "loadend", optional: false},
{target: XHR, type: "abort", optional: false},
{target: XHR, type: "loadend", optional: false}]},
{ method: "GET", withUpload: small, testAbort: false, testRedirectError: true, testNetworkError: false,
@ -256,6 +260,8 @@ var tests =
{ method: "GET", withUpload: mid, testAbort: true, testRedirectError: false, testNetworkError: false,
expectedEvents: [{target: XHR, type: "loadstart", optional: false},
{target: XHR, type: "progress", optional: true},
{target: UPLOAD, type: "abort", optional: false},
{target: UPLOAD, type: "loadend", optional: false},
{target: XHR, type: "abort", optional: false},
{target: XHR, type: "loadend", optional: false}]},
{ method: "GET", withUpload: mid, testAbort: false, testRedirectError: true, testNetworkError: false,
@ -275,6 +281,8 @@ var tests =
{ method: "GET", withUpload: large, testAbort: true, testRedirectError: false, testNetworkError: false,
expectedEvents: [{target: XHR, type: "loadstart", optional: false},
{target: XHR, type: "progress", optional: true},
{target: UPLOAD, type: "abort", optional: false},
{target: UPLOAD, type: "loadend", optional: false},
{target: XHR, type: "abort", optional: false},
{target: XHR, type: "loadend", optional: false}]},
{ method: "GET", withUpload: large, testAbort: false, testRedirectError: true, testNetworkError: false,
@ -294,6 +302,8 @@ var tests =
{ method: "POST", withUpload: none, testAbort: true, testRedirectError: false, testNetworkError: false,
expectedEvents: [{target: XHR, type: "loadstart", optional: false},
{target: XHR, type: "progress", optional: true},
{target: UPLOAD, type: "abort", optional: false},
{target: UPLOAD, type: "loadend", optional: false},
{target: XHR, type: "abort", optional: false},
{target: XHR, type: "loadend", optional: false}]},
{ method: "POST", withUpload: none, testAbort: false, testRedirectError: true, testNetworkError: false,

View File

@ -1106,10 +1106,12 @@ XMLHttpRequestMainThread::RequestErrorSteps(const ProgressEventType aEventType,
FireReadystatechangeEvent();
// Step 6
if (mUpload && !mUploadComplete) {
if (mUpload) {
// Step 6-1
mUploadComplete = true;
if (!mUploadComplete) {
mUploadComplete = true;
}
// Step 6-2
if (mFlagHadUploadListenersOnSend) {