Changeset 263883 in webkit
- Timestamp:
- Jul 2, 2020 10:51:58 PM (4 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r263881 r263883 1 2020-07-02 Mark Lam <mark.lam@apple.com> 2 3 ReadableStream::create() should handle any exceptions that may be thrown during construction. 4 https://bugs.webkit.org/show_bug.cgi?id=213819 5 6 Reviewed by Youenn Fablet and Yusuke Suzuki. 7 8 Win EWS detected that ReadableStream::create() can throw exceptions, and we were 9 failing to handle it. This patch fixes that. 10 11 * Modules/cache/DOMCache.cpp: 12 (WebCore::DOMCache::put): 13 * Modules/fetch/FetchBodyOwner.cpp: 14 (WebCore::FetchBodyOwner::readableStream): 15 (WebCore::FetchBodyOwner::createReadableStream): 16 * Modules/fetch/FetchBodyOwner.h: 17 * Modules/fetch/FetchResponse.cpp: 18 (WebCore::FetchResponse::clone): 19 * bindings/js/ReadableStream.cpp: 20 (WebCore::ReadableStream::create): 21 * bindings/js/ReadableStream.h: 22 1 23 2020-07-02 Alex Christensen <achristensen@webkit.org> 2 24 -
trunk/Source/WebCore/Modules/cache/DOMCache.cpp
r263422 r263883 1 1 /* 2 * Copyright (C) 2017 Apple Inc. All rights reserved.2 * Copyright (C) 2017-2020 Apple Inc. All rights reserved. 3 3 * 4 4 * Redistribution and use in source and binary forms, with or without … … 366 366 367 367 // FIXME: for efficiency, we should load blobs directly instead of going through the readableStream path. 368 if (response->isBlobBody()) 369 response->readableStream(*scriptExecutionContext()->execState()); 368 if (response->isBlobBody()) { 369 auto streamOrException = response->readableStream(*scriptExecutionContext()->execState()); 370 if (UNLIKELY(streamOrException.hasException())) { 371 promise.reject(streamOrException.releaseException()); 372 return; 373 } 374 } 370 375 371 376 if (response->isBodyReceivedByChunk()) { -
trunk/Source/WebCore/Modules/fetch/FetchBodyOwner.cpp
r263700 r263883 1 1 /* 2 2 * Copyright (C) 2016 Canon Inc. 3 * Copyright (C) 2020 Apple Inc. All rights reserved. 3 4 * 4 5 * Redistribution and use in source and binary forms, with or without … … 312 313 } 313 314 314 RefPtr<ReadableStream> FetchBodyOwner::readableStream(JSC::JSGlobalObject& state)315 ExceptionOr<RefPtr<ReadableStream>> FetchBodyOwner::readableStream(JSC::JSGlobalObject& state) 315 316 { 316 317 if (isBodyNullOrOpaque()) 317 318 return nullptr; 318 319 319 if (!m_body->hasReadableStream()) 320 createReadableStream(state); 320 if (!m_body->hasReadableStream()) { 321 auto voidOrException = createReadableStream(state); 322 if (UNLIKELY(voidOrException.hasException())) 323 return voidOrException.releaseException(); 324 } 321 325 322 326 return m_body->readableStream(); 323 327 } 324 328 325 voidFetchBodyOwner::createReadableStream(JSC::JSGlobalObject& state)329 ExceptionOr<void> FetchBodyOwner::createReadableStream(JSC::JSGlobalObject& state) 326 330 { 327 331 ASSERT(!m_readableStreamSource); 328 332 if (isDisturbed()) { 329 m_body->setReadableStream(ReadableStream::create(state, nullptr)); 333 auto streamOrException = ReadableStream::create(state, nullptr); 334 if (UNLIKELY(streamOrException.hasException())) 335 return streamOrException.releaseException(); 336 m_body->setReadableStream(streamOrException.releaseReturnValue()); 330 337 m_body->readableStream()->lock(); 331 } else { 332 m_readableStreamSource = adoptRef(*new FetchBodySource(*this)); 333 m_body->setReadableStream(ReadableStream::create(state, m_readableStreamSource)); 334 } 338 return { }; 339 } 340 341 m_readableStreamSource = adoptRef(*new FetchBodySource(*this)); 342 auto streamOrException = ReadableStream::create(state, m_readableStreamSource); 343 if (UNLIKELY(streamOrException.hasException())) { 344 m_readableStreamSource = nullptr; 345 return streamOrException.releaseException(); 346 } 347 m_body->setReadableStream(streamOrException.releaseReturnValue()); 348 return { }; 335 349 } 336 350 -
trunk/Source/WebCore/Modules/fetch/FetchBodyOwner.h
r263700 r263883 1 1 /* 2 2 * Copyright (C) 2016 Canon Inc. 3 * Copyright (C) 2020 Apple Inc. All rights reserved. 3 4 * 4 5 * Redistribution and use in source and binary forms, with or without … … 30 31 31 32 #include "ActiveDOMObject.h" 33 #include "ExceptionOr.h" 32 34 #include "FetchBody.h" 33 35 #include "FetchBodySource.h" … … 58 60 bool isActive() const { return !!m_blobLoader; } 59 61 60 RefPtr<ReadableStream> readableStream(JSC::JSGlobalObject&);62 ExceptionOr<RefPtr<ReadableStream>> readableStream(JSC::JSGlobalObject&); 61 63 bool hasReadableStreamBody() const { return m_body && m_body->hasReadableStream(); } 62 64 … … 81 83 82 84 void setBody(FetchBody&& body) { m_body = WTFMove(body); } 83 voidcreateReadableStream(JSC::JSGlobalObject&);85 ExceptionOr<void> createReadableStream(JSC::JSGlobalObject&); 84 86 85 87 // ActiveDOMObject API -
trunk/Source/WebCore/Modules/fetch/FetchResponse.cpp
r263700 r263883 1 1 /* 2 2 * Copyright (C) 2016 Canon Inc. 3 * Copyright (C) 2020 Apple Inc. All rights reserved. 3 4 * 4 5 * Redistribution and use in source and binary forms, with or without … … 177 178 178 179 // If loading, let's create a stream so that data is teed on both clones. 179 if (isLoading() && !m_readableStreamSource) 180 createReadableStream(*context.execState()); 180 if (isLoading() && !m_readableStreamSource) { 181 auto voidOrException = createReadableStream(*context.execState()); 182 if (UNLIKELY(voidOrException.hasException())) 183 return voidOrException.releaseException(); 184 } 181 185 182 186 // Synthetic responses do not store headers in m_internalResponse. -
trunk/Source/WebCore/bindings/js/ReadableStream.cpp
r260848 r263883 1 1 /* 2 * Copyright (C) 2017 Apple Inc. All rights reserved.2 * Copyright (C) 2017-2020 Apple Inc. All rights reserved. 3 3 * 4 4 * Redistribution and use in source and binary forms, with or without … … 27 27 #include "ReadableStream.h" 28 28 29 #include "Exception.h" 30 #include "ExceptionCode.h" 29 31 #include "JSDOMConvertSequences.h" 30 32 #include "JSReadableStreamSink.h" … … 36 38 using namespace JSC; 37 39 38 Ref<ReadableStream> ReadableStream::create(JSC::JSGlobalObject& lexicalGlobalObject, RefPtr<ReadableStreamSource>&& source)40 ExceptionOr<Ref<ReadableStream>> ReadableStream::create(JSC::JSGlobalObject& lexicalGlobalObject, RefPtr<ReadableStreamSource>&& source) 39 41 { 40 42 VM& vm = lexicalGlobalObject.vm(); 41 auto scope = DECLARE_ CATCH_SCOPE(vm);43 auto scope = DECLARE_THROW_SCOPE(vm); 42 44 43 45 auto& clientData = *static_cast<JSVMClientData*>(vm.clientData); … … 53 55 ASSERT(!args.hasOverflowed()); 54 56 55 auto newReadableStream = jsDynamicCast<JSReadableStream*>(vm, JSC::construct(&lexicalGlobalObject, constructor, constructData, args)); 56 scope.assertNoException(); 57 JSObject* object = JSC::construct(&lexicalGlobalObject, constructor, constructData, args); 58 ASSERT(!!scope.exception() == !object); 59 RETURN_IF_EXCEPTION(scope, Exception { ExistingExceptionError }); 57 60 58 return create(globalObject, * newReadableStream);61 return create(globalObject, *jsCast<JSReadableStream*>(object)); 59 62 } 60 63 -
trunk/Source/WebCore/bindings/js/ReadableStream.h
r260415 r263883 1 1 /* 2 * Copyright (C) 2017 Apple Inc. All rights reserved.2 * Copyright (C) 2017-2020 Apple Inc. All rights reserved. 3 3 * 4 4 * Redistribution and use in source and binary forms, with or without … … 26 26 #pragma once 27 27 28 #include "ExceptionOr.h" 28 29 #include "JSDOMBinding.h" 29 30 #include "JSDOMConvert.h" … … 40 41 static Ref<ReadableStream> create(JSDOMGlobalObject& globalObject, JSReadableStream& readableStream) { return adoptRef(*new ReadableStream(globalObject, readableStream)); } 41 42 42 static Ref<ReadableStream> create(JSC::JSGlobalObject&, RefPtr<ReadableStreamSource>&&);43 static ExceptionOr<Ref<ReadableStream>> create(JSC::JSGlobalObject&, RefPtr<ReadableStreamSource>&&); 43 44 44 45 WEBCORE_EXPORT static bool isDisturbed(JSC::JSGlobalObject&, JSC::JSValue);
Note: See TracChangeset
for help on using the changeset viewer.