Diff
Modified: trunk/LayoutTests/ChangeLog (230065 => 230066)
--- trunk/LayoutTests/ChangeLog 2018-03-29 03:27:58 UTC (rev 230065)
+++ trunk/LayoutTests/ChangeLog 2018-03-29 04:16:26 UTC (rev 230066)
@@ -1,3 +1,26 @@
+2018-03-28 Chris Dumez <[email protected]>
+
+ Align XMLHttpRequest's open() / send() / abort() with the latest specification
+ https://bugs.webkit.org/show_bug.cgi?id=184108
+
+ Reviewed by Youenn Fablet.
+
+ * http/tests/xmlhttprequest/onloadend-event-after-abort.html:
+ * http/tests/xmlhttprequest/onloadend-event-after-error.html:
+ * http/tests/xmlhttprequest/simple-cross-origin-progress-events-expected.txt:
+ * http/tests/xmlhttprequest/upload-onloadend-event-after-abort.html:
+ * http/tests/xmlhttprequest/xmlhttprequest-sync-no-progress-events-expected.txt:
+ Fix tests that expected a progress event before error/abort event. This is not as
+ per specification and those tests were also failing in Firefox.
+
+ * http/tests/xmlhttprequest/readystatechange-and-abort.html:
+ Fix test that expected abort() to reset state to UNSENT as this is not as per specification.
+ This test was failing in both Firefox and Chrome.
+
+ * http/tests/xmlhttprequest/xmlhttprequest-abort-readyState-shouldNotDispatchEvent.html:
+ Re-sync test from Blink. The test was wrongly expecting abort() to reset the state to
+ UNSENT.
+
2018-03-28 Timothy Hatcher <[email protected]>
Consolidate NSColor to WebCore::Color conversion and fix system colors.
Modified: trunk/LayoutTests/http/tests/xmlhttprequest/onloadend-event-after-abort.html (230065 => 230066)
--- trunk/LayoutTests/http/tests/xmlhttprequest/onloadend-event-after-abort.html 2018-03-29 03:27:58 UTC (rev 230065)
+++ trunk/LayoutTests/http/tests/xmlhttprequest/onloadend-event-after-abort.html 2018-03-29 04:16:26 UTC (rev 230066)
@@ -22,7 +22,7 @@
var xhr = new XMLHttpRequest();
var results = "";
-var expected = " loadstart readyState=DONE progress abort loadend";
+var expected = " loadstart readyState=DONE abort loadend";
function logProgressEvent(e) {
results += " " + e.type;
Modified: trunk/LayoutTests/http/tests/xmlhttprequest/onloadend-event-after-error.html (230065 => 230066)
--- trunk/LayoutTests/http/tests/xmlhttprequest/onloadend-event-after-error.html 2018-03-29 03:27:58 UTC (rev 230065)
+++ trunk/LayoutTests/http/tests/xmlhttprequest/onloadend-event-after-error.html 2018-03-29 04:16:26 UTC (rev 230066)
@@ -22,7 +22,7 @@
var xhr = new XMLHttpRequest();
var results = "";
-var expected = " loadstart readyState=DONE progress error loadend";
+var expected = " loadstart readyState=DONE error loadend";
function logProgressEvent(e) {
Modified: trunk/LayoutTests/http/tests/xmlhttprequest/readystatechange-and-abort.html (230065 => 230066)
--- trunk/LayoutTests/http/tests/xmlhttprequest/readystatechange-and-abort.html 2018-03-29 03:27:58 UTC (rev 230065)
+++ trunk/LayoutTests/http/tests/xmlhttprequest/readystatechange-and-abort.html 2018-03-29 04:16:26 UTC (rev 230066)
@@ -36,7 +36,7 @@
});
xhr.open("GET", "resources/test.ogv", true);
xhr.abort();
- assert_equals(xhr.readyState, xhr.UNSENT, "xhr.readyState after abort() call");
+ assert_equals(xhr.readyState, xhr.OPENED, "xhr.readyState after abort() call");
assert_array_equals(seenStates, [xhr.OPENED]);
}, "Test onreadystatechange invocation when abort()-ed in OPENED state.");
Modified: trunk/LayoutTests/http/tests/xmlhttprequest/simple-cross-origin-progress-events-expected.txt (230065 => 230066)
--- trunk/LayoutTests/http/tests/xmlhttprequest/simple-cross-origin-progress-events-expected.txt 2018-03-29 03:27:58 UTC (rev 230065)
+++ trunk/LayoutTests/http/tests/xmlhttprequest/simple-cross-origin-progress-events-expected.txt 2018-03-29 04:16:26 UTC (rev 230066)
@@ -9,15 +9,12 @@
Response length: 8388608
Test 2: The URL is not allowed for cross-origin requests
-onprogress
onerror (expected)
Response length: 0
Test 3: The URL is not allowed for cross-origin requests and at least one upload event is listened for before doing the send.
upload.onloadstart
-upload.onprogress
upload.onerror (expected)
-onprogress
onerror (expected)
Response length: 0
Modified: trunk/LayoutTests/http/tests/xmlhttprequest/upload-onloadend-event-after-abort.html (230065 => 230066)
--- trunk/LayoutTests/http/tests/xmlhttprequest/upload-onloadend-event-after-abort.html 2018-03-29 03:27:58 UTC (rev 230065)
+++ trunk/LayoutTests/http/tests/xmlhttprequest/upload-onloadend-event-after-abort.html 2018-03-29 04:16:26 UTC (rev 230066)
@@ -21,7 +21,7 @@
var xhr = new XMLHttpRequest();
var results = "";
-var expected = " progress abort loadend";
+var expected = " abort loadend";
function logProgressEvent(e) {
results += " " + e.type;
Modified: trunk/LayoutTests/http/tests/xmlhttprequest/xmlhttprequest-abort-readyState-shouldNotDispatchEvent.html (230065 => 230066)
--- trunk/LayoutTests/http/tests/xmlhttprequest/xmlhttprequest-abort-readyState-shouldNotDispatchEvent.html 2018-03-29 03:27:58 UTC (rev 230065)
+++ trunk/LayoutTests/http/tests/xmlhttprequest/xmlhttprequest-abort-readyState-shouldNotDispatchEvent.html 2018-03-29 04:16:26 UTC (rev 230066)
@@ -37,12 +37,20 @@
++finishedTests;
this._onreadystatechange_ = catchReadystateEventAbort;
this.abort();
- if (this.readyState == 0)
+ // Following https://github.com/whatwg/xhr/issues/54, abort() should
+ // set readyState to UNSENT only when it (readyState) is DONE.
+ var pass;
+ if (num == XMLHttpRequest.DONE)
+ pass = this.readyState == XMLHttpRequest.UNSENT;
+ else
+ pass = this.readyState == num;
+
+ if (pass)
log("PASS");
else
log("FAILED");
}
-
+
if (finishedTests == abortToDo.length && window.testRunner)
testRunner.notifyDone();
}
Modified: trunk/LayoutTests/http/tests/xmlhttprequest/xmlhttprequest-sync-no-progress-events-expected.txt (230065 => 230066)
--- trunk/LayoutTests/http/tests/xmlhttprequest/xmlhttprequest-sync-no-progress-events-expected.txt 2018-03-29 03:27:58 UTC (rev 230065)
+++ trunk/LayoutTests/http/tests/xmlhttprequest/xmlhttprequest-sync-no-progress-events-expected.txt 2018-03-29 04:16:26 UTC (rev 230066)
@@ -10,7 +10,6 @@
Step 2: Cross origin request, disallowed
readystatechange 4
-progress
error
loadend
NetworkError: A network error occurred.
Added: trunk/LayoutTests/imported/blink/http/tests/xmlhttprequest/resources/get.txt (0 => 230066)
--- trunk/LayoutTests/imported/blink/http/tests/xmlhttprequest/resources/get.txt (rev 0)
+++ trunk/LayoutTests/imported/blink/http/tests/xmlhttprequest/resources/get.txt 2018-03-29 04:16:26 UTC (rev 230066)
@@ -0,0 +1 @@
+PASS
\ No newline at end of file
Modified: trunk/LayoutTests/imported/w3c/ChangeLog (230065 => 230066)
--- trunk/LayoutTests/imported/w3c/ChangeLog 2018-03-29 03:27:58 UTC (rev 230065)
+++ trunk/LayoutTests/imported/w3c/ChangeLog 2018-03-29 04:16:26 UTC (rev 230066)
@@ -1,3 +1,27 @@
+2018-03-28 Chris Dumez <[email protected]>
+
+ Align XMLHttpRequest's open() / send() / abort() with the latest specification
+ https://bugs.webkit.org/show_bug.cgi?id=184108
+
+ Reviewed by Youenn Fablet.
+
+ * web-platform-tests/XMLHttpRequest/abort-after-send-expected.txt:
+ * web-platform-tests/XMLHttpRequest/abort-during-open-expected.txt:
+ * web-platform-tests/XMLHttpRequest/abort-during-open.worker-expected.txt:
+ * web-platform-tests/XMLHttpRequest/abort-event-abort-expected.txt:
+ * web-platform-tests/XMLHttpRequest/abort-event-order-expected.txt:
+ * web-platform-tests/XMLHttpRequest/open-during-abort-event-expected.txt:
+ * web-platform-tests/XMLHttpRequest/open-during-abort-expected.txt:
+ * web-platform-tests/XMLHttpRequest/open-send-during-abort-expected.txt:
+ * web-platform-tests/XMLHttpRequest/security-consideration.sub-expected.txt:
+ * web-platform-tests/XMLHttpRequest/send-data-unexpected-tostring-expected.txt:
+ Rebaseline WPT tests that are now passing.
+
+ * web-platform-tests/XMLHttpRequest/open-during-abort-processing-expected.txt:
+ We now fail the test differently. Our results are consistent with Firefox. I believe this
+ test does not match the specification so I filed:
+ https://github.com/w3c/web-platform-tests/issues/10217
+
2018-03-28 Ryan Haddad <[email protected]>
Unreviewed, rolling out r230033.
Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/XMLHttpRequest/abort-after-send-expected.txt (230065 => 230066)
--- trunk/LayoutTests/imported/w3c/web-platform-tests/XMLHttpRequest/abort-after-send-expected.txt 2018-03-29 03:27:58 UTC (rev 230065)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/XMLHttpRequest/abort-after-send-expected.txt 2018-03-29 04:16:26 UTC (rev 230066)
@@ -1,3 +1,3 @@
-FAIL XMLHttpRequest: abort() after send() assert_equals: expected "abort(0,0,false)" but got "upload.progress(0,0,false)"
+PASS XMLHttpRequest: abort() after send()
Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/XMLHttpRequest/abort-during-open-expected.txt (230065 => 230066)
--- trunk/LayoutTests/imported/w3c/web-platform-tests/XMLHttpRequest/abort-during-open-expected.txt 2018-03-29 03:27:58 UTC (rev 230065)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/XMLHttpRequest/abort-during-open-expected.txt 2018-03-29 04:16:26 UTC (rev 230066)
@@ -1,3 +1,3 @@
-FAIL XMLHttpRequest: abort() during OPEN assert_equals: after abort() expected 1 but got 0
+PASS XMLHttpRequest: abort() during OPEN
Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/XMLHttpRequest/abort-during-open.worker-expected.txt (230065 => 230066)
--- trunk/LayoutTests/imported/w3c/web-platform-tests/XMLHttpRequest/abort-during-open.worker-expected.txt 2018-03-29 03:27:58 UTC (rev 230065)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/XMLHttpRequest/abort-during-open.worker-expected.txt 2018-03-29 04:16:26 UTC (rev 230066)
@@ -1,3 +1,3 @@
-FAIL Untitled assert_equals: after abort() expected 1 but got 0
+PASS Untitled
Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/XMLHttpRequest/abort-event-abort-expected.txt (230065 => 230066)
--- trunk/LayoutTests/imported/w3c/web-platform-tests/XMLHttpRequest/abort-event-abort-expected.txt 2018-03-29 03:27:58 UTC (rev 230065)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/XMLHttpRequest/abort-event-abort-expected.txt 2018-03-29 04:16:26 UTC (rev 230066)
@@ -1,3 +1,3 @@
-FAIL XMLHttpRequest: The abort() method: do not fire abort event in OPENED state when send() flag is unset. assert_equals: abort() cannot change readyState when readyState is 1 and send() flag is unset expected 1 but got 0
+PASS XMLHttpRequest: The abort() method: do not fire abort event in OPENED state when send() flag is unset.
Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/XMLHttpRequest/abort-event-order-expected.txt (230065 => 230066)
--- trunk/LayoutTests/imported/w3c/web-platform-tests/XMLHttpRequest/abort-event-order-expected.txt 2018-03-29 03:27:58 UTC (rev 230065)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/XMLHttpRequest/abort-event-order-expected.txt 2018-03-29 04:16:26 UTC (rev 230066)
@@ -1,3 +1,3 @@
-FAIL XMLHttpRequest: The abort() method: abort and loadend events assert_equals: expected "upload.abort(0,0,false)" but got "upload.progress(0,0,false)"
+PASS XMLHttpRequest: The abort() method: abort and loadend events
Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/XMLHttpRequest/open-during-abort-event-expected.txt (230065 => 230066)
--- trunk/LayoutTests/imported/w3c/web-platform-tests/XMLHttpRequest/open-during-abort-event-expected.txt 2018-03-29 03:27:58 UTC (rev 230065)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/XMLHttpRequest/open-during-abort-event-expected.txt 2018-03-29 04:16:26 UTC (rev 230066)
@@ -1,3 +1,3 @@
-FAIL XMLHttpRequest: open() during abort event - abort() called from upload.onloadstart assert_array_equals: property 5, expected "readyState after abort() 1" but got "readyState after abort() 0"
+PASS XMLHttpRequest: open() during abort event - abort() called from upload.onloadstart
Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/XMLHttpRequest/open-during-abort-expected.txt (230065 => 230066)
--- trunk/LayoutTests/imported/w3c/web-platform-tests/XMLHttpRequest/open-during-abort-expected.txt 2018-03-29 03:27:58 UTC (rev 230065)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/XMLHttpRequest/open-during-abort-expected.txt 2018-03-29 04:16:26 UTC (rev 230066)
@@ -1,3 +1,3 @@
-FAIL XMLHttpRequest: open() during abort() assert_equals: expected 1 but got 0
+PASS XMLHttpRequest: open() during abort()
Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/XMLHttpRequest/open-during-abort-processing-expected.txt (230065 => 230066)
--- trunk/LayoutTests/imported/w3c/web-platform-tests/XMLHttpRequest/open-during-abort-processing-expected.txt 2018-03-29 03:27:58 UTC (rev 230065)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/XMLHttpRequest/open-during-abort-processing-expected.txt 2018-03-29 04:16:26 UTC (rev 230066)
@@ -1,3 +1,3 @@
-FAIL XMLHttpRequest: open() during abort processing - abort() called from onloadstart assert_array_equals: property 7, expected "readyState after abort() 1" but got "readyState after abort() 0"
+FAIL XMLHttpRequest: open() during abort processing - abort() called from onloadstart assert_array_equals: lengths differ, expected 9 got 7
Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/XMLHttpRequest/open-send-during-abort-expected.txt (230065 => 230066)
--- trunk/LayoutTests/imported/w3c/web-platform-tests/XMLHttpRequest/open-send-during-abort-expected.txt 2018-03-29 03:27:58 UTC (rev 230065)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/XMLHttpRequest/open-send-during-abort-expected.txt 2018-03-29 04:16:26 UTC (rev 230066)
@@ -1,3 +1,3 @@
-FAIL XMLHttpRequest: open() during abort() assert_array_equals: property 2, expected 1 but got 0
+PASS XMLHttpRequest: open() during abort()
Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/XMLHttpRequest/security-consideration.sub-expected.txt (230065 => 230066)
--- trunk/LayoutTests/imported/w3c/web-platform-tests/XMLHttpRequest/security-consideration.sub-expected.txt 2018-03-29 03:27:58 UTC (rev 230065)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/XMLHttpRequest/security-consideration.sub-expected.txt 2018-03-29 04:16:26 UTC (rev 230066)
@@ -1,5 +1,5 @@
CONSOLE MESSAGE: Origin http://localhost:8800 is not allowed by Access-Control-Allow-Origin.
CONSOLE MESSAGE: XMLHttpRequest cannot load http://localhost:8801/XMLHttpRequest/resources/img.jpg due to access control checks.
-FAIL ProgressEvent: security consideration assert_unreached: MUST NOT dispatch progress event. Reached unreachable code
+PASS ProgressEvent: security consideration
Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/XMLHttpRequest/send-data-unexpected-tostring-expected.txt (230065 => 230066)
--- trunk/LayoutTests/imported/w3c/web-platform-tests/XMLHttpRequest/send-data-unexpected-tostring-expected.txt 2018-03-29 03:27:58 UTC (rev 230065)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/XMLHttpRequest/send-data-unexpected-tostring-expected.txt 2018-03-29 04:16:26 UTC (rev 230066)
@@ -1,5 +1,5 @@
-FAIL abort() called from data stringification The object is in an invalid state.
+PASS abort() called from data stringification
PASS open() called from data stringification
PASS send() called from data stringification
Modified: trunk/Source/WebCore/ChangeLog (230065 => 230066)
--- trunk/Source/WebCore/ChangeLog 2018-03-29 03:27:58 UTC (rev 230065)
+++ trunk/Source/WebCore/ChangeLog 2018-03-29 04:16:26 UTC (rev 230066)
@@ -1,3 +1,47 @@
+2018-03-28 Chris Dumez <[email protected]>
+
+ Align XMLHttpRequest's open() / send() / abort() with the latest specification
+ https://bugs.webkit.org/show_bug.cgi?id=184108
+
+ Reviewed by Youenn Fablet.
+
+ Align XMLHttpRequest's open() / send() / abort() with the latest specification:
+ - https://xhr.spec.whatwg.org
+
+ No new tests, rebaselined existing layout tests.
+
+ * xml/XMLHttpRequest.cpp:
+ (WebCore::XMLHttpRequest::open):
+ Align with https://xhr.spec.whatwg.org/#the-open()-method:
+ - Change the order of some steps to match the order in the spec. In particular,
+ open() no longer resets the state to UNSENT or abort any existing load when it
+ fails early due to being passed a bad method.
+
+ (WebCore::XMLHttpRequest::createRequest):
+ Align with https://xhr.spec.whatwg.org/#the-send()-method:
+ - Use the simpler "upload listener flag" logic from the spec instead of our more
+ complex m_uploadEventsAllowed flag. This avoids constructing a SecurityOrigin
+ objects on a background thread when XHR is used inside Web Workers, which was
+ not thread-safe.
+ - Set the upload complete flag when the request has no body as per step 9.
+ - After firing the loadstartEvent, return early if the state is no longer OPEN or
+ if the send flag is unset, as per step 11.3.
+
+ (WebCore::XMLHttpRequest::abort):
+ Align with https://xhr.spec.whatwg.org/#the-abort()-method:
+ - Only set the state to UNSENT if the state is still DONE after firing the error
+ events, as per step 3.
+
+ (WebCore::XMLHttpRequest::didSendData):
+ Use new "upload listener flag".
+
+ (WebCore::XMLHttpRequest::dispatchErrorEvents):
+ Align with https://xhr.spec.whatwg.org/#request-error-steps:
+ - Stop firing a progress event in case of error as this is not as per specification
+ and Firefox does not fire those either.
+
+ * xml/XMLHttpRequest.h:
+
2018-03-28 Timothy Hatcher <[email protected]>
Consolidate NSColor to WebCore::Color conversion and fix system colors.
Modified: trunk/Source/WebCore/xml/XMLHttpRequest.cpp (230065 => 230066)
--- trunk/Source/WebCore/xml/XMLHttpRequest.cpp 2018-03-29 03:27:58 UTC (rev 230065)
+++ trunk/Source/WebCore/xml/XMLHttpRequest.cpp 2018-03-29 04:16:26 UTC (rev 230066)
@@ -329,22 +329,6 @@
ExceptionOr<void> XMLHttpRequest::open(const String& method, const URL& url, bool async)
{
- if (!internalAbort())
- return { };
-
- State previousState = m_state;
- m_state = UNSENT;
- m_error = false;
- m_sendFlag = false;
- m_uploadComplete = false;
- m_wasAbortedByClient = false;
-
- // clear stuff from possible previous load
- clearResponse();
- clearRequest();
-
- ASSERT(m_state == UNSENT);
-
if (!isValidHTTPToken(method))
return Exception { SyntaxError };
@@ -368,8 +352,20 @@
}
}
+ if (!internalAbort())
+ return { };
+
+ m_sendFlag = false;
+ m_uploadListenerFlag = false;
m_method = normalizeHTTPMethod(method);
+ m_error = false;
+ m_uploadComplete = false;
+ m_wasAbortedByClient = false;
+ // clear stuff from possible previous load
+ clearResponse();
+ clearRequest();
+
m_url = url;
scriptExecutionContext()->contentSecurityPolicy()->upgradeInsecureRequestIfNeeded(m_url, ContentSecurityPolicy::InsecureRequestType::Load);
@@ -377,12 +373,7 @@
ASSERT(!m_loader);
- // Check previous state to avoid dispatching readyState event
- // when calling open several times in a row.
- if (previousState != OPENED)
- changeState(OPENED);
- else
- m_state = OPENED;
+ changeState(OPENED);
return { };
}
@@ -571,26 +562,9 @@
if (!m_async && m_url.protocolIsBlob() && m_method != "GET")
return Exception { NetworkError };
- m_sendFlag = true;
+ if (m_async && m_upload && m_upload->hasEventListeners())
+ m_uploadListenerFlag = true;
- // The presence of upload event listeners forces us to use preflighting because POSTing to an URL that does not
- // permit cross origin requests should look exactly like POSTing to an URL that does not respond at all.
- // Also, only async requests support upload progress events.
- bool uploadEvents = false;
- if (m_async) {
- m_progressEventThrottle.dispatchProgressEvent(eventNames().loadstartEvent);
- if (m_requestEntityBody && m_upload) {
- uploadEvents = m_upload->hasEventListeners();
- m_upload->dispatchProgressEvent(eventNames().loadstartEvent);
- }
- }
-
- m_sameOriginRequest = securityOrigin()->canRequest(m_url);
-
- // We also remember whether upload events should be allowed for this request in case the upload listeners are
- // added after the request is started.
- m_uploadEventsAllowed = m_sameOriginRequest || uploadEvents || !isSimpleCrossOriginAccessRequest(m_method, m_requestHeaders);
-
ResourceRequest request(m_url);
request.setRequester(ResourceRequest::Requester::XHR);
request.setInitiatorIdentifier(scriptExecutionContext()->resourceRequestIdentifier());
@@ -607,7 +581,9 @@
ThreadableLoaderOptions options;
options.sendLoadCallbacks = SendCallbacks;
- options.preflightPolicy = uploadEvents ? ForcePreflight : ConsiderPreflight;
+ // The presence of upload event listeners forces us to use preflighting because POSTing to an URL that does not
+ // permit cross origin requests should look exactly like POSTing to an URL that does not respond at all.
+ options.preflightPolicy = m_uploadListenerFlag ? ForcePreflight : ConsiderPreflight;
options.credentials = m_includeCredentials ? FetchOptions::Credentials::Include : FetchOptions::Credentials::SameOrigin;
options.mode = FetchOptions::Mode::Cors;
options.contentSecurityPolicyEnforcement = scriptExecutionContext()->shouldBypassMainWorldContentSecurityPolicy() ? ContentSecurityPolicyEnforcement::DoNotEnforce : ContentSecurityPolicyEnforcement::EnforceConnectSrcDirective;
@@ -628,8 +604,17 @@
m_exceptionCode = std::nullopt;
m_error = false;
+ m_uploadComplete = !request.httpBody();
+ m_sendFlag = true;
if (m_async) {
+ m_progressEventThrottle.dispatchProgressEvent(eventNames().loadstartEvent);
+ if (!m_uploadComplete && m_uploadListenerFlag)
+ m_upload->dispatchProgressEvent(eventNames().loadstartEvent);
+
+ if (m_state != OPENED || !m_sendFlag || m_loader)
+ return { };
+
// ThreadableLoader::create can return null here, for example if we're no longer attached to a page or if a content blocker blocks the load.
// This is true while running onunload handlers.
// FIXME: Maybe we need to be able to send XMLHttpRequests from onunload, <http://bugs.webkit.org/show_bug.cgi?id=10904>.
@@ -668,7 +653,6 @@
clearResponseBuffers();
- // Clear headers as required by the spec
m_requestHeaders.clear();
if ((m_state == OPENED && m_sendFlag) || m_state == HEADERS_RECEIVED || m_state == LOADING) {
ASSERT(!m_loader);
@@ -676,7 +660,8 @@
changeState(DONE);
dispatchErrorEvents(eventNames().abortEvent);
}
- m_state = UNSENT;
+ if (m_state == DONE)
+ m_state = UNSENT;
}
bool XMLHttpRequest::internalAbort()
@@ -960,11 +945,12 @@
if (!m_upload)
return;
- if (m_uploadEventsAllowed)
+ if (m_uploadListenerFlag)
m_upload->dispatchThrottledProgressEvent(true, bytesSent, totalBytesToBeSent);
+
if (bytesSent == totalBytesToBeSent && !m_uploadComplete) {
m_uploadComplete = true;
- if (m_uploadEventsAllowed) {
+ if (m_uploadListenerFlag) {
m_upload->dispatchProgressEvent(eventNames().loadEvent);
m_upload->dispatchProgressEvent(eventNames().loadendEvent);
}
@@ -1083,13 +1069,11 @@
{
if (!m_uploadComplete) {
m_uploadComplete = true;
- if (m_upload && m_uploadEventsAllowed) {
- m_upload->dispatchProgressEvent(eventNames().progressEvent);
+ if (m_upload && m_uploadListenerFlag) {
m_upload->dispatchProgressEvent(type);
m_upload->dispatchProgressEvent(eventNames().loadendEvent);
}
}
- m_progressEventThrottle.dispatchProgressEvent(eventNames().progressEvent);
m_progressEventThrottle.dispatchProgressEvent(type);
m_progressEventThrottle.dispatchProgressEvent(eventNames().loadendEvent);
}
Modified: trunk/Source/WebCore/xml/XMLHttpRequest.h (230065 => 230066)
--- trunk/Source/WebCore/xml/XMLHttpRequest.h 2018-03-29 03:27:58 UTC (rev 230065)
+++ trunk/Source/WebCore/xml/XMLHttpRequest.h 2018-03-29 04:16:26 UTC (rev 230066)
@@ -205,10 +205,9 @@
bool m_error { false };
- bool m_uploadEventsAllowed { true };
+ bool m_uploadListenerFlag { false };
bool m_uploadComplete { false };
- bool m_sameOriginRequest { true };
bool m_wasAbortedByClient { false };
// Used for progress event tracking.