1 | /* |
2 | This file is part of the WebKit open source project. |
3 | This file has been generated by generate-bindings.pl. DO NOT MODIFY! |
4 | |
5 | This library is free software; you can redistribute it and/or |
6 | modify it under the terms of the GNU Library General Public |
7 | License as published by the Free Software Foundation; either |
8 | version 2 of the License, or (at your option) any later version. |
9 | |
10 | This library is distributed in the hope that it will be useful, |
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
13 | Library General Public License for more details. |
14 | |
15 | You should have received a copy of the GNU Library General Public License |
16 | along with this library; see the file COPYING.LIB. If not, write to |
17 | the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
18 | Boston, MA 02110-1301, USA. |
19 | */ |
20 | |
21 | #include "config.h" |
22 | #include "JSFetchResponse.h" |
23 | |
24 | #include "JSBlob.h" |
25 | #include "JSDOMAttribute.h" |
26 | #include "JSDOMBinding.h" |
27 | #include "JSDOMConstructor.h" |
28 | #include "JSDOMConvertBoolean.h" |
29 | #include "JSDOMConvertBufferSource.h" |
30 | #include "JSDOMConvertInterface.h" |
31 | #include "JSDOMConvertNullable.h" |
32 | #include "JSDOMConvertNumbers.h" |
33 | #include "JSDOMConvertRecord.h" |
34 | #include "JSDOMConvertSequences.h" |
35 | #include "JSDOMConvertStrings.h" |
36 | #include "JSDOMConvertUnion.h" |
37 | #include "JSDOMExceptionHandling.h" |
38 | #include "JSDOMFormData.h" |
39 | #include "JSDOMGlobalObject.h" |
40 | #include "JSDOMOperation.h" |
41 | #include "JSDOMOperationReturningPromise.h" |
42 | #include "JSDOMWrapperCache.h" |
43 | #include "JSFetchHeaders.h" |
44 | #include "JSFetchResponse.h" |
45 | #include "JSReadableStream.h" |
46 | #include "JSURLSearchParams.h" |
47 | #include "RuntimeEnabledFeatures.h" |
48 | #include "ScriptExecutionContext.h" |
49 | #include <JavaScriptCore/FunctionPrototype.h> |
50 | #include <JavaScriptCore/HeapSnapshotBuilder.h> |
51 | #include <JavaScriptCore/JSArray.h> |
52 | #include <JavaScriptCore/JSCInlines.h> |
53 | #include <JavaScriptCore/JSString.h> |
54 | #include <wtf/GetPtr.h> |
55 | #include <wtf/PointerPreparations.h> |
56 | #include <wtf/URL.h> |
57 | #include <wtf/Variant.h> |
58 | #include <wtf/Vector.h> |
59 | |
60 | |
61 | namespace WebCore { |
62 | using namespace JSC; |
63 | |
64 | String convertEnumerationToString(FetchResponse::Type enumerationValue) |
65 | { |
66 | static const NeverDestroyed<String> values[] = { |
67 | MAKE_STATIC_STRING_IMPL("basic" ), |
68 | MAKE_STATIC_STRING_IMPL("cors" ), |
69 | MAKE_STATIC_STRING_IMPL("default" ), |
70 | MAKE_STATIC_STRING_IMPL("error" ), |
71 | MAKE_STATIC_STRING_IMPL("opaque" ), |
72 | MAKE_STATIC_STRING_IMPL("opaqueredirect" ), |
73 | }; |
74 | static_assert(static_cast<size_t>(FetchResponse::Type::Basic) == 0, "FetchResponse::Type::Basic is not 0 as expected" ); |
75 | static_assert(static_cast<size_t>(FetchResponse::Type::Cors) == 1, "FetchResponse::Type::Cors is not 1 as expected" ); |
76 | static_assert(static_cast<size_t>(FetchResponse::Type::Default) == 2, "FetchResponse::Type::Default is not 2 as expected" ); |
77 | static_assert(static_cast<size_t>(FetchResponse::Type::Error) == 3, "FetchResponse::Type::Error is not 3 as expected" ); |
78 | static_assert(static_cast<size_t>(FetchResponse::Type::Opaque) == 4, "FetchResponse::Type::Opaque is not 4 as expected" ); |
79 | static_assert(static_cast<size_t>(FetchResponse::Type::Opaqueredirect) == 5, "FetchResponse::Type::Opaqueredirect is not 5 as expected" ); |
80 | ASSERT(static_cast<size_t>(enumerationValue) < WTF_ARRAY_LENGTH(values)); |
81 | return values[static_cast<size_t>(enumerationValue)]; |
82 | } |
83 | |
84 | template<> JSString* convertEnumerationToJS(ExecState& state, FetchResponse::Type enumerationValue) |
85 | { |
86 | return jsStringWithCache(&state, convertEnumerationToString(enumerationValue)); |
87 | } |
88 | |
89 | template<> Optional<FetchResponse::Type> parseEnumeration<FetchResponse::Type>(ExecState& state, JSValue value) |
90 | { |
91 | auto stringValue = value.toWTFString(&state); |
92 | if (stringValue == "basic" ) |
93 | return FetchResponse::Type::Basic; |
94 | if (stringValue == "cors" ) |
95 | return FetchResponse::Type::Cors; |
96 | if (stringValue == "default" ) |
97 | return FetchResponse::Type::Default; |
98 | if (stringValue == "error" ) |
99 | return FetchResponse::Type::Error; |
100 | if (stringValue == "opaque" ) |
101 | return FetchResponse::Type::Opaque; |
102 | if (stringValue == "opaqueredirect" ) |
103 | return FetchResponse::Type::Opaqueredirect; |
104 | return WTF::nullopt; |
105 | } |
106 | |
107 | template<> const char* expectedEnumerationValues<FetchResponse::Type>() |
108 | { |
109 | return "\"basic\", \"cors\", \"default\", \"error\", \"opaque\", \"opaqueredirect\"" ; |
110 | } |
111 | |
112 | template<> FetchResponse::Init convertDictionary<FetchResponse::Init>(ExecState& state, JSValue value) |
113 | { |
114 | VM& vm = state.vm(); |
115 | auto throwScope = DECLARE_THROW_SCOPE(vm); |
116 | bool isNullOrUndefined = value.isUndefinedOrNull(); |
117 | auto* object = isNullOrUndefined ? nullptr : value.getObject(); |
118 | if (UNLIKELY(!isNullOrUndefined && !object)) { |
119 | throwTypeError(&state, throwScope); |
120 | return { }; |
121 | } |
122 | FetchResponse::Init result; |
123 | JSValue ; |
124 | if (isNullOrUndefined) |
125 | headersValue = jsUndefined(); |
126 | else { |
127 | headersValue = object->get(&state, Identifier::fromString(&state, "headers" )); |
128 | RETURN_IF_EXCEPTION(throwScope, { }); |
129 | } |
130 | if (!headersValue.isUndefined()) { |
131 | result.headers = convert<IDLUnion<IDLSequence<IDLSequence<IDLByteString>>, IDLRecord<IDLByteString, IDLByteString>>>(state, headersValue); |
132 | RETURN_IF_EXCEPTION(throwScope, { }); |
133 | } |
134 | JSValue statusValue; |
135 | if (isNullOrUndefined) |
136 | statusValue = jsUndefined(); |
137 | else { |
138 | statusValue = object->get(&state, Identifier::fromString(&state, "status" )); |
139 | RETURN_IF_EXCEPTION(throwScope, { }); |
140 | } |
141 | if (!statusValue.isUndefined()) { |
142 | result.status = convert<IDLUnsignedShort>(state, statusValue); |
143 | RETURN_IF_EXCEPTION(throwScope, { }); |
144 | } else |
145 | result.status = 200; |
146 | JSValue statusTextValue; |
147 | if (isNullOrUndefined) |
148 | statusTextValue = jsUndefined(); |
149 | else { |
150 | statusTextValue = object->get(&state, Identifier::fromString(&state, "statusText" )); |
151 | RETURN_IF_EXCEPTION(throwScope, { }); |
152 | } |
153 | if (!statusTextValue.isUndefined()) { |
154 | result.statusText = convert<IDLByteString>(state, statusTextValue); |
155 | RETURN_IF_EXCEPTION(throwScope, { }); |
156 | } else |
157 | result.statusText = "OK"_s ; |
158 | return result; |
159 | } |
160 | |
161 | // Functions |
162 | |
163 | JSC::EncodedJSValue JSC_HOST_CALL jsFetchResponseConstructorFunctionError(JSC::ExecState*); |
164 | JSC::EncodedJSValue JSC_HOST_CALL jsFetchResponseConstructorFunctionRedirect(JSC::ExecState*); |
165 | JSC::EncodedJSValue JSC_HOST_CALL jsFetchResponsePrototypeFunctionClone(JSC::ExecState*); |
166 | JSC::EncodedJSValue JSC_HOST_CALL jsFetchResponsePrototypeFunctionArrayBuffer(JSC::ExecState*); |
167 | JSC::EncodedJSValue JSC_HOST_CALL jsFetchResponsePrototypeFunctionBlob(JSC::ExecState*); |
168 | JSC::EncodedJSValue JSC_HOST_CALL jsFetchResponsePrototypeFunctionFormData(JSC::ExecState*); |
169 | JSC::EncodedJSValue JSC_HOST_CALL jsFetchResponsePrototypeFunctionJson(JSC::ExecState*); |
170 | JSC::EncodedJSValue JSC_HOST_CALL jsFetchResponsePrototypeFunctionText(JSC::ExecState*); |
171 | |
172 | // Attributes |
173 | |
174 | JSC::EncodedJSValue jsFetchResponseConstructor(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
175 | bool setJSFetchResponseConstructor(JSC::ExecState*, JSC::EncodedJSValue, JSC::EncodedJSValue); |
176 | JSC::EncodedJSValue jsFetchResponseType(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
177 | JSC::EncodedJSValue jsFetchResponseUrl(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
178 | JSC::EncodedJSValue jsFetchResponseRedirected(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
179 | JSC::EncodedJSValue jsFetchResponseStatus(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
180 | JSC::EncodedJSValue jsFetchResponseOk(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
181 | JSC::EncodedJSValue jsFetchResponseStatusText(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
182 | JSC::EncodedJSValue jsFetchResponseHeaders(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
183 | JSC::EncodedJSValue jsFetchResponseBody(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
184 | JSC::EncodedJSValue jsFetchResponseBodyUsed(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
185 | |
186 | class JSFetchResponsePrototype : public JSC::JSNonFinalObject { |
187 | public: |
188 | using Base = JSC::JSNonFinalObject; |
189 | static JSFetchResponsePrototype* create(JSC::VM& vm, JSDOMGlobalObject* globalObject, JSC::Structure* structure) |
190 | { |
191 | JSFetchResponsePrototype* ptr = new (NotNull, JSC::allocateCell<JSFetchResponsePrototype>(vm.heap)) JSFetchResponsePrototype(vm, globalObject, structure); |
192 | ptr->finishCreation(vm); |
193 | return ptr; |
194 | } |
195 | |
196 | DECLARE_INFO; |
197 | static JSC::Structure* createStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype) |
198 | { |
199 | return JSC::Structure::create(vm, globalObject, prototype, JSC::TypeInfo(JSC::ObjectType, StructureFlags), info()); |
200 | } |
201 | |
202 | private: |
203 | JSFetchResponsePrototype(JSC::VM& vm, JSC::JSGlobalObject*, JSC::Structure* structure) |
204 | : JSC::JSNonFinalObject(vm, structure) |
205 | { |
206 | } |
207 | |
208 | void finishCreation(JSC::VM&); |
209 | }; |
210 | |
211 | using JSFetchResponseConstructor = JSDOMConstructor<JSFetchResponse>; |
212 | |
213 | /* Hash table for constructor */ |
214 | |
215 | static const HashTableValue JSFetchResponseConstructorTableValues[] = |
216 | { |
217 | { "error" , static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t)static_cast<RawNativeFunction>(jsFetchResponseConstructorFunctionError), (intptr_t) (0) } }, |
218 | { "redirect" , static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t)static_cast<RawNativeFunction>(jsFetchResponseConstructorFunctionRedirect), (intptr_t) (1) } }, |
219 | }; |
220 | |
221 | template<> EncodedJSValue JSC_HOST_CALL JSFetchResponseConstructor::construct(ExecState* state) |
222 | { |
223 | VM& vm = state->vm(); |
224 | auto throwScope = DECLARE_THROW_SCOPE(vm); |
225 | UNUSED_PARAM(throwScope); |
226 | auto* castedThis = jsCast<JSFetchResponseConstructor*>(state->jsCallee()); |
227 | ASSERT(castedThis); |
228 | auto* context = castedThis->scriptExecutionContext(); |
229 | if (UNLIKELY(!context)) |
230 | return throwConstructorScriptExecutionContextUnavailableError(*state, throwScope, "Response" ); |
231 | auto body = state->argument(0).isUndefined() ? WTF::nullopt : convert<IDLNullable<IDLUnion<IDLInterface<Blob>, IDLArrayBufferView, IDLArrayBuffer, IDLInterface<DOMFormData>, IDLInterface<URLSearchParams>, IDLInterface<ReadableStream>, IDLUSVString>>>(*state, state->uncheckedArgument(0)); |
232 | RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); |
233 | auto init = convert<IDLDictionary<FetchResponse::Init>>(*state, state->argument(1)); |
234 | RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); |
235 | auto object = FetchResponse::create(*context, WTFMove(body), WTFMove(init)); |
236 | return JSValue::encode(toJSNewlyCreated<IDLInterface<FetchResponse>>(*state, *castedThis->globalObject(), throwScope, WTFMove(object))); |
237 | } |
238 | |
239 | template<> JSValue JSFetchResponseConstructor::prototypeForStructure(JSC::VM& vm, const JSDOMGlobalObject& globalObject) |
240 | { |
241 | UNUSED_PARAM(vm); |
242 | return globalObject.functionPrototype(); |
243 | } |
244 | |
245 | template<> void JSFetchResponseConstructor::initializeProperties(VM& vm, JSDOMGlobalObject& globalObject) |
246 | { |
247 | putDirect(vm, vm.propertyNames->prototype, JSFetchResponse::prototype(vm, globalObject), JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum); |
248 | putDirect(vm, vm.propertyNames->name, jsNontrivialString(&vm, String("Response"_s )), JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum); |
249 | putDirect(vm, vm.propertyNames->length, jsNumber(0), JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum); |
250 | reifyStaticProperties(vm, JSFetchResponse::info(), JSFetchResponseConstructorTableValues, *this); |
251 | } |
252 | |
253 | template<> const ClassInfo JSFetchResponseConstructor::s_info = { "Response" , &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSFetchResponseConstructor) }; |
254 | |
255 | /* Hash table for prototype */ |
256 | |
257 | static const HashTableValue JSFetchResponsePrototypeTableValues[] = |
258 | { |
259 | { "constructor" , static_cast<unsigned>(JSC::PropertyAttribute::DontEnum), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsFetchResponseConstructor), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(setJSFetchResponseConstructor) } }, |
260 | { "type" , static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsFetchResponseType), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } }, |
261 | { "url" , static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsFetchResponseUrl), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } }, |
262 | { "redirected" , static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsFetchResponseRedirected), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } }, |
263 | { "status" , static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsFetchResponseStatus), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } }, |
264 | { "ok" , static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsFetchResponseOk), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } }, |
265 | { "statusText" , static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsFetchResponseStatusText), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } }, |
266 | { "headers" , static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsFetchResponseHeaders), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } }, |
267 | { "body" , static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsFetchResponseBody), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } }, |
268 | { "bodyUsed" , static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsFetchResponseBodyUsed), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } }, |
269 | { "clone" , static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t)static_cast<RawNativeFunction>(jsFetchResponsePrototypeFunctionClone), (intptr_t) (0) } }, |
270 | { "arrayBuffer" , static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t)static_cast<RawNativeFunction>(jsFetchResponsePrototypeFunctionArrayBuffer), (intptr_t) (0) } }, |
271 | { "blob" , static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t)static_cast<RawNativeFunction>(jsFetchResponsePrototypeFunctionBlob), (intptr_t) (0) } }, |
272 | { "formData" , static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t)static_cast<RawNativeFunction>(jsFetchResponsePrototypeFunctionFormData), (intptr_t) (0) } }, |
273 | { "json" , static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t)static_cast<RawNativeFunction>(jsFetchResponsePrototypeFunctionJson), (intptr_t) (0) } }, |
274 | { "text" , static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t)static_cast<RawNativeFunction>(jsFetchResponsePrototypeFunctionText), (intptr_t) (0) } }, |
275 | }; |
276 | |
277 | const ClassInfo JSFetchResponsePrototype::s_info = { "ResponsePrototype" , &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSFetchResponsePrototype) }; |
278 | |
279 | void JSFetchResponsePrototype::finishCreation(VM& vm) |
280 | { |
281 | Base::finishCreation(vm); |
282 | reifyStaticProperties(vm, JSFetchResponse::info(), JSFetchResponsePrototypeTableValues, *this); |
283 | bool hasDisabledRuntimeProperties = false; |
284 | if (!RuntimeEnabledFeatures::sharedFeatures().fetchAPIEnabled()) { |
285 | hasDisabledRuntimeProperties = true; |
286 | auto propertyName = Identifier::fromString(&vm, reinterpret_cast<const LChar*>("arrayBuffer" ), strlen("arrayBuffer" )); |
287 | VM::DeletePropertyModeScope scope(vm, VM::DeletePropertyMode::IgnoreConfigurable); |
288 | JSObject::deleteProperty(this, globalObject()->globalExec(), propertyName); |
289 | } |
290 | if (!RuntimeEnabledFeatures::sharedFeatures().fetchAPIEnabled()) { |
291 | hasDisabledRuntimeProperties = true; |
292 | auto propertyName = Identifier::fromString(&vm, reinterpret_cast<const LChar*>("blob" ), strlen("blob" )); |
293 | VM::DeletePropertyModeScope scope(vm, VM::DeletePropertyMode::IgnoreConfigurable); |
294 | JSObject::deleteProperty(this, globalObject()->globalExec(), propertyName); |
295 | } |
296 | if (!RuntimeEnabledFeatures::sharedFeatures().fetchAPIEnabled()) { |
297 | hasDisabledRuntimeProperties = true; |
298 | auto propertyName = Identifier::fromString(&vm, reinterpret_cast<const LChar*>("formData" ), strlen("formData" )); |
299 | VM::DeletePropertyModeScope scope(vm, VM::DeletePropertyMode::IgnoreConfigurable); |
300 | JSObject::deleteProperty(this, globalObject()->globalExec(), propertyName); |
301 | } |
302 | if (!RuntimeEnabledFeatures::sharedFeatures().fetchAPIEnabled()) { |
303 | hasDisabledRuntimeProperties = true; |
304 | auto propertyName = Identifier::fromString(&vm, reinterpret_cast<const LChar*>("json" ), strlen("json" )); |
305 | VM::DeletePropertyModeScope scope(vm, VM::DeletePropertyMode::IgnoreConfigurable); |
306 | JSObject::deleteProperty(this, globalObject()->globalExec(), propertyName); |
307 | } |
308 | if (!RuntimeEnabledFeatures::sharedFeatures().fetchAPIEnabled()) { |
309 | hasDisabledRuntimeProperties = true; |
310 | auto propertyName = Identifier::fromString(&vm, reinterpret_cast<const LChar*>("text" ), strlen("text" )); |
311 | VM::DeletePropertyModeScope scope(vm, VM::DeletePropertyMode::IgnoreConfigurable); |
312 | JSObject::deleteProperty(this, globalObject()->globalExec(), propertyName); |
313 | } |
314 | if (!RuntimeEnabledFeatures::sharedFeatures().fetchAPIEnabled()) { |
315 | hasDisabledRuntimeProperties = true; |
316 | auto propertyName = Identifier::fromString(&vm, reinterpret_cast<const LChar*>("body" ), strlen("body" )); |
317 | VM::DeletePropertyModeScope scope(vm, VM::DeletePropertyMode::IgnoreConfigurable); |
318 | JSObject::deleteProperty(this, globalObject()->globalExec(), propertyName); |
319 | } |
320 | if (!RuntimeEnabledFeatures::sharedFeatures().fetchAPIEnabled()) { |
321 | hasDisabledRuntimeProperties = true; |
322 | auto propertyName = Identifier::fromString(&vm, reinterpret_cast<const LChar*>("bodyUsed" ), strlen("bodyUsed" )); |
323 | VM::DeletePropertyModeScope scope(vm, VM::DeletePropertyMode::IgnoreConfigurable); |
324 | JSObject::deleteProperty(this, globalObject()->globalExec(), propertyName); |
325 | } |
326 | if (hasDisabledRuntimeProperties && structure()->isDictionary()) |
327 | flattenDictionaryObject(vm); |
328 | } |
329 | |
330 | const ClassInfo JSFetchResponse::s_info = { "Response" , &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSFetchResponse) }; |
331 | |
332 | JSFetchResponse::JSFetchResponse(Structure* structure, JSDOMGlobalObject& globalObject, Ref<FetchResponse>&& impl) |
333 | : JSDOMWrapper<FetchResponse>(structure, globalObject, WTFMove(impl)) |
334 | { |
335 | } |
336 | |
337 | void JSFetchResponse::finishCreation(VM& vm) |
338 | { |
339 | Base::finishCreation(vm); |
340 | ASSERT(inherits(vm, info())); |
341 | |
342 | } |
343 | |
344 | JSObject* JSFetchResponse::createPrototype(VM& vm, JSDOMGlobalObject& globalObject) |
345 | { |
346 | return JSFetchResponsePrototype::create(vm, &globalObject, JSFetchResponsePrototype::createStructure(vm, &globalObject, globalObject.objectPrototype())); |
347 | } |
348 | |
349 | JSObject* JSFetchResponse::prototype(VM& vm, JSDOMGlobalObject& globalObject) |
350 | { |
351 | return getDOMPrototype<JSFetchResponse>(vm, globalObject); |
352 | } |
353 | |
354 | JSValue JSFetchResponse::getConstructor(VM& vm, const JSGlobalObject* globalObject) |
355 | { |
356 | return getDOMConstructor<JSFetchResponseConstructor>(vm, *jsCast<const JSDOMGlobalObject*>(globalObject)); |
357 | } |
358 | |
359 | void JSFetchResponse::destroy(JSC::JSCell* cell) |
360 | { |
361 | JSFetchResponse* thisObject = static_cast<JSFetchResponse*>(cell); |
362 | thisObject->JSFetchResponse::~JSFetchResponse(); |
363 | } |
364 | |
365 | template<> inline JSFetchResponse* IDLAttribute<JSFetchResponse>::cast(ExecState& state, EncodedJSValue thisValue) |
366 | { |
367 | return jsDynamicCast<JSFetchResponse*>(state.vm(), JSValue::decode(thisValue)); |
368 | } |
369 | |
370 | template<> inline JSFetchResponse* IDLOperation<JSFetchResponse>::cast(ExecState& state) |
371 | { |
372 | return jsDynamicCast<JSFetchResponse*>(state.vm(), state.thisValue()); |
373 | } |
374 | |
375 | EncodedJSValue jsFetchResponseConstructor(ExecState* state, EncodedJSValue thisValue, PropertyName) |
376 | { |
377 | VM& vm = state->vm(); |
378 | auto throwScope = DECLARE_THROW_SCOPE(vm); |
379 | auto* prototype = jsDynamicCast<JSFetchResponsePrototype*>(vm, JSValue::decode(thisValue)); |
380 | if (UNLIKELY(!prototype)) |
381 | return throwVMTypeError(state, throwScope); |
382 | return JSValue::encode(JSFetchResponse::getConstructor(state->vm(), prototype->globalObject())); |
383 | } |
384 | |
385 | bool setJSFetchResponseConstructor(ExecState* state, EncodedJSValue thisValue, EncodedJSValue encodedValue) |
386 | { |
387 | VM& vm = state->vm(); |
388 | auto throwScope = DECLARE_THROW_SCOPE(vm); |
389 | auto* prototype = jsDynamicCast<JSFetchResponsePrototype*>(vm, JSValue::decode(thisValue)); |
390 | if (UNLIKELY(!prototype)) { |
391 | throwVMTypeError(state, throwScope); |
392 | return false; |
393 | } |
394 | // Shadowing a built-in constructor |
395 | return prototype->putDirect(vm, vm.propertyNames->constructor, JSValue::decode(encodedValue)); |
396 | } |
397 | |
398 | static inline JSValue jsFetchResponseTypeGetter(ExecState& state, JSFetchResponse& thisObject, ThrowScope& throwScope) |
399 | { |
400 | UNUSED_PARAM(throwScope); |
401 | UNUSED_PARAM(state); |
402 | auto& impl = thisObject.wrapped(); |
403 | JSValue result = toJS<IDLEnumeration<FetchResponse::Type>>(state, throwScope, impl.type()); |
404 | return result; |
405 | } |
406 | |
407 | EncodedJSValue jsFetchResponseType(ExecState* state, EncodedJSValue thisValue, PropertyName) |
408 | { |
409 | return IDLAttribute<JSFetchResponse>::get<jsFetchResponseTypeGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "type" ); |
410 | } |
411 | |
412 | static inline JSValue jsFetchResponseUrlGetter(ExecState& state, JSFetchResponse& thisObject, ThrowScope& throwScope) |
413 | { |
414 | UNUSED_PARAM(throwScope); |
415 | UNUSED_PARAM(state); |
416 | auto& impl = thisObject.wrapped(); |
417 | JSValue result = toJS<IDLUSVString>(state, throwScope, impl.url()); |
418 | return result; |
419 | } |
420 | |
421 | EncodedJSValue jsFetchResponseUrl(ExecState* state, EncodedJSValue thisValue, PropertyName) |
422 | { |
423 | return IDLAttribute<JSFetchResponse>::get<jsFetchResponseUrlGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "url" ); |
424 | } |
425 | |
426 | static inline JSValue jsFetchResponseRedirectedGetter(ExecState& state, JSFetchResponse& thisObject, ThrowScope& throwScope) |
427 | { |
428 | UNUSED_PARAM(throwScope); |
429 | UNUSED_PARAM(state); |
430 | auto& impl = thisObject.wrapped(); |
431 | JSValue result = toJS<IDLBoolean>(state, throwScope, impl.redirected()); |
432 | return result; |
433 | } |
434 | |
435 | EncodedJSValue jsFetchResponseRedirected(ExecState* state, EncodedJSValue thisValue, PropertyName) |
436 | { |
437 | return IDLAttribute<JSFetchResponse>::get<jsFetchResponseRedirectedGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "redirected" ); |
438 | } |
439 | |
440 | static inline JSValue jsFetchResponseStatusGetter(ExecState& state, JSFetchResponse& thisObject, ThrowScope& throwScope) |
441 | { |
442 | UNUSED_PARAM(throwScope); |
443 | UNUSED_PARAM(state); |
444 | auto& impl = thisObject.wrapped(); |
445 | JSValue result = toJS<IDLUnsignedShort>(state, throwScope, impl.status()); |
446 | return result; |
447 | } |
448 | |
449 | EncodedJSValue jsFetchResponseStatus(ExecState* state, EncodedJSValue thisValue, PropertyName) |
450 | { |
451 | return IDLAttribute<JSFetchResponse>::get<jsFetchResponseStatusGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "status" ); |
452 | } |
453 | |
454 | static inline JSValue jsFetchResponseOkGetter(ExecState& state, JSFetchResponse& thisObject, ThrowScope& throwScope) |
455 | { |
456 | UNUSED_PARAM(throwScope); |
457 | UNUSED_PARAM(state); |
458 | auto& impl = thisObject.wrapped(); |
459 | JSValue result = toJS<IDLBoolean>(state, throwScope, impl.ok()); |
460 | return result; |
461 | } |
462 | |
463 | EncodedJSValue jsFetchResponseOk(ExecState* state, EncodedJSValue thisValue, PropertyName) |
464 | { |
465 | return IDLAttribute<JSFetchResponse>::get<jsFetchResponseOkGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "ok" ); |
466 | } |
467 | |
468 | static inline JSValue jsFetchResponseStatusTextGetter(ExecState& state, JSFetchResponse& thisObject, ThrowScope& throwScope) |
469 | { |
470 | UNUSED_PARAM(throwScope); |
471 | UNUSED_PARAM(state); |
472 | auto& impl = thisObject.wrapped(); |
473 | JSValue result = toJS<IDLByteString>(state, throwScope, impl.statusText()); |
474 | return result; |
475 | } |
476 | |
477 | EncodedJSValue jsFetchResponseStatusText(ExecState* state, EncodedJSValue thisValue, PropertyName) |
478 | { |
479 | return IDLAttribute<JSFetchResponse>::get<jsFetchResponseStatusTextGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "statusText" ); |
480 | } |
481 | |
482 | static inline JSValue (ExecState& state, JSFetchResponse& thisObject, ThrowScope& throwScope) |
483 | { |
484 | UNUSED_PARAM(throwScope); |
485 | UNUSED_PARAM(state); |
486 | auto& impl = thisObject.wrapped(); |
487 | JSValue result = toJS<IDLInterface<FetchHeaders>>(state, *thisObject.globalObject(), throwScope, impl.headers()); |
488 | return result; |
489 | } |
490 | |
491 | EncodedJSValue (ExecState* state, EncodedJSValue thisValue, PropertyName) |
492 | { |
493 | return IDLAttribute<JSFetchResponse>::get<jsFetchResponseHeadersGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "headers" ); |
494 | } |
495 | |
496 | static inline JSValue jsFetchResponseBodyGetter(ExecState& state, JSFetchResponse& thisObject, ThrowScope& throwScope) |
497 | { |
498 | UNUSED_PARAM(throwScope); |
499 | UNUSED_PARAM(state); |
500 | auto& impl = thisObject.wrapped(); |
501 | JSValue result = toJS<IDLNullable<IDLInterface<ReadableStream>>>(state, *thisObject.globalObject(), throwScope, impl.readableStream(state)); |
502 | return result; |
503 | } |
504 | |
505 | EncodedJSValue jsFetchResponseBody(ExecState* state, EncodedJSValue thisValue, PropertyName) |
506 | { |
507 | return IDLAttribute<JSFetchResponse>::get<jsFetchResponseBodyGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "body" ); |
508 | } |
509 | |
510 | static inline JSValue jsFetchResponseBodyUsedGetter(ExecState& state, JSFetchResponse& thisObject, ThrowScope& throwScope) |
511 | { |
512 | UNUSED_PARAM(throwScope); |
513 | UNUSED_PARAM(state); |
514 | auto& impl = thisObject.wrapped(); |
515 | JSValue result = toJS<IDLBoolean>(state, throwScope, impl.bodyUsed()); |
516 | return result; |
517 | } |
518 | |
519 | EncodedJSValue jsFetchResponseBodyUsed(ExecState* state, EncodedJSValue thisValue, PropertyName) |
520 | { |
521 | return IDLAttribute<JSFetchResponse>::get<jsFetchResponseBodyUsedGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "bodyUsed" ); |
522 | } |
523 | |
524 | static inline JSC::EncodedJSValue jsFetchResponseConstructorFunctionErrorBody(JSC::ExecState* state, JSC::ThrowScope& throwScope) |
525 | { |
526 | UNUSED_PARAM(state); |
527 | UNUSED_PARAM(throwScope); |
528 | auto* context = jsCast<JSDOMGlobalObject*>(state->lexicalGlobalObject())->scriptExecutionContext(); |
529 | if (UNLIKELY(!context)) |
530 | return JSValue::encode(jsUndefined()); |
531 | return JSValue::encode(toJSNewlyCreated<IDLInterface<FetchResponse>>(*state, *jsCast<JSDOMGlobalObject*>(state->lexicalGlobalObject()), FetchResponse::error(*context))); |
532 | } |
533 | |
534 | EncodedJSValue JSC_HOST_CALL jsFetchResponseConstructorFunctionError(ExecState* state) |
535 | { |
536 | return IDLOperation<JSFetchResponse>::callStatic<jsFetchResponseConstructorFunctionErrorBody>(*state, "error" ); |
537 | } |
538 | |
539 | static inline JSC::EncodedJSValue jsFetchResponseConstructorFunctionRedirectBody(JSC::ExecState* state, JSC::ThrowScope& throwScope) |
540 | { |
541 | UNUSED_PARAM(state); |
542 | UNUSED_PARAM(throwScope); |
543 | if (UNLIKELY(state->argumentCount() < 1)) |
544 | return throwVMError(state, throwScope, createNotEnoughArgumentsError(state)); |
545 | auto* context = jsCast<JSDOMGlobalObject*>(state->lexicalGlobalObject())->scriptExecutionContext(); |
546 | if (UNLIKELY(!context)) |
547 | return JSValue::encode(jsUndefined()); |
548 | auto url = convert<IDLUSVString>(*state, state->uncheckedArgument(0)); |
549 | RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); |
550 | auto status = state->argument(1).isUndefined() ? 302 : convert<IDLUnsignedShort>(*state, state->uncheckedArgument(1)); |
551 | RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); |
552 | return JSValue::encode(toJSNewlyCreated<IDLInterface<FetchResponse>>(*state, *jsCast<JSDOMGlobalObject*>(state->lexicalGlobalObject()), throwScope, FetchResponse::redirect(*context, WTFMove(url), WTFMove(status)))); |
553 | } |
554 | |
555 | EncodedJSValue JSC_HOST_CALL jsFetchResponseConstructorFunctionRedirect(ExecState* state) |
556 | { |
557 | return IDLOperation<JSFetchResponse>::callStatic<jsFetchResponseConstructorFunctionRedirectBody>(*state, "redirect" ); |
558 | } |
559 | |
560 | static inline JSC::EncodedJSValue jsFetchResponsePrototypeFunctionCloneBody(JSC::ExecState* state, typename IDLOperation<JSFetchResponse>::ClassParameter castedThis, JSC::ThrowScope& throwScope) |
561 | { |
562 | UNUSED_PARAM(state); |
563 | UNUSED_PARAM(throwScope); |
564 | auto& impl = castedThis->wrapped(); |
565 | auto* context = jsCast<JSDOMGlobalObject*>(state->lexicalGlobalObject())->scriptExecutionContext(); |
566 | if (UNLIKELY(!context)) |
567 | return JSValue::encode(jsUndefined()); |
568 | return JSValue::encode(toJSNewlyCreated<IDLInterface<FetchResponse>>(*state, *castedThis->globalObject(), throwScope, impl.clone(*context))); |
569 | } |
570 | |
571 | EncodedJSValue JSC_HOST_CALL jsFetchResponsePrototypeFunctionClone(ExecState* state) |
572 | { |
573 | return IDLOperation<JSFetchResponse>::call<jsFetchResponsePrototypeFunctionCloneBody>(*state, "clone" ); |
574 | } |
575 | |
576 | static inline JSC::EncodedJSValue jsFetchResponsePrototypeFunctionArrayBufferBody(JSC::ExecState* state, typename IDLOperationReturningPromise<JSFetchResponse>::ClassParameter castedThis, Ref<DeferredPromise>&& promise, JSC::ThrowScope& throwScope) |
577 | { |
578 | UNUSED_PARAM(state); |
579 | UNUSED_PARAM(throwScope); |
580 | auto& impl = castedThis->wrapped(); |
581 | impl.arrayBuffer(WTFMove(promise)); |
582 | return JSValue::encode(jsUndefined()); |
583 | } |
584 | |
585 | EncodedJSValue JSC_HOST_CALL jsFetchResponsePrototypeFunctionArrayBuffer(ExecState* state) |
586 | { |
587 | return IDLOperationReturningPromise<JSFetchResponse>::call<jsFetchResponsePrototypeFunctionArrayBufferBody, PromiseExecutionScope::WindowOrWorker>(*state, "arrayBuffer" ); |
588 | } |
589 | |
590 | static inline JSC::EncodedJSValue jsFetchResponsePrototypeFunctionBlobBody(JSC::ExecState* state, typename IDLOperationReturningPromise<JSFetchResponse>::ClassParameter castedThis, Ref<DeferredPromise>&& promise, JSC::ThrowScope& throwScope) |
591 | { |
592 | UNUSED_PARAM(state); |
593 | UNUSED_PARAM(throwScope); |
594 | auto& impl = castedThis->wrapped(); |
595 | impl.blob(WTFMove(promise)); |
596 | return JSValue::encode(jsUndefined()); |
597 | } |
598 | |
599 | EncodedJSValue JSC_HOST_CALL jsFetchResponsePrototypeFunctionBlob(ExecState* state) |
600 | { |
601 | return IDLOperationReturningPromise<JSFetchResponse>::call<jsFetchResponsePrototypeFunctionBlobBody, PromiseExecutionScope::WindowOrWorker>(*state, "blob" ); |
602 | } |
603 | |
604 | static inline JSC::EncodedJSValue jsFetchResponsePrototypeFunctionFormDataBody(JSC::ExecState* state, typename IDLOperationReturningPromise<JSFetchResponse>::ClassParameter castedThis, Ref<DeferredPromise>&& promise, JSC::ThrowScope& throwScope) |
605 | { |
606 | UNUSED_PARAM(state); |
607 | UNUSED_PARAM(throwScope); |
608 | auto& impl = castedThis->wrapped(); |
609 | impl.formData(WTFMove(promise)); |
610 | return JSValue::encode(jsUndefined()); |
611 | } |
612 | |
613 | EncodedJSValue JSC_HOST_CALL jsFetchResponsePrototypeFunctionFormData(ExecState* state) |
614 | { |
615 | return IDLOperationReturningPromise<JSFetchResponse>::call<jsFetchResponsePrototypeFunctionFormDataBody, PromiseExecutionScope::WindowOrWorker>(*state, "formData" ); |
616 | } |
617 | |
618 | static inline JSC::EncodedJSValue jsFetchResponsePrototypeFunctionJsonBody(JSC::ExecState* state, typename IDLOperationReturningPromise<JSFetchResponse>::ClassParameter castedThis, Ref<DeferredPromise>&& promise, JSC::ThrowScope& throwScope) |
619 | { |
620 | UNUSED_PARAM(state); |
621 | UNUSED_PARAM(throwScope); |
622 | auto& impl = castedThis->wrapped(); |
623 | impl.json(WTFMove(promise)); |
624 | return JSValue::encode(jsUndefined()); |
625 | } |
626 | |
627 | EncodedJSValue JSC_HOST_CALL jsFetchResponsePrototypeFunctionJson(ExecState* state) |
628 | { |
629 | return IDLOperationReturningPromise<JSFetchResponse>::call<jsFetchResponsePrototypeFunctionJsonBody, PromiseExecutionScope::WindowOrWorker>(*state, "json" ); |
630 | } |
631 | |
632 | static inline JSC::EncodedJSValue jsFetchResponsePrototypeFunctionTextBody(JSC::ExecState* state, typename IDLOperationReturningPromise<JSFetchResponse>::ClassParameter castedThis, Ref<DeferredPromise>&& promise, JSC::ThrowScope& throwScope) |
633 | { |
634 | UNUSED_PARAM(state); |
635 | UNUSED_PARAM(throwScope); |
636 | auto& impl = castedThis->wrapped(); |
637 | impl.text(WTFMove(promise)); |
638 | return JSValue::encode(jsUndefined()); |
639 | } |
640 | |
641 | EncodedJSValue JSC_HOST_CALL jsFetchResponsePrototypeFunctionText(ExecState* state) |
642 | { |
643 | return IDLOperationReturningPromise<JSFetchResponse>::call<jsFetchResponsePrototypeFunctionTextBody, PromiseExecutionScope::WindowOrWorker>(*state, "text" ); |
644 | } |
645 | |
646 | void JSFetchResponse::heapSnapshot(JSCell* cell, HeapSnapshotBuilder& builder) |
647 | { |
648 | auto* thisObject = jsCast<JSFetchResponse*>(cell); |
649 | builder.setWrappedObjectForCell(cell, &thisObject->wrapped()); |
650 | if (thisObject->scriptExecutionContext()) |
651 | builder.setLabelForCell(cell, "url " + thisObject->scriptExecutionContext()->url().string()); |
652 | Base::heapSnapshot(cell, builder); |
653 | } |
654 | |
655 | bool JSFetchResponseOwner::isReachableFromOpaqueRoots(JSC::Handle<JSC::Unknown> handle, void*, SlotVisitor& visitor, const char** reason) |
656 | { |
657 | auto* jsFetchResponse = jsCast<JSFetchResponse*>(handle.slot()->asCell()); |
658 | if (jsFetchResponse->wrapped().hasPendingActivity()) { |
659 | if (UNLIKELY(reason)) |
660 | *reason = "ActiveDOMObject with pending activity" ; |
661 | return true; |
662 | } |
663 | UNUSED_PARAM(visitor); |
664 | UNUSED_PARAM(reason); |
665 | return false; |
666 | } |
667 | |
668 | void JSFetchResponseOwner::finalize(JSC::Handle<JSC::Unknown> handle, void* context) |
669 | { |
670 | auto* jsFetchResponse = static_cast<JSFetchResponse*>(handle.slot()->asCell()); |
671 | auto& world = *static_cast<DOMWrapperWorld*>(context); |
672 | uncacheWrapper(world, &jsFetchResponse->wrapped(), jsFetchResponse); |
673 | } |
674 | |
675 | #if ENABLE(BINDING_INTEGRITY) |
676 | #if PLATFORM(WIN) |
677 | #pragma warning(disable: 4483) |
678 | extern "C" { extern void (*const __identifier("??_7FetchResponse@WebCore@@6B@" )[])(); } |
679 | #else |
680 | extern "C" { extern void* _ZTVN7WebCore13FetchResponseE[]; } |
681 | #endif |
682 | #endif |
683 | |
684 | JSC::JSValue toJSNewlyCreated(JSC::ExecState*, JSDOMGlobalObject* globalObject, Ref<FetchResponse>&& impl) |
685 | { |
686 | |
687 | #if ENABLE(BINDING_INTEGRITY) |
688 | void* actualVTablePointer = *(reinterpret_cast<void**>(impl.ptr())); |
689 | #if PLATFORM(WIN) |
690 | void* expectedVTablePointer = WTF_PREPARE_VTBL_POINTER_FOR_INSPECTION(__identifier("??_7FetchResponse@WebCore@@6B@" )); |
691 | #else |
692 | void* expectedVTablePointer = WTF_PREPARE_VTBL_POINTER_FOR_INSPECTION(&_ZTVN7WebCore13FetchResponseE[2]); |
693 | #endif |
694 | |
695 | // If this fails FetchResponse does not have a vtable, so you need to add the |
696 | // ImplementationLacksVTable attribute to the interface definition |
697 | static_assert(std::is_polymorphic<FetchResponse>::value, "FetchResponse is not polymorphic" ); |
698 | |
699 | // If you hit this assertion you either have a use after free bug, or |
700 | // FetchResponse has subclasses. If FetchResponse has subclasses that get passed |
701 | // to toJS() we currently require FetchResponse you to opt out of binding hardening |
702 | // by adding the SkipVTableValidation attribute to the interface IDL definition |
703 | RELEASE_ASSERT(actualVTablePointer == expectedVTablePointer); |
704 | #endif |
705 | return createWrapper<FetchResponse>(globalObject, WTFMove(impl)); |
706 | } |
707 | |
708 | JSC::JSValue toJS(JSC::ExecState* state, JSDOMGlobalObject* globalObject, FetchResponse& impl) |
709 | { |
710 | return wrap(state, globalObject, impl); |
711 | } |
712 | |
713 | FetchResponse* JSFetchResponse::toWrapped(JSC::VM& vm, JSC::JSValue value) |
714 | { |
715 | if (auto* wrapper = jsDynamicCast<JSFetchResponse*>(vm, value)) |
716 | return &wrapper->wrapped(); |
717 | return nullptr; |
718 | } |
719 | |
720 | } |
721 | |