- Revision
- 279967
- Author
- [email protected]
- Date
- 2021-07-15 15:52:51 -0700 (Thu, 15 Jul 2021)
Log Message
Sync XHR 'load' event is always has total/loaded=0
https://bugs.webkit.org/show_bug.cgi?id=228004
Reviewed by Alex Christensen.
LayoutTests/imported/w3c:
Rebaseline WPT test that is now passing.
* web-platform-tests/xhr/send-sync-response-event-order-expected.txt:
Source/WebCore:
XMLHttpRequest::didReceiveData() was not calling XMLHttpRequestProgressEventThrottle::dispatchThrottledProgressEvent()
for sync XHRs because we don't want to fire 'progress' events for sync XHR. However, dispatchThrottledProgressEvent()
also updates XMLHttpRequestProgressEventThrottle's m_loaded / m_total members and we do want those to get updated for
sync XHRs, since they get used later on for the 'load' event.
No new tests, rebaselined existing test.
* xml/XMLHttpRequest.cpp:
(WebCore::XMLHttpRequest::didReceiveData):
* xml/XMLHttpRequestProgressEventThrottle.cpp:
(WebCore::XMLHttpRequestProgressEventThrottle::updateProgress):
(WebCore::XMLHttpRequestProgressEventThrottle::dispatchThrottledProgressEvent): Deleted.
* xml/XMLHttpRequestProgressEventThrottle.h:
Modified Paths
Diff
Modified: trunk/LayoutTests/imported/w3c/ChangeLog (279966 => 279967)
--- trunk/LayoutTests/imported/w3c/ChangeLog 2021-07-15 22:45:24 UTC (rev 279966)
+++ trunk/LayoutTests/imported/w3c/ChangeLog 2021-07-15 22:52:51 UTC (rev 279967)
@@ -1,3 +1,14 @@
+2021-07-15 Chris Dumez <[email protected]>
+
+ Sync XHR 'load' event is always has total/loaded=0
+ https://bugs.webkit.org/show_bug.cgi?id=228004
+
+ Reviewed by Alex Christensen.
+
+ Rebaseline WPT test that is now passing.
+
+ * web-platform-tests/xhr/send-sync-response-event-order-expected.txt:
+
2021-07-15 Tim Nguyen <[email protected]>
<dialog> element: do not perform close() method steps when removing open attribute.
Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/xhr/send-sync-response-event-order-expected.txt (279966 => 279967)
--- trunk/LayoutTests/imported/w3c/web-platform-tests/xhr/send-sync-response-event-order-expected.txt 2021-07-15 22:45:24 UTC (rev 279966)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/xhr/send-sync-response-event-order-expected.txt 2021-07-15 22:52:51 UTC (rev 279967)
@@ -1,3 +1,3 @@
-FAIL XMLHttpRequest: The send() method: event order when synchronous flag is set assert_equals: expected "load(12,12,true)" but got "load(0,0,false)"
+PASS XMLHttpRequest: The send() method: event order when synchronous flag is set
Modified: trunk/Source/WebCore/ChangeLog (279966 => 279967)
--- trunk/Source/WebCore/ChangeLog 2021-07-15 22:45:24 UTC (rev 279966)
+++ trunk/Source/WebCore/ChangeLog 2021-07-15 22:52:51 UTC (rev 279967)
@@ -1,3 +1,24 @@
+2021-07-15 Chris Dumez <[email protected]>
+
+ Sync XHR 'load' event is always has total/loaded=0
+ https://bugs.webkit.org/show_bug.cgi?id=228004
+
+ Reviewed by Alex Christensen.
+
+ XMLHttpRequest::didReceiveData() was not calling XMLHttpRequestProgressEventThrottle::dispatchThrottledProgressEvent()
+ for sync XHRs because we don't want to fire 'progress' events for sync XHR. However, dispatchThrottledProgressEvent()
+ also updates XMLHttpRequestProgressEventThrottle's m_loaded / m_total members and we do want those to get updated for
+ sync XHRs, since they get used later on for the 'load' event.
+
+ No new tests, rebaselined existing test.
+
+ * xml/XMLHttpRequest.cpp:
+ (WebCore::XMLHttpRequest::didReceiveData):
+ * xml/XMLHttpRequestProgressEventThrottle.cpp:
+ (WebCore::XMLHttpRequestProgressEventThrottle::updateProgress):
+ (WebCore::XMLHttpRequestProgressEventThrottle::dispatchThrottledProgressEvent): Deleted.
+ * xml/XMLHttpRequestProgressEventThrottle.h:
+
2021-07-15 Sihui Liu <[email protected]>
Do not abort ongoing IDB transaction synchronously on non-imminent PrepareToSuspend message
Modified: trunk/Source/WebCore/xml/XMLHttpRequest.cpp (279966 => 279967)
--- trunk/Source/WebCore/xml/XMLHttpRequest.cpp 2021-07-15 22:45:24 UTC (rev 279966)
+++ trunk/Source/WebCore/xml/XMLHttpRequest.cpp 2021-07-15 22:52:51 UTC (rev 279967)
@@ -1070,12 +1070,10 @@
callReadyStateChangeListener();
}
- if (m_async) {
- long long expectedLength = m_response.expectedContentLength();
- bool lengthComputable = expectedLength > 0 && m_receivedLength <= expectedLength;
- unsigned long long total = lengthComputable ? expectedLength : 0;
- m_progressEventThrottle.dispatchThrottledProgressEvent(lengthComputable, m_receivedLength, total);
- }
+ long long expectedLength = m_response.expectedContentLength();
+ bool lengthComputable = expectedLength > 0 && m_receivedLength <= expectedLength;
+ unsigned long long total = lengthComputable ? expectedLength : 0;
+ m_progressEventThrottle.updateProgress(m_async, lengthComputable, m_receivedLength, total);
}
}
Modified: trunk/Source/WebCore/xml/XMLHttpRequestProgressEventThrottle.cpp (279966 => 279967)
--- trunk/Source/WebCore/xml/XMLHttpRequestProgressEventThrottle.cpp 2021-07-15 22:45:24 UTC (rev 279966)
+++ trunk/Source/WebCore/xml/XMLHttpRequestProgressEventThrottle.cpp 2021-07-15 22:52:51 UTC (rev 279967)
@@ -45,13 +45,13 @@
XMLHttpRequestProgressEventThrottle::~XMLHttpRequestProgressEventThrottle() = default;
-void XMLHttpRequestProgressEventThrottle::dispatchThrottledProgressEvent(bool lengthComputable, unsigned long long loaded, unsigned long long total)
+void XMLHttpRequestProgressEventThrottle::updateProgress(bool isAsync, bool lengthComputable, unsigned long long loaded, unsigned long long total)
{
m_lengthComputable = lengthComputable;
m_loaded = loaded;
m_total = total;
- if (!m_target.hasEventListeners(eventNames().progressEvent))
+ if (!isAsync || !m_target.hasEventListeners(eventNames().progressEvent))
return;
if (!m_shouldDeferEventsDueToSuspension && !m_dispatchThrottledProgressEventTimer.isActive()) {
Modified: trunk/Source/WebCore/xml/XMLHttpRequestProgressEventThrottle.h (279966 => 279967)
--- trunk/Source/WebCore/xml/XMLHttpRequestProgressEventThrottle.h 2021-07-15 22:45:24 UTC (rev 279966)
+++ trunk/Source/WebCore/xml/XMLHttpRequestProgressEventThrottle.h 2021-07-15 22:52:51 UTC (rev 279967)
@@ -47,7 +47,7 @@
explicit XMLHttpRequestProgressEventThrottle(XMLHttpRequest&);
virtual ~XMLHttpRequestProgressEventThrottle();
- void dispatchThrottledProgressEvent(bool lengthComputable, unsigned long long loaded, unsigned long long total);
+ void updateProgress(bool isAsync, bool lengthComputable, unsigned long long loaded, unsigned long long total);
void dispatchReadyStateChangeEvent(Event&, ProgressEventAction = DoNotFlushProgressEvent);
void dispatchProgressEvent(const AtomString&);