Changeset 268228 in webkit
- Timestamp:
- Oct 8, 2020 4:28:32 PM (4 years ago)
- Location:
- trunk
- Files:
-
- 5 added
- 16 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r268214 r268228 1 2020-10-08 Alex Christensen <achristensen@webkit.org> 2 3 Implement Blob.stream 4 https://bugs.webkit.org/show_bug.cgi?id=217457 5 6 Reviewed by Youenn Fablet. 7 8 * fast/files/blob-stream-error-expected.txt: Added. 9 * fast/files/blob-stream-error.html: Added. 10 * fast/files/blob-stream-frame-expected.txt: Added. 11 * fast/files/blob-stream-frame.html: Added. 12 * fast/files/resources/blob-stream-iframe.html: Added. 13 1 14 2020-10-08 Alex Christensen <achristensen@webkit.org> 2 15 -
trunk/LayoutTests/imported/w3c/ChangeLog
r268178 r268228 1 2020-10-08 Alex Christensen <achristensen@webkit.org> 2 3 Implement Blob.stream 4 https://bugs.webkit.org/show_bug.cgi?id=217457 5 6 Reviewed by Youenn Fablet. 7 8 * web-platform-tests/FileAPI/blob/Blob-stream.any-expected.txt: 9 * web-platform-tests/FileAPI/blob/Blob-stream.any.worker-expected.txt: 10 * web-platform-tests/FileAPI/idlharness-expected.txt: 11 * web-platform-tests/FileAPI/idlharness.worker-expected.txt: 12 1 13 2020-10-08 Rob Buis <rbuis@igalia.com> 2 14 -
trunk/LayoutTests/imported/w3c/web-platform-tests/FileAPI/blob/Blob-stream.any-expected.txt
r263059 r268228 1 1 2 FAIL Blob.stream() promise_test: Unhandled rejection with value: object "TypeError: blob.stream is not a function. (In 'blob.stream()', 'blob.stream' is undefined)" 3 FAIL Blob.stream() empty Blob promise_test: Unhandled rejection with value: object "TypeError: blob.stream is not a function. (In 'blob.stream()', 'blob.stream' is undefined)" 4 FAIL Blob.stream() non-unicode input promise_test: Unhandled rejection with value: object "TypeError: blob.stream is not a function. (In 'blob.stream()', 'blob.stream' is undefined)" 5 FAIL Blob.stream() garbage collection of blob shouldn't break streamconsumption promise_test: Unhandled rejection with value: object "TypeError: blob.stream is not a function. (In 'blob.stream()', 'blob.stream' is undefined)" 2 PASS Blob.stream() 3 PASS Blob.stream() empty Blob 4 PASS Blob.stream() non-unicode input 5 PASS Blob.stream() garbage collection of blob shouldn't break streamconsumption 6 6 -
trunk/LayoutTests/imported/w3c/web-platform-tests/FileAPI/blob/Blob-stream.any.worker-expected.txt
r263059 r268228 1 1 2 FAIL Blob.stream() promise_test: Unhandled rejection with value: object "TypeError: blob.stream is not a function. (In 'blob.stream()', 'blob.stream' is undefined)" 3 FAIL Blob.stream() empty Blob promise_test: Unhandled rejection with value: object "TypeError: blob.stream is not a function. (In 'blob.stream()', 'blob.stream' is undefined)" 4 FAIL Blob.stream() non-unicode input promise_test: Unhandled rejection with value: object "TypeError: blob.stream is not a function. (In 'blob.stream()', 'blob.stream' is undefined)" 5 FAIL Blob.stream() garbage collection of blob shouldn't break streamconsumption promise_test: Unhandled rejection with value: object "TypeError: blob.stream is not a function. (In 'blob.stream()', 'blob.stream' is undefined)" 2 PASS Blob.stream() 3 PASS Blob.stream() empty Blob 4 PASS Blob.stream() non-unicode input 5 PASS Blob.stream() garbage collection of blob shouldn't break streamconsumption 6 6 -
trunk/LayoutTests/imported/w3c/web-platform-tests/FileAPI/idlharness-expected.txt
r267651 r268228 16 16 PASS Blob interface: attribute type 17 17 PASS Blob interface: operation slice(optional long long, optional long long, optional DOMString) 18 FAIL Blob interface: operation stream() assert_own_property: interface prototype object missing non-static operation expected property "stream" missing 18 PASS Blob interface: operation stream() 19 19 PASS Blob interface: operation text() 20 20 PASS Blob interface: operation arrayBuffer() … … 25 25 PASS Blob interface: new Blob(["TEST"]) must inherit property "slice(optional long long, optional long long, optional DOMString)" with the proper type 26 26 PASS Blob interface: calling slice(optional long long, optional long long, optional DOMString) on new Blob(["TEST"]) with too few arguments must throw TypeError 27 FAIL Blob interface: new Blob(["TEST"]) must inherit property "stream()" with the proper type assert_inherits: property "stream" not found in prototype chain 27 PASS Blob interface: new Blob(["TEST"]) must inherit property "stream()" with the proper type 28 28 PASS Blob interface: new Blob(["TEST"]) must inherit property "text()" with the proper type 29 29 PASS Blob interface: new Blob(["TEST"]) must inherit property "arrayBuffer()" with the proper type … … 44 44 PASS Blob interface: new File(["myFileBits"], "myFileName") must inherit property "slice(optional long long, optional long long, optional DOMString)" with the proper type 45 45 PASS Blob interface: calling slice(optional long long, optional long long, optional DOMString) on new File(["myFileBits"], "myFileName") with too few arguments must throw TypeError 46 FAIL Blob interface: new File(["myFileBits"], "myFileName") must inherit property "stream()" with the proper type assert_inherits: property "stream" not found in prototype chain 46 PASS Blob interface: new File(["myFileBits"], "myFileName") must inherit property "stream()" with the proper type 47 47 PASS Blob interface: new File(["myFileBits"], "myFileName") must inherit property "text()" with the proper type 48 48 PASS Blob interface: new File(["myFileBits"], "myFileName") must inherit property "arrayBuffer()" with the proper type -
trunk/LayoutTests/imported/w3c/web-platform-tests/FileAPI/idlharness.worker-expected.txt
r267651 r268228 14 14 PASS Blob interface: attribute type 15 15 PASS Blob interface: operation slice(optional long long, optional long long, optional DOMString) 16 FAIL Blob interface: operation stream() assert_own_property: interface prototype object missing non-static operation expected property "stream" missing 16 PASS Blob interface: operation stream() 17 17 PASS Blob interface: operation text() 18 18 PASS Blob interface: operation arrayBuffer() … … 23 23 PASS Blob interface: new Blob(["TEST"]) must inherit property "slice(optional long long, optional long long, optional DOMString)" with the proper type 24 24 PASS Blob interface: calling slice(optional long long, optional long long, optional DOMString) on new Blob(["TEST"]) with too few arguments must throw TypeError 25 FAIL Blob interface: new Blob(["TEST"]) must inherit property "stream()" with the proper type assert_inherits: property "stream" not found in prototype chain 25 PASS Blob interface: new Blob(["TEST"]) must inherit property "stream()" with the proper type 26 26 PASS Blob interface: new Blob(["TEST"]) must inherit property "text()" with the proper type 27 27 PASS Blob interface: new Blob(["TEST"]) must inherit property "arrayBuffer()" with the proper type … … 42 42 PASS Blob interface: new File(["myFileBits"], "myFileName") must inherit property "slice(optional long long, optional long long, optional DOMString)" with the proper type 43 43 PASS Blob interface: calling slice(optional long long, optional long long, optional DOMString) on new File(["myFileBits"], "myFileName") with too few arguments must throw TypeError 44 FAIL Blob interface: new File(["myFileBits"], "myFileName") must inherit property "stream()" with the proper type assert_inherits: property "stream" not found in prototype chain 44 PASS Blob interface: new File(["myFileBits"], "myFileName") must inherit property "stream()" with the proper type 45 45 PASS Blob interface: new File(["myFileBits"], "myFileName") must inherit property "text()" with the proper type 46 46 PASS Blob interface: new File(["myFileBits"], "myFileName") must inherit property "arrayBuffer()" with the proper type -
trunk/Source/WebCore/ChangeLog
r268208 r268228 1 2020-10-08 Alex Christensen <achristensen@webkit.org> 2 3 Implement Blob.stream 4 https://bugs.webkit.org/show_bug.cgi?id=217457 5 6 Reviewed by Youenn Fablet. 7 8 It's implemented in Chrome and Firefox. 9 10 * Modules/async-clipboard/ClipboardItemBindingsDataSource.h: 11 * bindings/js/ReadableStream.h: 12 (WebCore::toJSNewlyCreated): 13 * bindings/scripts/CodeGeneratorJS.pm: 14 (AddToIncludesForIDLType): 15 * fileapi/Blob.cpp: 16 (WebCore::Blob::stream): 17 * fileapi/Blob.h: 18 * fileapi/Blob.idl: 19 * fileapi/FileReaderLoader.cpp: 20 (WebCore::FileReaderLoader::FileReaderLoader): 21 (WebCore::FileReaderLoader::takeRawData): 22 * fileapi/FileReaderLoader.h: 23 * fileapi/FileReaderLoaderClient.h: 24 1 25 2020-10-08 Fujii Hironori <Hironori.Fujii@sony.com> 2 26 -
trunk/Source/WebCore/Modules/async-clipboard/ClipboardItemBindingsDataSource.h
r262999 r268228 56 56 57 57 using BufferOrString = Variant<String, Ref<SharedBuffer>>; 58 class ClipboardItemTypeLoader : public FileReaderLoaderClient, public RefCounted<ClipboardItemTypeLoader> , public CanMakeWeakPtr<ClipboardItemTypeLoader>{58 class ClipboardItemTypeLoader : public FileReaderLoaderClient, public RefCounted<ClipboardItemTypeLoader> { 59 59 public: 60 60 static Ref<ClipboardItemTypeLoader> create(const String& type, CompletionHandler<void()>&& completionHandler) -
trunk/Source/WebCore/bindings/js/ReadableStream.h
r263883 r268228 85 85 } 86 86 87 inline JSC::JSValue toJSNewlyCreated(JSC::JSGlobalObject*, JSDOMGlobalObject*, Ref<ReadableStream>&& stream) 88 { 89 return stream->readableStream(); 87 90 } 91 92 } -
trunk/Source/WebCore/bindings/scripts/CodeGeneratorJS.pm
r268114 r268228 631 631 AddToIncludes("JSEventListener.h", $includesRef, $conditional); 632 632 AddToIncludes("JSDOMConvertEventListener.h", $includesRef, $conditional); 633 return; 634 } 635 636 if ($type->name eq "ReadableStream") { 637 AddToIncludes("ReadableStream.h", $includesRef, $conditional); 633 638 return; 634 639 } -
trunk/Source/WebCore/fileapi/Blob.cpp
r266168 r268228 38 38 #include "File.h" 39 39 #include "JSDOMPromiseDeferred.h" 40 #include "ReadableStream.h" 41 #include "ReadableStreamSource.h" 40 42 #include "ScriptExecutionContext.h" 41 43 #include "SharedBuffer.h" … … 237 239 } 238 240 241 ExceptionOr<Ref<ReadableStream>> Blob::stream(ScriptExecutionContext& scriptExecutionContext) 242 { 243 class BlobStreamSource : public FileReaderLoaderClient, public ReadableStreamSource { 244 public: 245 BlobStreamSource(ScriptExecutionContext& scriptExecutionContext, Blob& blob) 246 : m_loader(makeUniqueRef<FileReaderLoader>(FileReaderLoader::ReadType::ReadAsArrayBuffer, this)) 247 { 248 m_loader->start(&scriptExecutionContext, blob); 249 } 250 251 private: 252 // ReadableStreamSource 253 void setActive() final { } 254 void setInactive() final { } 255 void doStart() final { } 256 void doPull() final { } 257 void doCancel() final 258 { 259 m_loader->cancel(); 260 } 261 262 // FileReaderLoaderClient 263 void didStartLoading() final { } 264 void didReceiveData() final 265 { 266 controller().enqueue(m_loader->takeRawData()); 267 } 268 void didFinishLoading() final 269 { 270 controller().close(); 271 } 272 void didFail(ExceptionCode exception) final 273 { 274 controller().error(Exception { exception }); 275 } 276 277 UniqueRef<FileReaderLoader> m_loader; 278 }; 279 280 return ReadableStream::create(*scriptExecutionContext.execState(), adoptRef(*new BlobStreamSource(scriptExecutionContext, *this))); 281 } 282 239 283 #if ASSERT_ENABLED 240 284 bool Blob::isNormalizedContentType(const String& contentType) -
trunk/Source/WebCore/fileapi/Blob.h
r266168 r268228 51 51 class BlobLoader; 52 52 class DeferredPromise; 53 class ReadableStream; 53 54 class ScriptExecutionContext; 54 55 class SharedBuffer; 56 57 template<typename> class ExceptionOr; 55 58 56 59 using BlobPartVariant = Variant<RefPtr<JSC::ArrayBufferView>, RefPtr<JSC::ArrayBuffer>, RefPtr<Blob>, String>; … … 124 127 void text(ScriptExecutionContext&, Ref<DeferredPromise>&&); 125 128 void arrayBuffer(ScriptExecutionContext&, Ref<DeferredPromise>&&); 129 ExceptionOr<Ref<ReadableStream>> stream(ScriptExecutionContext&); 126 130 127 131 protected: -
trunk/Source/WebCore/fileapi/Blob.idl
r266168 r268228 44 44 [CallWith=ScriptExecutionContext] Blob slice(optional long long start = 0, optional long long end = 0x7FFFFFFFFFFFFFFF, optional DOMString contentType = ""); 45 45 46 // [NewObject] ReadableStream stream();46 [NewObject, CallWith=ScriptExecutionContext, MayThrowException] ReadableStream stream(); 47 47 [NewObject, CallWith=ScriptExecutionContext] Promise<USVString> text(); 48 48 [NewObject, CallWith=ScriptExecutionContext] Promise<ArrayBuffer> arrayBuffer(); -
trunk/Source/WebCore/fileapi/FileReaderLoader.cpp
r262999 r268228 57 57 FileReaderLoader::FileReaderLoader(ReadType readType, FileReaderLoaderClient* client) 58 58 : m_readType(readType) 59 , m_client( client)59 , m_client(makeWeakPtr(client)) 60 60 , m_isRawDataConverted(false) 61 61 , m_stringResult(emptyString()) … … 280 280 } 281 281 282 RefPtr<JSC::ArrayBuffer> FileReaderLoader::takeRawData() 283 { 284 return std::exchange(m_rawData, nullptr); 285 } 286 282 287 String FileReaderLoader::stringResult() 283 288 { -
trunk/Source/WebCore/fileapi/FileReaderLoader.h
r262999 r268228 38 38 #include <wtf/Forward.h> 39 39 #include <wtf/Optional.h> 40 #include <wtf/WeakPtr.h> 40 41 #include <wtf/text/WTFString.h> 41 42 … … 79 80 unsigned bytesLoaded() const { return m_bytesLoaded; } 80 81 unsigned totalBytes() const { return m_totalBytes; } 82 RefPtr<JSC::ArrayBuffer> takeRawData(); 81 83 Optional<ExceptionCode> errorCode() const { return m_errorCode; } 82 84 … … 99 101 100 102 ReadType m_readType; 101 FileReaderLoaderClient*m_client;103 WeakPtr<FileReaderLoaderClient> m_client; 102 104 TextEncoding m_encoding; 103 105 String m_dataType; -
trunk/Source/WebCore/fileapi/FileReaderLoaderClient.h
r262999 r268228 32 32 33 33 #include "ExceptionCode.h" 34 #include <wtf/WeakPtr.h> 34 35 35 36 namespace WebCore { 36 37 37 class FileReaderLoaderClient {38 class FileReaderLoaderClient : public CanMakeWeakPtr<FileReaderLoaderClient> { 38 39 public: 39 40 virtual ~FileReaderLoaderClient() = default;
Note: See TracChangeset
for help on using the changeset viewer.