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 "JSFetchRequest.h" |
23 | |
24 | #include "JSAbortSignal.h" |
25 | #include "JSDOMAttribute.h" |
26 | #include "JSDOMBinding.h" |
27 | #include "JSDOMConstructor.h" |
28 | #include "JSDOMConvertBoolean.h" |
29 | #include "JSDOMConvertDictionary.h" |
30 | #include "JSDOMConvertInterface.h" |
31 | #include "JSDOMConvertNullable.h" |
32 | #include "JSDOMConvertStrings.h" |
33 | #include "JSDOMConvertUnion.h" |
34 | #include "JSDOMExceptionHandling.h" |
35 | #include "JSDOMGlobalObject.h" |
36 | #include "JSDOMOperation.h" |
37 | #include "JSDOMOperationReturningPromise.h" |
38 | #include "JSDOMWrapperCache.h" |
39 | #include "JSFetchHeaders.h" |
40 | #include "JSFetchReferrerPolicy.h" |
41 | #include "JSFetchRequest.h" |
42 | #include "JSFetchRequestCache.h" |
43 | #include "JSFetchRequestCredentials.h" |
44 | #include "JSFetchRequestInit.h" |
45 | #include "JSFetchRequestMode.h" |
46 | #include "JSFetchRequestRedirect.h" |
47 | #include "JSReadableStream.h" |
48 | #include "RuntimeEnabledFeatures.h" |
49 | #include "ScriptExecutionContext.h" |
50 | #include <JavaScriptCore/FunctionPrototype.h> |
51 | #include <JavaScriptCore/HeapSnapshotBuilder.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 | |
59 | |
60 | namespace WebCore { |
61 | using namespace JSC; |
62 | |
63 | String convertEnumerationToString(FetchRequest::Destination enumerationValue) |
64 | { |
65 | static const NeverDestroyed<String> values[] = { |
66 | emptyString(), |
67 | MAKE_STATIC_STRING_IMPL("audio" ), |
68 | MAKE_STATIC_STRING_IMPL("document" ), |
69 | MAKE_STATIC_STRING_IMPL("embed" ), |
70 | MAKE_STATIC_STRING_IMPL("font" ), |
71 | MAKE_STATIC_STRING_IMPL("image" ), |
72 | MAKE_STATIC_STRING_IMPL("manifest" ), |
73 | MAKE_STATIC_STRING_IMPL("object" ), |
74 | MAKE_STATIC_STRING_IMPL("report" ), |
75 | MAKE_STATIC_STRING_IMPL("script" ), |
76 | MAKE_STATIC_STRING_IMPL("serviceworker" ), |
77 | MAKE_STATIC_STRING_IMPL("sharedworker" ), |
78 | MAKE_STATIC_STRING_IMPL("style" ), |
79 | MAKE_STATIC_STRING_IMPL("track" ), |
80 | MAKE_STATIC_STRING_IMPL("video" ), |
81 | MAKE_STATIC_STRING_IMPL("worker" ), |
82 | MAKE_STATIC_STRING_IMPL("xslt" ), |
83 | }; |
84 | static_assert(static_cast<size_t>(FetchRequest::Destination::EmptyString) == 0, "FetchRequest::Destination::EmptyString is not 0 as expected" ); |
85 | static_assert(static_cast<size_t>(FetchRequest::Destination::Audio) == 1, "FetchRequest::Destination::Audio is not 1 as expected" ); |
86 | static_assert(static_cast<size_t>(FetchRequest::Destination::Document) == 2, "FetchRequest::Destination::Document is not 2 as expected" ); |
87 | static_assert(static_cast<size_t>(FetchRequest::Destination::Embed) == 3, "FetchRequest::Destination::Embed is not 3 as expected" ); |
88 | static_assert(static_cast<size_t>(FetchRequest::Destination::Font) == 4, "FetchRequest::Destination::Font is not 4 as expected" ); |
89 | static_assert(static_cast<size_t>(FetchRequest::Destination::Image) == 5, "FetchRequest::Destination::Image is not 5 as expected" ); |
90 | static_assert(static_cast<size_t>(FetchRequest::Destination::Manifest) == 6, "FetchRequest::Destination::Manifest is not 6 as expected" ); |
91 | static_assert(static_cast<size_t>(FetchRequest::Destination::Object) == 7, "FetchRequest::Destination::Object is not 7 as expected" ); |
92 | static_assert(static_cast<size_t>(FetchRequest::Destination::Report) == 8, "FetchRequest::Destination::Report is not 8 as expected" ); |
93 | static_assert(static_cast<size_t>(FetchRequest::Destination::Script) == 9, "FetchRequest::Destination::Script is not 9 as expected" ); |
94 | static_assert(static_cast<size_t>(FetchRequest::Destination::Serviceworker) == 10, "FetchRequest::Destination::Serviceworker is not 10 as expected" ); |
95 | static_assert(static_cast<size_t>(FetchRequest::Destination::Sharedworker) == 11, "FetchRequest::Destination::Sharedworker is not 11 as expected" ); |
96 | static_assert(static_cast<size_t>(FetchRequest::Destination::Style) == 12, "FetchRequest::Destination::Style is not 12 as expected" ); |
97 | static_assert(static_cast<size_t>(FetchRequest::Destination::Track) == 13, "FetchRequest::Destination::Track is not 13 as expected" ); |
98 | static_assert(static_cast<size_t>(FetchRequest::Destination::Video) == 14, "FetchRequest::Destination::Video is not 14 as expected" ); |
99 | static_assert(static_cast<size_t>(FetchRequest::Destination::Worker) == 15, "FetchRequest::Destination::Worker is not 15 as expected" ); |
100 | static_assert(static_cast<size_t>(FetchRequest::Destination::Xslt) == 16, "FetchRequest::Destination::Xslt is not 16 as expected" ); |
101 | ASSERT(static_cast<size_t>(enumerationValue) < WTF_ARRAY_LENGTH(values)); |
102 | return values[static_cast<size_t>(enumerationValue)]; |
103 | } |
104 | |
105 | template<> JSString* convertEnumerationToJS(ExecState& state, FetchRequest::Destination enumerationValue) |
106 | { |
107 | return jsStringWithCache(&state, convertEnumerationToString(enumerationValue)); |
108 | } |
109 | |
110 | template<> Optional<FetchRequest::Destination> parseEnumeration<FetchRequest::Destination>(ExecState& state, JSValue value) |
111 | { |
112 | auto stringValue = value.toWTFString(&state); |
113 | if (stringValue.isEmpty()) |
114 | return FetchRequest::Destination::EmptyString; |
115 | if (stringValue == "audio" ) |
116 | return FetchRequest::Destination::Audio; |
117 | if (stringValue == "document" ) |
118 | return FetchRequest::Destination::Document; |
119 | if (stringValue == "embed" ) |
120 | return FetchRequest::Destination::Embed; |
121 | if (stringValue == "font" ) |
122 | return FetchRequest::Destination::Font; |
123 | if (stringValue == "image" ) |
124 | return FetchRequest::Destination::Image; |
125 | if (stringValue == "manifest" ) |
126 | return FetchRequest::Destination::Manifest; |
127 | if (stringValue == "object" ) |
128 | return FetchRequest::Destination::Object; |
129 | if (stringValue == "report" ) |
130 | return FetchRequest::Destination::Report; |
131 | if (stringValue == "script" ) |
132 | return FetchRequest::Destination::Script; |
133 | if (stringValue == "serviceworker" ) |
134 | return FetchRequest::Destination::Serviceworker; |
135 | if (stringValue == "sharedworker" ) |
136 | return FetchRequest::Destination::Sharedworker; |
137 | if (stringValue == "style" ) |
138 | return FetchRequest::Destination::Style; |
139 | if (stringValue == "track" ) |
140 | return FetchRequest::Destination::Track; |
141 | if (stringValue == "video" ) |
142 | return FetchRequest::Destination::Video; |
143 | if (stringValue == "worker" ) |
144 | return FetchRequest::Destination::Worker; |
145 | if (stringValue == "xslt" ) |
146 | return FetchRequest::Destination::Xslt; |
147 | return WTF::nullopt; |
148 | } |
149 | |
150 | template<> const char* expectedEnumerationValues<FetchRequest::Destination>() |
151 | { |
152 | return "\"\", \"audio\", \"document\", \"embed\", \"font\", \"image\", \"manifest\", \"object\", \"report\", \"script\", \"serviceworker\", \"sharedworker\", \"style\", \"track\", \"video\", \"worker\", \"xslt\"" ; |
153 | } |
154 | |
155 | // Functions |
156 | |
157 | JSC::EncodedJSValue JSC_HOST_CALL jsFetchRequestPrototypeFunctionClone(JSC::ExecState*); |
158 | JSC::EncodedJSValue JSC_HOST_CALL jsFetchRequestPrototypeFunctionArrayBuffer(JSC::ExecState*); |
159 | JSC::EncodedJSValue JSC_HOST_CALL jsFetchRequestPrototypeFunctionBlob(JSC::ExecState*); |
160 | JSC::EncodedJSValue JSC_HOST_CALL jsFetchRequestPrototypeFunctionFormData(JSC::ExecState*); |
161 | JSC::EncodedJSValue JSC_HOST_CALL jsFetchRequestPrototypeFunctionJson(JSC::ExecState*); |
162 | JSC::EncodedJSValue JSC_HOST_CALL jsFetchRequestPrototypeFunctionText(JSC::ExecState*); |
163 | |
164 | // Attributes |
165 | |
166 | JSC::EncodedJSValue jsFetchRequestConstructor(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
167 | bool setJSFetchRequestConstructor(JSC::ExecState*, JSC::EncodedJSValue, JSC::EncodedJSValue); |
168 | JSC::EncodedJSValue jsFetchRequestMethod(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
169 | JSC::EncodedJSValue jsFetchRequestUrl(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
170 | JSC::EncodedJSValue jsFetchRequestHeaders(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
171 | JSC::EncodedJSValue jsFetchRequestDestination(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
172 | JSC::EncodedJSValue jsFetchRequestReferrer(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
173 | JSC::EncodedJSValue jsFetchRequestReferrerPolicy(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
174 | JSC::EncodedJSValue jsFetchRequestMode(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
175 | JSC::EncodedJSValue jsFetchRequestCredentials(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
176 | JSC::EncodedJSValue jsFetchRequestCache(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
177 | JSC::EncodedJSValue jsFetchRequestRedirect(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
178 | JSC::EncodedJSValue jsFetchRequestIntegrity(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
179 | JSC::EncodedJSValue jsFetchRequestKeepalive(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
180 | JSC::EncodedJSValue jsFetchRequestSignal(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
181 | JSC::EncodedJSValue jsFetchRequestBody(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
182 | JSC::EncodedJSValue jsFetchRequestBodyUsed(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
183 | |
184 | class JSFetchRequestPrototype : public JSC::JSNonFinalObject { |
185 | public: |
186 | using Base = JSC::JSNonFinalObject; |
187 | static JSFetchRequestPrototype* create(JSC::VM& vm, JSDOMGlobalObject* globalObject, JSC::Structure* structure) |
188 | { |
189 | JSFetchRequestPrototype* ptr = new (NotNull, JSC::allocateCell<JSFetchRequestPrototype>(vm.heap)) JSFetchRequestPrototype(vm, globalObject, structure); |
190 | ptr->finishCreation(vm); |
191 | return ptr; |
192 | } |
193 | |
194 | DECLARE_INFO; |
195 | static JSC::Structure* createStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype) |
196 | { |
197 | return JSC::Structure::create(vm, globalObject, prototype, JSC::TypeInfo(JSC::ObjectType, StructureFlags), info()); |
198 | } |
199 | |
200 | private: |
201 | JSFetchRequestPrototype(JSC::VM& vm, JSC::JSGlobalObject*, JSC::Structure* structure) |
202 | : JSC::JSNonFinalObject(vm, structure) |
203 | { |
204 | } |
205 | |
206 | void finishCreation(JSC::VM&); |
207 | }; |
208 | |
209 | using JSFetchRequestConstructor = JSDOMConstructor<JSFetchRequest>; |
210 | |
211 | template<> EncodedJSValue JSC_HOST_CALL JSFetchRequestConstructor::construct(ExecState* state) |
212 | { |
213 | VM& vm = state->vm(); |
214 | auto throwScope = DECLARE_THROW_SCOPE(vm); |
215 | UNUSED_PARAM(throwScope); |
216 | auto* castedThis = jsCast<JSFetchRequestConstructor*>(state->jsCallee()); |
217 | ASSERT(castedThis); |
218 | if (UNLIKELY(state->argumentCount() < 1)) |
219 | return throwVMError(state, throwScope, createNotEnoughArgumentsError(state)); |
220 | auto* context = castedThis->scriptExecutionContext(); |
221 | if (UNLIKELY(!context)) |
222 | return throwConstructorScriptExecutionContextUnavailableError(*state, throwScope, "Request" ); |
223 | auto input = convert<IDLUnion<IDLInterface<FetchRequest>, IDLUSVString>>(*state, state->uncheckedArgument(0)); |
224 | RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); |
225 | auto init = convert<IDLDictionary<FetchRequestInit>>(*state, state->argument(1)); |
226 | RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); |
227 | auto object = FetchRequest::create(*context, WTFMove(input), WTFMove(init)); |
228 | return JSValue::encode(toJSNewlyCreated<IDLInterface<FetchRequest>>(*state, *castedThis->globalObject(), throwScope, WTFMove(object))); |
229 | } |
230 | |
231 | template<> JSValue JSFetchRequestConstructor::prototypeForStructure(JSC::VM& vm, const JSDOMGlobalObject& globalObject) |
232 | { |
233 | UNUSED_PARAM(vm); |
234 | return globalObject.functionPrototype(); |
235 | } |
236 | |
237 | template<> void JSFetchRequestConstructor::initializeProperties(VM& vm, JSDOMGlobalObject& globalObject) |
238 | { |
239 | putDirect(vm, vm.propertyNames->prototype, JSFetchRequest::prototype(vm, globalObject), JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum); |
240 | putDirect(vm, vm.propertyNames->name, jsNontrivialString(&vm, String("Request"_s )), JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum); |
241 | putDirect(vm, vm.propertyNames->length, jsNumber(1), JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum); |
242 | } |
243 | |
244 | template<> const ClassInfo JSFetchRequestConstructor::s_info = { "Request" , &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSFetchRequestConstructor) }; |
245 | |
246 | /* Hash table for prototype */ |
247 | |
248 | static const HashTableValue JSFetchRequestPrototypeTableValues[] = |
249 | { |
250 | { "constructor" , static_cast<unsigned>(JSC::PropertyAttribute::DontEnum), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsFetchRequestConstructor), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(setJSFetchRequestConstructor) } }, |
251 | { "method" , static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsFetchRequestMethod), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } }, |
252 | { "url" , static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsFetchRequestUrl), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } }, |
253 | { "headers" , static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsFetchRequestHeaders), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } }, |
254 | { "destination" , static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsFetchRequestDestination), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } }, |
255 | { "referrer" , static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsFetchRequestReferrer), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } }, |
256 | { "referrerPolicy" , static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsFetchRequestReferrerPolicy), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } }, |
257 | { "mode" , static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsFetchRequestMode), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } }, |
258 | { "credentials" , static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsFetchRequestCredentials), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } }, |
259 | { "cache" , static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsFetchRequestCache), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } }, |
260 | { "redirect" , static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsFetchRequestRedirect), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } }, |
261 | { "integrity" , static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsFetchRequestIntegrity), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } }, |
262 | { "keepalive" , static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsFetchRequestKeepalive), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } }, |
263 | { "signal" , static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsFetchRequestSignal), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } }, |
264 | { "body" , static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsFetchRequestBody), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } }, |
265 | { "bodyUsed" , static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsFetchRequestBodyUsed), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } }, |
266 | { "clone" , static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t)static_cast<RawNativeFunction>(jsFetchRequestPrototypeFunctionClone), (intptr_t) (0) } }, |
267 | { "arrayBuffer" , static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t)static_cast<RawNativeFunction>(jsFetchRequestPrototypeFunctionArrayBuffer), (intptr_t) (0) } }, |
268 | { "blob" , static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t)static_cast<RawNativeFunction>(jsFetchRequestPrototypeFunctionBlob), (intptr_t) (0) } }, |
269 | { "formData" , static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t)static_cast<RawNativeFunction>(jsFetchRequestPrototypeFunctionFormData), (intptr_t) (0) } }, |
270 | { "json" , static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t)static_cast<RawNativeFunction>(jsFetchRequestPrototypeFunctionJson), (intptr_t) (0) } }, |
271 | { "text" , static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t)static_cast<RawNativeFunction>(jsFetchRequestPrototypeFunctionText), (intptr_t) (0) } }, |
272 | }; |
273 | |
274 | const ClassInfo JSFetchRequestPrototype::s_info = { "RequestPrototype" , &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSFetchRequestPrototype) }; |
275 | |
276 | void JSFetchRequestPrototype::finishCreation(VM& vm) |
277 | { |
278 | Base::finishCreation(vm); |
279 | reifyStaticProperties(vm, JSFetchRequest::info(), JSFetchRequestPrototypeTableValues, *this); |
280 | bool hasDisabledRuntimeProperties = false; |
281 | if (!RuntimeEnabledFeatures::sharedFeatures().fetchAPIEnabled()) { |
282 | hasDisabledRuntimeProperties = true; |
283 | auto propertyName = Identifier::fromString(&vm, reinterpret_cast<const LChar*>("arrayBuffer" ), strlen("arrayBuffer" )); |
284 | VM::DeletePropertyModeScope scope(vm, VM::DeletePropertyMode::IgnoreConfigurable); |
285 | JSObject::deleteProperty(this, globalObject()->globalExec(), propertyName); |
286 | } |
287 | if (!RuntimeEnabledFeatures::sharedFeatures().fetchAPIEnabled()) { |
288 | hasDisabledRuntimeProperties = true; |
289 | auto propertyName = Identifier::fromString(&vm, reinterpret_cast<const LChar*>("blob" ), strlen("blob" )); |
290 | VM::DeletePropertyModeScope scope(vm, VM::DeletePropertyMode::IgnoreConfigurable); |
291 | JSObject::deleteProperty(this, globalObject()->globalExec(), propertyName); |
292 | } |
293 | if (!RuntimeEnabledFeatures::sharedFeatures().fetchAPIEnabled()) { |
294 | hasDisabledRuntimeProperties = true; |
295 | auto propertyName = Identifier::fromString(&vm, reinterpret_cast<const LChar*>("formData" ), strlen("formData" )); |
296 | VM::DeletePropertyModeScope scope(vm, VM::DeletePropertyMode::IgnoreConfigurable); |
297 | JSObject::deleteProperty(this, globalObject()->globalExec(), propertyName); |
298 | } |
299 | if (!RuntimeEnabledFeatures::sharedFeatures().fetchAPIEnabled()) { |
300 | hasDisabledRuntimeProperties = true; |
301 | auto propertyName = Identifier::fromString(&vm, reinterpret_cast<const LChar*>("json" ), strlen("json" )); |
302 | VM::DeletePropertyModeScope scope(vm, VM::DeletePropertyMode::IgnoreConfigurable); |
303 | JSObject::deleteProperty(this, globalObject()->globalExec(), propertyName); |
304 | } |
305 | if (!RuntimeEnabledFeatures::sharedFeatures().fetchAPIEnabled()) { |
306 | hasDisabledRuntimeProperties = true; |
307 | auto propertyName = Identifier::fromString(&vm, reinterpret_cast<const LChar*>("text" ), strlen("text" )); |
308 | VM::DeletePropertyModeScope scope(vm, VM::DeletePropertyMode::IgnoreConfigurable); |
309 | JSObject::deleteProperty(this, globalObject()->globalExec(), propertyName); |
310 | } |
311 | if (!RuntimeEnabledFeatures::sharedFeatures().fetchAPIKeepAliveEnabled()) { |
312 | hasDisabledRuntimeProperties = true; |
313 | auto propertyName = Identifier::fromString(&vm, reinterpret_cast<const LChar*>("keepalive" ), strlen("keepalive" )); |
314 | VM::DeletePropertyModeScope scope(vm, VM::DeletePropertyMode::IgnoreConfigurable); |
315 | JSObject::deleteProperty(this, globalObject()->globalExec(), propertyName); |
316 | } |
317 | if (!RuntimeEnabledFeatures::sharedFeatures().fetchAPIEnabled()) { |
318 | hasDisabledRuntimeProperties = true; |
319 | auto propertyName = Identifier::fromString(&vm, reinterpret_cast<const LChar*>("body" ), strlen("body" )); |
320 | VM::DeletePropertyModeScope scope(vm, VM::DeletePropertyMode::IgnoreConfigurable); |
321 | JSObject::deleteProperty(this, globalObject()->globalExec(), propertyName); |
322 | } |
323 | if (!RuntimeEnabledFeatures::sharedFeatures().fetchAPIEnabled()) { |
324 | hasDisabledRuntimeProperties = true; |
325 | auto propertyName = Identifier::fromString(&vm, reinterpret_cast<const LChar*>("bodyUsed" ), strlen("bodyUsed" )); |
326 | VM::DeletePropertyModeScope scope(vm, VM::DeletePropertyMode::IgnoreConfigurable); |
327 | JSObject::deleteProperty(this, globalObject()->globalExec(), propertyName); |
328 | } |
329 | if (hasDisabledRuntimeProperties && structure()->isDictionary()) |
330 | flattenDictionaryObject(vm); |
331 | } |
332 | |
333 | const ClassInfo JSFetchRequest::s_info = { "Request" , &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSFetchRequest) }; |
334 | |
335 | JSFetchRequest::JSFetchRequest(Structure* structure, JSDOMGlobalObject& globalObject, Ref<FetchRequest>&& impl) |
336 | : JSDOMWrapper<FetchRequest>(structure, globalObject, WTFMove(impl)) |
337 | { |
338 | } |
339 | |
340 | void JSFetchRequest::finishCreation(VM& vm) |
341 | { |
342 | Base::finishCreation(vm); |
343 | ASSERT(inherits(vm, info())); |
344 | |
345 | } |
346 | |
347 | JSObject* JSFetchRequest::createPrototype(VM& vm, JSDOMGlobalObject& globalObject) |
348 | { |
349 | return JSFetchRequestPrototype::create(vm, &globalObject, JSFetchRequestPrototype::createStructure(vm, &globalObject, globalObject.objectPrototype())); |
350 | } |
351 | |
352 | JSObject* JSFetchRequest::prototype(VM& vm, JSDOMGlobalObject& globalObject) |
353 | { |
354 | return getDOMPrototype<JSFetchRequest>(vm, globalObject); |
355 | } |
356 | |
357 | JSValue JSFetchRequest::getConstructor(VM& vm, const JSGlobalObject* globalObject) |
358 | { |
359 | return getDOMConstructor<JSFetchRequestConstructor>(vm, *jsCast<const JSDOMGlobalObject*>(globalObject)); |
360 | } |
361 | |
362 | void JSFetchRequest::destroy(JSC::JSCell* cell) |
363 | { |
364 | JSFetchRequest* thisObject = static_cast<JSFetchRequest*>(cell); |
365 | thisObject->JSFetchRequest::~JSFetchRequest(); |
366 | } |
367 | |
368 | template<> inline JSFetchRequest* IDLAttribute<JSFetchRequest>::cast(ExecState& state, EncodedJSValue thisValue) |
369 | { |
370 | return jsDynamicCast<JSFetchRequest*>(state.vm(), JSValue::decode(thisValue)); |
371 | } |
372 | |
373 | template<> inline JSFetchRequest* IDLOperation<JSFetchRequest>::cast(ExecState& state) |
374 | { |
375 | return jsDynamicCast<JSFetchRequest*>(state.vm(), state.thisValue()); |
376 | } |
377 | |
378 | EncodedJSValue jsFetchRequestConstructor(ExecState* state, EncodedJSValue thisValue, PropertyName) |
379 | { |
380 | VM& vm = state->vm(); |
381 | auto throwScope = DECLARE_THROW_SCOPE(vm); |
382 | auto* prototype = jsDynamicCast<JSFetchRequestPrototype*>(vm, JSValue::decode(thisValue)); |
383 | if (UNLIKELY(!prototype)) |
384 | return throwVMTypeError(state, throwScope); |
385 | return JSValue::encode(JSFetchRequest::getConstructor(state->vm(), prototype->globalObject())); |
386 | } |
387 | |
388 | bool setJSFetchRequestConstructor(ExecState* state, EncodedJSValue thisValue, EncodedJSValue encodedValue) |
389 | { |
390 | VM& vm = state->vm(); |
391 | auto throwScope = DECLARE_THROW_SCOPE(vm); |
392 | auto* prototype = jsDynamicCast<JSFetchRequestPrototype*>(vm, JSValue::decode(thisValue)); |
393 | if (UNLIKELY(!prototype)) { |
394 | throwVMTypeError(state, throwScope); |
395 | return false; |
396 | } |
397 | // Shadowing a built-in constructor |
398 | return prototype->putDirect(vm, vm.propertyNames->constructor, JSValue::decode(encodedValue)); |
399 | } |
400 | |
401 | static inline JSValue jsFetchRequestMethodGetter(ExecState& state, JSFetchRequest& thisObject, ThrowScope& throwScope) |
402 | { |
403 | UNUSED_PARAM(throwScope); |
404 | UNUSED_PARAM(state); |
405 | auto& impl = thisObject.wrapped(); |
406 | JSValue result = toJS<IDLByteString>(state, throwScope, impl.method()); |
407 | return result; |
408 | } |
409 | |
410 | EncodedJSValue jsFetchRequestMethod(ExecState* state, EncodedJSValue thisValue, PropertyName) |
411 | { |
412 | return IDLAttribute<JSFetchRequest>::get<jsFetchRequestMethodGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "method" ); |
413 | } |
414 | |
415 | static inline JSValue jsFetchRequestUrlGetter(ExecState& state, JSFetchRequest& thisObject, ThrowScope& throwScope) |
416 | { |
417 | UNUSED_PARAM(throwScope); |
418 | UNUSED_PARAM(state); |
419 | auto& impl = thisObject.wrapped(); |
420 | JSValue result = toJS<IDLUSVString>(state, throwScope, impl.urlString()); |
421 | return result; |
422 | } |
423 | |
424 | EncodedJSValue jsFetchRequestUrl(ExecState* state, EncodedJSValue thisValue, PropertyName) |
425 | { |
426 | return IDLAttribute<JSFetchRequest>::get<jsFetchRequestUrlGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "url" ); |
427 | } |
428 | |
429 | static inline JSValue (ExecState& state, JSFetchRequest& thisObject, ThrowScope& throwScope) |
430 | { |
431 | UNUSED_PARAM(throwScope); |
432 | UNUSED_PARAM(state); |
433 | auto& impl = thisObject.wrapped(); |
434 | JSValue result = toJS<IDLInterface<FetchHeaders>>(state, *thisObject.globalObject(), throwScope, impl.headers()); |
435 | return result; |
436 | } |
437 | |
438 | EncodedJSValue (ExecState* state, EncodedJSValue thisValue, PropertyName) |
439 | { |
440 | return IDLAttribute<JSFetchRequest>::get<jsFetchRequestHeadersGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "headers" ); |
441 | } |
442 | |
443 | static inline JSValue jsFetchRequestDestinationGetter(ExecState& state, JSFetchRequest& thisObject, ThrowScope& throwScope) |
444 | { |
445 | UNUSED_PARAM(throwScope); |
446 | UNUSED_PARAM(state); |
447 | auto& impl = thisObject.wrapped(); |
448 | JSValue result = toJS<IDLEnumeration<FetchRequest::Destination>>(state, throwScope, impl.destination()); |
449 | return result; |
450 | } |
451 | |
452 | EncodedJSValue jsFetchRequestDestination(ExecState* state, EncodedJSValue thisValue, PropertyName) |
453 | { |
454 | return IDLAttribute<JSFetchRequest>::get<jsFetchRequestDestinationGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "destination" ); |
455 | } |
456 | |
457 | static inline JSValue jsFetchRequestReferrerGetter(ExecState& state, JSFetchRequest& thisObject, ThrowScope& throwScope) |
458 | { |
459 | UNUSED_PARAM(throwScope); |
460 | UNUSED_PARAM(state); |
461 | auto& impl = thisObject.wrapped(); |
462 | JSValue result = toJS<IDLUSVString>(state, throwScope, impl.referrer()); |
463 | return result; |
464 | } |
465 | |
466 | EncodedJSValue jsFetchRequestReferrer(ExecState* state, EncodedJSValue thisValue, PropertyName) |
467 | { |
468 | return IDLAttribute<JSFetchRequest>::get<jsFetchRequestReferrerGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "referrer" ); |
469 | } |
470 | |
471 | static inline JSValue jsFetchRequestReferrerPolicyGetter(ExecState& state, JSFetchRequest& thisObject, ThrowScope& throwScope) |
472 | { |
473 | UNUSED_PARAM(throwScope); |
474 | UNUSED_PARAM(state); |
475 | auto& impl = thisObject.wrapped(); |
476 | JSValue result = toJS<IDLEnumeration<FetchReferrerPolicy>>(state, throwScope, impl.referrerPolicy()); |
477 | return result; |
478 | } |
479 | |
480 | EncodedJSValue jsFetchRequestReferrerPolicy(ExecState* state, EncodedJSValue thisValue, PropertyName) |
481 | { |
482 | return IDLAttribute<JSFetchRequest>::get<jsFetchRequestReferrerPolicyGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "referrerPolicy" ); |
483 | } |
484 | |
485 | static inline JSValue jsFetchRequestModeGetter(ExecState& state, JSFetchRequest& thisObject, ThrowScope& throwScope) |
486 | { |
487 | UNUSED_PARAM(throwScope); |
488 | UNUSED_PARAM(state); |
489 | auto& impl = thisObject.wrapped(); |
490 | JSValue result = toJS<IDLEnumeration<FetchRequestMode>>(state, throwScope, impl.mode()); |
491 | return result; |
492 | } |
493 | |
494 | EncodedJSValue jsFetchRequestMode(ExecState* state, EncodedJSValue thisValue, PropertyName) |
495 | { |
496 | return IDLAttribute<JSFetchRequest>::get<jsFetchRequestModeGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "mode" ); |
497 | } |
498 | |
499 | static inline JSValue jsFetchRequestCredentialsGetter(ExecState& state, JSFetchRequest& thisObject, ThrowScope& throwScope) |
500 | { |
501 | UNUSED_PARAM(throwScope); |
502 | UNUSED_PARAM(state); |
503 | auto& impl = thisObject.wrapped(); |
504 | JSValue result = toJS<IDLEnumeration<FetchRequestCredentials>>(state, throwScope, impl.credentials()); |
505 | return result; |
506 | } |
507 | |
508 | EncodedJSValue jsFetchRequestCredentials(ExecState* state, EncodedJSValue thisValue, PropertyName) |
509 | { |
510 | return IDLAttribute<JSFetchRequest>::get<jsFetchRequestCredentialsGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "credentials" ); |
511 | } |
512 | |
513 | static inline JSValue jsFetchRequestCacheGetter(ExecState& state, JSFetchRequest& thisObject, ThrowScope& throwScope) |
514 | { |
515 | UNUSED_PARAM(throwScope); |
516 | UNUSED_PARAM(state); |
517 | auto& impl = thisObject.wrapped(); |
518 | JSValue result = toJS<IDLEnumeration<FetchRequestCache>>(state, throwScope, impl.cache()); |
519 | return result; |
520 | } |
521 | |
522 | EncodedJSValue jsFetchRequestCache(ExecState* state, EncodedJSValue thisValue, PropertyName) |
523 | { |
524 | return IDLAttribute<JSFetchRequest>::get<jsFetchRequestCacheGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "cache" ); |
525 | } |
526 | |
527 | static inline JSValue jsFetchRequestRedirectGetter(ExecState& state, JSFetchRequest& thisObject, ThrowScope& throwScope) |
528 | { |
529 | UNUSED_PARAM(throwScope); |
530 | UNUSED_PARAM(state); |
531 | auto& impl = thisObject.wrapped(); |
532 | JSValue result = toJS<IDLEnumeration<FetchRequestRedirect>>(state, throwScope, impl.redirect()); |
533 | return result; |
534 | } |
535 | |
536 | EncodedJSValue jsFetchRequestRedirect(ExecState* state, EncodedJSValue thisValue, PropertyName) |
537 | { |
538 | return IDLAttribute<JSFetchRequest>::get<jsFetchRequestRedirectGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "redirect" ); |
539 | } |
540 | |
541 | static inline JSValue jsFetchRequestIntegrityGetter(ExecState& state, JSFetchRequest& thisObject, ThrowScope& throwScope) |
542 | { |
543 | UNUSED_PARAM(throwScope); |
544 | UNUSED_PARAM(state); |
545 | auto& impl = thisObject.wrapped(); |
546 | JSValue result = toJS<IDLDOMString>(state, throwScope, impl.integrity()); |
547 | return result; |
548 | } |
549 | |
550 | EncodedJSValue jsFetchRequestIntegrity(ExecState* state, EncodedJSValue thisValue, PropertyName) |
551 | { |
552 | return IDLAttribute<JSFetchRequest>::get<jsFetchRequestIntegrityGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "integrity" ); |
553 | } |
554 | |
555 | static inline JSValue jsFetchRequestKeepaliveGetter(ExecState& state, JSFetchRequest& thisObject, ThrowScope& throwScope) |
556 | { |
557 | UNUSED_PARAM(throwScope); |
558 | UNUSED_PARAM(state); |
559 | auto& impl = thisObject.wrapped(); |
560 | JSValue result = toJS<IDLBoolean>(state, throwScope, impl.keepalive()); |
561 | return result; |
562 | } |
563 | |
564 | EncodedJSValue jsFetchRequestKeepalive(ExecState* state, EncodedJSValue thisValue, PropertyName) |
565 | { |
566 | return IDLAttribute<JSFetchRequest>::get<jsFetchRequestKeepaliveGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "keepalive" ); |
567 | } |
568 | |
569 | static inline JSValue jsFetchRequestSignalGetter(ExecState& state, JSFetchRequest& thisObject, ThrowScope& throwScope) |
570 | { |
571 | UNUSED_PARAM(throwScope); |
572 | UNUSED_PARAM(state); |
573 | auto& impl = thisObject.wrapped(); |
574 | JSValue result = toJS<IDLInterface<AbortSignal>>(state, *thisObject.globalObject(), throwScope, impl.signal()); |
575 | return result; |
576 | } |
577 | |
578 | EncodedJSValue jsFetchRequestSignal(ExecState* state, EncodedJSValue thisValue, PropertyName) |
579 | { |
580 | return IDLAttribute<JSFetchRequest>::get<jsFetchRequestSignalGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "signal" ); |
581 | } |
582 | |
583 | static inline JSValue jsFetchRequestBodyGetter(ExecState& state, JSFetchRequest& thisObject, ThrowScope& throwScope) |
584 | { |
585 | UNUSED_PARAM(throwScope); |
586 | UNUSED_PARAM(state); |
587 | auto& impl = thisObject.wrapped(); |
588 | JSValue result = toJS<IDLNullable<IDLInterface<ReadableStream>>>(state, *thisObject.globalObject(), throwScope, impl.readableStream(state)); |
589 | return result; |
590 | } |
591 | |
592 | EncodedJSValue jsFetchRequestBody(ExecState* state, EncodedJSValue thisValue, PropertyName) |
593 | { |
594 | return IDLAttribute<JSFetchRequest>::get<jsFetchRequestBodyGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "body" ); |
595 | } |
596 | |
597 | static inline JSValue jsFetchRequestBodyUsedGetter(ExecState& state, JSFetchRequest& thisObject, ThrowScope& throwScope) |
598 | { |
599 | UNUSED_PARAM(throwScope); |
600 | UNUSED_PARAM(state); |
601 | auto& impl = thisObject.wrapped(); |
602 | JSValue result = toJS<IDLBoolean>(state, throwScope, impl.bodyUsed()); |
603 | return result; |
604 | } |
605 | |
606 | EncodedJSValue jsFetchRequestBodyUsed(ExecState* state, EncodedJSValue thisValue, PropertyName) |
607 | { |
608 | return IDLAttribute<JSFetchRequest>::get<jsFetchRequestBodyUsedGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "bodyUsed" ); |
609 | } |
610 | |
611 | static inline JSC::EncodedJSValue jsFetchRequestPrototypeFunctionCloneBody(JSC::ExecState* state, typename IDLOperation<JSFetchRequest>::ClassParameter castedThis, JSC::ThrowScope& throwScope) |
612 | { |
613 | UNUSED_PARAM(state); |
614 | UNUSED_PARAM(throwScope); |
615 | auto& impl = castedThis->wrapped(); |
616 | auto* context = jsCast<JSDOMGlobalObject*>(state->lexicalGlobalObject())->scriptExecutionContext(); |
617 | if (UNLIKELY(!context)) |
618 | return JSValue::encode(jsUndefined()); |
619 | return JSValue::encode(toJSNewlyCreated<IDLInterface<FetchRequest>>(*state, *castedThis->globalObject(), throwScope, impl.clone(*context))); |
620 | } |
621 | |
622 | EncodedJSValue JSC_HOST_CALL jsFetchRequestPrototypeFunctionClone(ExecState* state) |
623 | { |
624 | return IDLOperation<JSFetchRequest>::call<jsFetchRequestPrototypeFunctionCloneBody>(*state, "clone" ); |
625 | } |
626 | |
627 | static inline JSC::EncodedJSValue jsFetchRequestPrototypeFunctionArrayBufferBody(JSC::ExecState* state, typename IDLOperationReturningPromise<JSFetchRequest>::ClassParameter castedThis, Ref<DeferredPromise>&& promise, JSC::ThrowScope& throwScope) |
628 | { |
629 | UNUSED_PARAM(state); |
630 | UNUSED_PARAM(throwScope); |
631 | auto& impl = castedThis->wrapped(); |
632 | impl.arrayBuffer(WTFMove(promise)); |
633 | return JSValue::encode(jsUndefined()); |
634 | } |
635 | |
636 | EncodedJSValue JSC_HOST_CALL jsFetchRequestPrototypeFunctionArrayBuffer(ExecState* state) |
637 | { |
638 | return IDLOperationReturningPromise<JSFetchRequest>::call<jsFetchRequestPrototypeFunctionArrayBufferBody, PromiseExecutionScope::WindowOrWorker>(*state, "arrayBuffer" ); |
639 | } |
640 | |
641 | static inline JSC::EncodedJSValue jsFetchRequestPrototypeFunctionBlobBody(JSC::ExecState* state, typename IDLOperationReturningPromise<JSFetchRequest>::ClassParameter castedThis, Ref<DeferredPromise>&& promise, JSC::ThrowScope& throwScope) |
642 | { |
643 | UNUSED_PARAM(state); |
644 | UNUSED_PARAM(throwScope); |
645 | auto& impl = castedThis->wrapped(); |
646 | impl.blob(WTFMove(promise)); |
647 | return JSValue::encode(jsUndefined()); |
648 | } |
649 | |
650 | EncodedJSValue JSC_HOST_CALL jsFetchRequestPrototypeFunctionBlob(ExecState* state) |
651 | { |
652 | return IDLOperationReturningPromise<JSFetchRequest>::call<jsFetchRequestPrototypeFunctionBlobBody, PromiseExecutionScope::WindowOrWorker>(*state, "blob" ); |
653 | } |
654 | |
655 | static inline JSC::EncodedJSValue jsFetchRequestPrototypeFunctionFormDataBody(JSC::ExecState* state, typename IDLOperationReturningPromise<JSFetchRequest>::ClassParameter castedThis, Ref<DeferredPromise>&& promise, JSC::ThrowScope& throwScope) |
656 | { |
657 | UNUSED_PARAM(state); |
658 | UNUSED_PARAM(throwScope); |
659 | auto& impl = castedThis->wrapped(); |
660 | impl.formData(WTFMove(promise)); |
661 | return JSValue::encode(jsUndefined()); |
662 | } |
663 | |
664 | EncodedJSValue JSC_HOST_CALL jsFetchRequestPrototypeFunctionFormData(ExecState* state) |
665 | { |
666 | return IDLOperationReturningPromise<JSFetchRequest>::call<jsFetchRequestPrototypeFunctionFormDataBody, PromiseExecutionScope::WindowOrWorker>(*state, "formData" ); |
667 | } |
668 | |
669 | static inline JSC::EncodedJSValue jsFetchRequestPrototypeFunctionJsonBody(JSC::ExecState* state, typename IDLOperationReturningPromise<JSFetchRequest>::ClassParameter castedThis, Ref<DeferredPromise>&& promise, JSC::ThrowScope& throwScope) |
670 | { |
671 | UNUSED_PARAM(state); |
672 | UNUSED_PARAM(throwScope); |
673 | auto& impl = castedThis->wrapped(); |
674 | impl.json(WTFMove(promise)); |
675 | return JSValue::encode(jsUndefined()); |
676 | } |
677 | |
678 | EncodedJSValue JSC_HOST_CALL jsFetchRequestPrototypeFunctionJson(ExecState* state) |
679 | { |
680 | return IDLOperationReturningPromise<JSFetchRequest>::call<jsFetchRequestPrototypeFunctionJsonBody, PromiseExecutionScope::WindowOrWorker>(*state, "json" ); |
681 | } |
682 | |
683 | static inline JSC::EncodedJSValue jsFetchRequestPrototypeFunctionTextBody(JSC::ExecState* state, typename IDLOperationReturningPromise<JSFetchRequest>::ClassParameter castedThis, Ref<DeferredPromise>&& promise, JSC::ThrowScope& throwScope) |
684 | { |
685 | UNUSED_PARAM(state); |
686 | UNUSED_PARAM(throwScope); |
687 | auto& impl = castedThis->wrapped(); |
688 | impl.text(WTFMove(promise)); |
689 | return JSValue::encode(jsUndefined()); |
690 | } |
691 | |
692 | EncodedJSValue JSC_HOST_CALL jsFetchRequestPrototypeFunctionText(ExecState* state) |
693 | { |
694 | return IDLOperationReturningPromise<JSFetchRequest>::call<jsFetchRequestPrototypeFunctionTextBody, PromiseExecutionScope::WindowOrWorker>(*state, "text" ); |
695 | } |
696 | |
697 | void JSFetchRequest::heapSnapshot(JSCell* cell, HeapSnapshotBuilder& builder) |
698 | { |
699 | auto* thisObject = jsCast<JSFetchRequest*>(cell); |
700 | builder.setWrappedObjectForCell(cell, &thisObject->wrapped()); |
701 | if (thisObject->scriptExecutionContext()) |
702 | builder.setLabelForCell(cell, "url " + thisObject->scriptExecutionContext()->url().string()); |
703 | Base::heapSnapshot(cell, builder); |
704 | } |
705 | |
706 | bool JSFetchRequestOwner::isReachableFromOpaqueRoots(JSC::Handle<JSC::Unknown> handle, void*, SlotVisitor& visitor, const char** reason) |
707 | { |
708 | auto* jsFetchRequest = jsCast<JSFetchRequest*>(handle.slot()->asCell()); |
709 | if (jsFetchRequest->wrapped().hasPendingActivity()) { |
710 | if (UNLIKELY(reason)) |
711 | *reason = "ActiveDOMObject with pending activity" ; |
712 | return true; |
713 | } |
714 | FetchRequest* root = &jsFetchRequest->wrapped(); |
715 | if (UNLIKELY(reason)) |
716 | *reason = "Reachable from FetchRequest" ; |
717 | return visitor.containsOpaqueRoot(root); |
718 | } |
719 | |
720 | void JSFetchRequestOwner::finalize(JSC::Handle<JSC::Unknown> handle, void* context) |
721 | { |
722 | auto* jsFetchRequest = static_cast<JSFetchRequest*>(handle.slot()->asCell()); |
723 | auto& world = *static_cast<DOMWrapperWorld*>(context); |
724 | uncacheWrapper(world, &jsFetchRequest->wrapped(), jsFetchRequest); |
725 | } |
726 | |
727 | #if ENABLE(BINDING_INTEGRITY) |
728 | #if PLATFORM(WIN) |
729 | #pragma warning(disable: 4483) |
730 | extern "C" { extern void (*const __identifier("??_7FetchRequest@WebCore@@6B@" )[])(); } |
731 | #else |
732 | extern "C" { extern void* _ZTVN7WebCore12FetchRequestE[]; } |
733 | #endif |
734 | #endif |
735 | |
736 | JSC::JSValue toJSNewlyCreated(JSC::ExecState*, JSDOMGlobalObject* globalObject, Ref<FetchRequest>&& impl) |
737 | { |
738 | |
739 | #if ENABLE(BINDING_INTEGRITY) |
740 | void* actualVTablePointer = *(reinterpret_cast<void**>(impl.ptr())); |
741 | #if PLATFORM(WIN) |
742 | void* expectedVTablePointer = WTF_PREPARE_VTBL_POINTER_FOR_INSPECTION(__identifier("??_7FetchRequest@WebCore@@6B@" )); |
743 | #else |
744 | void* expectedVTablePointer = WTF_PREPARE_VTBL_POINTER_FOR_INSPECTION(&_ZTVN7WebCore12FetchRequestE[2]); |
745 | #endif |
746 | |
747 | // If this fails FetchRequest does not have a vtable, so you need to add the |
748 | // ImplementationLacksVTable attribute to the interface definition |
749 | static_assert(std::is_polymorphic<FetchRequest>::value, "FetchRequest is not polymorphic" ); |
750 | |
751 | // If you hit this assertion you either have a use after free bug, or |
752 | // FetchRequest has subclasses. If FetchRequest has subclasses that get passed |
753 | // to toJS() we currently require FetchRequest you to opt out of binding hardening |
754 | // by adding the SkipVTableValidation attribute to the interface IDL definition |
755 | RELEASE_ASSERT(actualVTablePointer == expectedVTablePointer); |
756 | #endif |
757 | return createWrapper<FetchRequest>(globalObject, WTFMove(impl)); |
758 | } |
759 | |
760 | JSC::JSValue toJS(JSC::ExecState* state, JSDOMGlobalObject* globalObject, FetchRequest& impl) |
761 | { |
762 | return wrap(state, globalObject, impl); |
763 | } |
764 | |
765 | FetchRequest* JSFetchRequest::toWrapped(JSC::VM& vm, JSC::JSValue value) |
766 | { |
767 | if (auto* wrapper = jsDynamicCast<JSFetchRequest*>(vm, value)) |
768 | return &wrapper->wrapped(); |
769 | return nullptr; |
770 | } |
771 | |
772 | } |
773 | |