DescriptionFix XHR's logic to determine whether or not to dispatch upload progress events
Fix the m_uploadEventsAllowed variable (renamed by this commit to
m_uploadListenerFlag) to become true if and only if there're one or more
event handlers registered with the upload attribute.
Here's the background of the bug.
1. The m_uploadEventsAllowed variable has been introduced to
XMLHttpRequest.cpp in
http://crrev.com/405043c1ec2ad3dbb9ed711adc698c7d865923b6 to issue a
preflight when there're one or more event handlers registered with
the upload attribute even when the request is simple. This commit
included one bug that the variable is set to true even when m_async
is not set for same origin requests, but was correct in terms of
handling of same/cross origin and simpleness of a request.
2. http://crrev.com/2c580376f830a33f06f2dd980c532e9e12498571 has
mistakenly refactored the logic to set m_uploadEventsAllowed to true
only when the request is not a simple request.
3. http://crrev.com/a5c5e927f63f72d121b62ddf6c1d9f093555e516 has fixed
the bug partially by setting m_uploadEventsAllowed to true when the
request is same origin.
4. http://crrev.com/03fac94860bfc63750af994932d3d38bd9335b3c has fixed
the bug to set m_uploadEventsAllowed to true when there're one or
more event handlers registered with the upload attribute as the spec
says. But there're still unwanted variables left in the formula
calculating m_uploadEventsAllowed, i.e. m_sameOriginRequest and the
FetchUtils::isSimpleRequest() call.
m_uploadEventsAllowed and m_uploadComplete are renamed to make the
correspondence with the spec term clearer.
setReportUploadProgress() was called if and only if m_upload was not
NULL. But didSendData() was no-op (except for m_uploadComplete
updating but it's also used only for controlling handler invocation
on m_upload) when m_uploadEventAllowed is false. So, change the
condition to call setReportUnloadProgress() to be based on
m_uploadListenerFlag.
The only incompatibility this patch will introduce is that as long as
xhr.upload was touched before xhr.send() and the request is either
same origin or non-simple, we could set handlers to xhr.upload after
xhr.send() call to receive upload progress events. I think this
wouldn't have big impact.
This CL also removed m_httpBody from the condition. But this doesn't fix
the issue that the upload progress events are not dispatched when no
payload is given to send() call since didSendData() is not invoked
for zero length request body.
BUG=none
Patch Set 1 : a #Patch Set 2 : a #
Total comments: 6
Messages
Total messages: 18 (15 generated)
|