summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--chromium/third_party/blink/renderer/core/fileapi/file_reader.cc14
1 files changed, 8 insertions, 6 deletions
diff --git a/chromium/third_party/blink/renderer/core/fileapi/file_reader.cc b/chromium/third_party/blink/renderer/core/fileapi/file_reader.cc
index d2e87ac7ddf..960d796c218 100644
--- a/chromium/third_party/blink/renderer/core/fileapi/file_reader.cc
+++ b/chromium/third_party/blink/renderer/core/fileapi/file_reader.cc
@@ -332,7 +332,10 @@ void FileReader::abort() {
loading_state_ = kLoadingStateAborted;
DCHECK_NE(kDone, state_);
- state_ = kDone;
+ // Synchronously cancel the loader before dispatching events. This way we make
+ // sure the FileReader internal state stays consistent even if another load
+ // is started from one of the event handlers, or right after abort returns.
+ Terminate();
base::AutoReset<bool> firing_events(&still_firing_events_, true);
@@ -344,15 +347,12 @@ void FileReader::abort() {
ThrottlingController::RemoveReader(GetExecutionContext(), this);
FireEvent(EventTypeNames::abort);
+ // TODO(https://crbug.com/1204139): Only fire loadend event if no new load was
+ // started from the abort event handler.
FireEvent(EventTypeNames::loadend);
// All possible events have fired and we're done, no more pending activity.
ThrottlingController::FinishReader(GetExecutionContext(), this, final_step);
-
- // Also synchronously cancel the loader, as script might initiate a new load
- // right after this method returns, in which case an async termination would
- // terminate the wrong loader.
- Terminate();
}
void FileReader::result(ScriptState* state,
@@ -425,6 +425,8 @@ void FileReader::DidFinishLoading() {
ThrottlingController::RemoveReader(GetExecutionContext(), this);
FireEvent(EventTypeNames::load);
+ // TODO(https://crbug.com/1204139): Only fire loadend event if no new load was
+ // started from the abort event handler.
FireEvent(EventTypeNames::loadend);
// All possible events have fired and we're done, no more pending activity.