Changeset 272221 in webkit


Ignore:
Timestamp:
Feb 2, 2021 10:30:42 AM (18 months ago)
Author:
ysuzuki@apple.com
Message:

WebAssembly: add support for stream APIs - JavaScript API: Implement loading for the Blob type
https://bugs.webkit.org/show_bug.cgi?id=184886

Reviewed by Youenn Fablet.

LayoutTests/imported/w3c:

  • web-platform-tests/wasm/wasm_stream_compile_test-expected.txt:
  • web-platform-tests/wasm/wasm_stream_compile_test.html:
  • web-platform-tests/wasm/wasm_stream_instantiate_test-expected.txt:
  • web-platform-tests/wasm/wasm_stream_instantiate_test.html:

Source/WebCore:

This patch adds compileStreaming / instantiateStreaming with FetchResponse created from Blob.
We materialize ReadableStream to load Blob for now. In the future, if more efficient way is
implemented, we will switch to that.
More complex FormData is not supported, tracked in https://bugs.webkit.org/show_bug.cgi?id=221248.

  • bindings/js/JSDOMGlobalObject.cpp:

(WebCore::handleResponseOnStreamingAction):

Location:
trunk
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/imported/w3c/ChangeLog

    r272193 r272221  
     12021-02-02  Yusuke Suzuki  <ysuzuki@apple.com>
     2
     3        WebAssembly: add support for stream APIs - JavaScript API: Implement loading for the Blob type
     4        https://bugs.webkit.org/show_bug.cgi?id=184886
     5
     6        Reviewed by Youenn Fablet.
     7
     8        * web-platform-tests/wasm/wasm_stream_compile_test-expected.txt:
     9        * web-platform-tests/wasm/wasm_stream_compile_test.html:
     10        * web-platform-tests/wasm/wasm_stream_instantiate_test-expected.txt:
     11        * web-platform-tests/wasm/wasm_stream_instantiate_test.html:
     12
    1132021-02-02  Rob Buis  <rbuis@igalia.com>
    214
  • trunk/LayoutTests/imported/w3c/web-platform-tests/wasm/wasm_stream_compile_test-expected.txt

    r271993 r272221  
    1010PASS compileStreaming receive promise with response created from ArrayBuffer
    1111PASS compileStreaming receive response that deliver data by chunks as bufferArray
     12PASS compileStreaming using blob
     13FAIL compileStreaming using FormData promise_rejects_js: function "function () { throw e }" threw object "TypeError: FormData is not supported" ("TypeError") expected instance of function "function CompileError() {
     14    [native code]
     15}" ("CompileError")
    1216
  • trunk/LayoutTests/imported/w3c/web-platform-tests/wasm/wasm_stream_compile_test.html

    r271993 r272221  
    106106    assert_true(module instanceof WebAssembly.Module);
    107107  }, "compileStreaming receive response that deliver data by chunks as bufferArray");
     108
     109  promise_test(async function() {
     110      var response = await fetch('resources/incrementer.wasm');
     111      var blob = await response.blob();
     112      const module = await WebAssembly.compileStreaming(new Response(blob, { headers: { "Content-Type" : "application/wasm" }}));
     113      assert_true(module instanceof WebAssembly.Module);
     114  }, "compileStreaming using blob");
     115
     116  promise_test(async function(t) {
     117      var response = await fetch('resources/incrementer.wasm');
     118      var blob = await response.blob();
     119      var formData = new FormData;
     120      formData.append('blob', blob);
     121      formData.append('blob2', "Hello");
     122      await promise_rejects_js(t, WebAssembly.CompileError, WebAssembly.compileStreaming(new Response(formData, { headers: { "Content-Type" : "application/wasm" }})));
     123  }, "compileStreaming using FormData");
    108124</script>
    109125
  • trunk/LayoutTests/imported/w3c/web-platform-tests/wasm/wasm_stream_instantiate_test-expected.txt

    r271993 r272221  
    1010PASS instantiateStreaming receive promise with response created from ArrayBuffer
    1111PASS instantiateStreaming receive response that deliver data by chunks as bufferArray
     12PASS instantiateStreaming using blob
     13FAIL instantiateStreaming using FormData promise_rejects_js: function "function () { throw e }" threw object "TypeError: FormData is not supported" ("TypeError") expected instance of function "function CompileError() {
     14    [native code]
     15}" ("CompileError")
    1216
  • trunk/LayoutTests/imported/w3c/web-platform-tests/wasm/wasm_stream_instantiate_test.html

    r271993 r272221  
    104104    assert_true(instance instanceof WebAssembly.Instance);
    105105  }, "instantiateStreaming receive response that deliver data by chunks as bufferArray");
     106
     107  promise_test(async function() {
     108      var response = await fetch('resources/incrementer.wasm');
     109      var blob = await response.blob();
     110      const { instance, module } = await WebAssembly.instantiateStreaming(new Response(blob, { headers: { "Content-Type" : "application/wasm" }}));
     111      assert_true(instance instanceof WebAssembly.Instance);
     112      assert_true(module instanceof WebAssembly.Module);
     113  }, "instantiateStreaming using blob");
     114
     115  promise_test(async function(t) {
     116      var response = await fetch('resources/incrementer.wasm');
     117      var blob = await response.blob();
     118      var formData = new FormData;
     119      formData.append('blob', blob);
     120      formData.append('blob2', "Hello");
     121      await promise_rejects_js(t, WebAssembly.CompileError, WebAssembly.instantiateStreaming(new Response(formData, { headers: { "Content-Type" : "application/wasm" }})));
     122  }, "instantiateStreaming using FormData");
    106123</script>
  • trunk/Source/WebCore/ChangeLog

    r272218 r272221  
     12021-02-02  Yusuke Suzuki  <ysuzuki@apple.com>
     2
     3        WebAssembly: add support for stream APIs - JavaScript API: Implement loading for the Blob type
     4        https://bugs.webkit.org/show_bug.cgi?id=184886
     5
     6        Reviewed by Youenn Fablet.
     7
     8        This patch adds compileStreaming / instantiateStreaming with FetchResponse created from Blob.
     9        We materialize ReadableStream to load Blob for now. In the future, if more efficient way is
     10        implemented, we will switch to that.
     11        More complex FormData is not supported, tracked in https://bugs.webkit.org/show_bug.cgi?id=221248.
     12
     13        * bindings/js/JSDOMGlobalObject.cpp:
     14        (WebCore::handleResponseOnStreamingAction):
     15
    1162021-02-02  Chris Dumez  <cdumez@apple.com>
    217
  • trunk/Source/WebCore/bindings/js/JSDOMGlobalObject.cpp

    r271993 r272221  
    340340    }
    341341
     342    // FIXME: for efficiency, we should load blobs directly instead of going through the readableStream path.
     343    if (inputResponse->isBlobBody()) {
     344        auto streamOrException = inputResponse->readableStream(*globalObject);
     345        if (UNLIKELY(streamOrException.hasException())) {
     346            deferred->reject(streamOrException.releaseException());
     347            return jsCast<JSC::JSPromise*>(deferred->promise());
     348        }
     349    }
     350
    342351    auto compiler = JSC::Wasm::StreamingCompiler::create(vm, compilerMode, globalObject, jsCast<JSC::JSPromise*>(deferred->promise()), importObject);
    343352
     
    388397            return;
    389398        }
    390         // FIXME: http://webkit.org/b/184886> Implement loading for the Blob type
    391         compiler->fail(globalObject, createTypeError(globalObject, "Blob is not supported"_s));
     399        // FIXME: Support FormData loading.
     400        // https://bugs.webkit.org/show_bug.cgi?id=221248
     401        compiler->fail(globalObject, createDOMException(*globalObject, Exception { NotSupportedError, "Not implemented"_s  }));
    392402    }, [&](Ref<SharedBuffer>& buffer) {
    393403        compiler->addBytes(reinterpret_cast<const uint8_t*>(buffer->data()), buffer->size());
Note: See TracChangeset for help on using the changeset viewer.