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

Unified Diff: Source/core/fileapi/FileReader.cpp

Issue 399863002: Gracefully handle FileReader() read operations when in a detached state. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 6 years, 5 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 | « LayoutTests/fast/files/resources/file-reader-detached-no-crash-new-window.html ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/fileapi/FileReader.cpp
diff --git a/Source/core/fileapi/FileReader.cpp b/Source/core/fileapi/FileReader.cpp
index 7e7232e71e36e49b2ab577248c24ad8470085f5e..91c1c3bc9afda0d45f6eea5300f06ae16a203209 100644
--- a/Source/core/fileapi/FileReader.cpp
+++ b/Source/core/fileapi/FileReader.cpp
@@ -80,6 +80,9 @@ class FileReader::ThrottlingController FINAL : public NoBaseWillBeGarbageCollect
public:
static ThrottlingController* from(ExecutionContext* context)
{
+ if (!context)
+ return 0;
+
if (context->isDocument()) {
Document* document = toDocument(context);
if (!document->frame())
@@ -285,6 +288,11 @@ void FileReader::readInternal(Blob* blob, FileReaderLoader::ReadType type, Excep
return;
}
+ if (!throttlingController()) {
+ exceptionState.throwDOMException(NotSupportedError, "Reading from a Document-detached FileReader is not supported.");
kinuko 2014/07/17 15:22:24 I don't have strong opinion, but AbortError might
+ return;
+ }
+
// "Snapshot" the Blob data rather than the Blob itself as ongoing
// read operations should not be affected if close() is called on
// the Blob being read.
« no previous file with comments | « LayoutTests/fast/files/resources/file-reader-detached-no-crash-new-window.html ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698