Index: third_party/WebKit/Source/modules/fetch/ReadableStreamDataConsumerHandle.cpp |
diff --git a/third_party/WebKit/Source/modules/fetch/ReadableStreamDataConsumerHandle.cpp b/third_party/WebKit/Source/modules/fetch/ReadableStreamDataConsumerHandle.cpp |
index 9f4533ad514c5ac482bb27c05f6c8d198f62af4e..ca69f165054155930f38448de3f1a78276f13cf0 100644 |
--- a/third_party/WebKit/Source/modules/fetch/ReadableStreamDataConsumerHandle.cpp |
+++ b/third_party/WebKit/Source/modules/fetch/ReadableStreamDataConsumerHandle.cpp |
@@ -12,8 +12,10 @@ |
#include "bindings/core/v8/V8BindingMacros.h" |
#include "bindings/core/v8/V8IteratorResultValue.h" |
#include "bindings/core/v8/V8Uint8Array.h" |
+#include "bindings/core/v8/WorkerOrWorkletScriptController.h" |
#include "core/dom/DOMTypedArray.h" |
#include "core/streams/ReadableStreamOperations.h" |
+#include "core/workers/WorkerGlobalScope.h" |
#include "public/platform/Platform.h" |
#include "public/platform/WebTaskRunner.h" |
#include "public/platform/WebThread.h" |
@@ -27,6 +29,20 @@ |
namespace blink { |
+namespace { |
+ |
+bool isTerminating(ScriptState* scriptState) |
+{ |
+ ExecutionContext* executionContext = scriptState->getExecutionContext(); |
+ if (!executionContext) |
+ return true; |
+ if (!executionContext->isWorkerGlobalScope()) |
+ return false; |
+ return toWorkerGlobalScope(executionContext)->scriptController()->isExecutionTerminating(); |
+} |
+ |
+} // namespace |
+ |
using Result = WebDataConsumerHandle::Result; |
using Flags = WebDataConsumerHandle::Flags; |
@@ -49,7 +65,11 @@ |
bool done; |
v8::Local<v8::Value> item = v.v8Value(); |
ASSERT(item->IsObject()); |
+ if (isTerminating(v.getScriptState())) |
+ return ScriptValue(); |
v8::MaybeLocal<v8::Value> maybeValue = v8UnpackIteratorResult(v.getScriptState(), item.As<v8::Object>(), &done); |
+ if (isTerminating(v.getScriptState())) |
+ return ScriptValue(); |
v8::Local<v8::Value> value = maybeValue.ToLocalChecked(); |
if (done) { |
readingContext->onReadDone(); |