Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(69)

Unified Diff: Source/core/xmlhttprequest/XMLHttpRequestProgressEventThrottle.cpp

Issue 1217803002: Protect readystatechange event dispatch on XMLHttpRequest. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 5 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « Source/core/xmlhttprequest/XMLHttpRequestProgressEventThrottle.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/xmlhttprequest/XMLHttpRequestProgressEventThrottle.cpp
diff --git a/Source/core/xmlhttprequest/XMLHttpRequestProgressEventThrottle.cpp b/Source/core/xmlhttprequest/XMLHttpRequestProgressEventThrottle.cpp
index 5f9e9d15cb07066de244ecd760256d72ddc5a773..f3d619673fd4845ec63c13e1302507978faad4de 100644
--- a/Source/core/xmlhttprequest/XMLHttpRequestProgressEventThrottle.cpp
+++ b/Source/core/xmlhttprequest/XMLHttpRequestProgressEventThrottle.cpp
@@ -28,7 +28,7 @@
#include "core/xmlhttprequest/XMLHttpRequestProgressEventThrottle.h"
#include "core/EventTypeNames.h"
-#include "core/events/EventTarget.h"
+#include "core/xmlhttprequest/XMLHttpRequest.h"
#include "core/xmlhttprequest/XMLHttpRequestProgressEvent.h"
#include "wtf/Assertions.h"
#include "wtf/text/AtomicString.h"
@@ -66,7 +66,7 @@ private:
const double XMLHttpRequestProgressEventThrottle::minimumProgressEventDispatchingIntervalInSeconds = .05; // 50 ms per specification.
-XMLHttpRequestProgressEventThrottle::XMLHttpRequestProgressEventThrottle(EventTarget* target)
+XMLHttpRequestProgressEventThrottle::XMLHttpRequestProgressEventThrottle(XMLHttpRequest* target)
: m_target(target)
, m_deferred(adoptPtr(new DeferredEvent))
{
@@ -96,17 +96,25 @@ void XMLHttpRequestProgressEventThrottle::dispatchProgressEvent(const AtomicStri
void XMLHttpRequestProgressEventThrottle::dispatchReadyStateChangeEvent(PassRefPtrWillBeRawPtr<Event> event, DeferredEventAction action)
{
+ XMLHttpRequest::State state = m_target->readyState();
// Given that ResourceDispatcher doesn't deliver an event when suspended,
// we don't have to worry about event dispatching while suspended.
if (action == Flush) {
dispatchDeferredEvent();
+ // |m_target| is protected by the caller.
stop();
} else if (action == Clear) {
m_deferred->clear();
stop();
}
- m_target->dispatchEvent(event);
+ if (state == m_target->readyState()) {
+ // We don't dispatch the event when an event handler associated with
+ // the previously dispatched event changes the readyState (e.g. when
+ // the event handler calls xhr.abort()). In such cases a
+ // readystatechange should have been already dispatched if necessary.
+ m_target->dispatchEvent(event);
+ }
}
void XMLHttpRequestProgressEventThrottle::dispatchDeferredEvent()
« no previous file with comments | « Source/core/xmlhttprequest/XMLHttpRequestProgressEventThrottle.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698