diff options
author | Tobias Nießen <tniessen@tnie.de> | 2022-04-26 00:46:42 +0300 |
---|---|---|
committer | Michaël Zasso <targos@protonmail.com> | 2022-04-28 07:57:24 +0300 |
commit | ad8269450a1f9b04b5a502789a6097f4346aae03 (patch) | |
tree | adbeb1629acd43dc3e0c68d9217d1c3faf85976d /src/node_wasm_web_api.cc | |
parent | 7b701442de42329ea2b244a18226d51bb14529b2 (diff) |
lib,src: use Response URL as WebAssembly location
As per Section 3 of the WebAssembly Web API spec.
PR-URL: https://github.com/nodejs/node/pull/42842
Refs: https://github.com/nodejs/node/pull/42701
Reviewed-By: Gus Caplan <me@gus.host>
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
Diffstat (limited to 'src/node_wasm_web_api.cc')
-rw-r--r-- | src/node_wasm_web_api.cc | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/src/node_wasm_web_api.cc b/src/node_wasm_web_api.cc index b23096120b1..fcb845d08b0 100644 --- a/src/node_wasm_web_api.cc +++ b/src/node_wasm_web_api.cc @@ -29,6 +29,7 @@ Local<Function> WasmStreamingObject::Initialize(Environment* env) { t->InstanceTemplate()->SetInternalFieldCount( WasmStreamingObject::kInternalFieldCount); + env->SetProtoMethod(t, "setURL", SetURL); env->SetProtoMethod(t, "push", Push); env->SetProtoMethod(t, "finish", Finish); env->SetProtoMethod(t, "abort", Abort); @@ -75,6 +76,17 @@ void WasmStreamingObject::New(const FunctionCallbackInfo<Value>& args) { new WasmStreamingObject(env, args.This()); } +void WasmStreamingObject::SetURL(const FunctionCallbackInfo<Value>& args) { + WasmStreamingObject* obj; + ASSIGN_OR_RETURN_UNWRAP(&obj, args.Holder()); + CHECK(obj->streaming_); + + CHECK_EQ(args.Length(), 1); + CHECK(args[0]->IsString()); + Utf8Value url(Environment::GetCurrent(args)->isolate(), args[0]); + obj->streaming_->SetUrl(url.out(), url.length()); +} + void WasmStreamingObject::Push(const FunctionCallbackInfo<Value>& args) { WasmStreamingObject* obj; ASSIGN_OR_RETURN_UNWRAP(&obj, args.Holder()); |