| 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 "JSDOMCache.h" |
| 23 | |
| 24 | #include "JSCacheQueryOptions.h" |
| 25 | #include "JSDOMBinding.h" |
| 26 | #include "JSDOMConstructorNotConstructable.h" |
| 27 | #include "JSDOMConvertDictionary.h" |
| 28 | #include "JSDOMConvertInterface.h" |
| 29 | #include "JSDOMConvertSequences.h" |
| 30 | #include "JSDOMConvertStrings.h" |
| 31 | #include "JSDOMConvertUnion.h" |
| 32 | #include "JSDOMExceptionHandling.h" |
| 33 | #include "JSDOMOperation.h" |
| 34 | #include "JSDOMOperationReturningPromise.h" |
| 35 | #include "JSDOMWrapperCache.h" |
| 36 | #include "JSFetchRequest.h" |
| 37 | #include "JSFetchResponse.h" |
| 38 | #include "ScriptExecutionContext.h" |
| 39 | #include <JavaScriptCore/FunctionPrototype.h> |
| 40 | #include <JavaScriptCore/HeapSnapshotBuilder.h> |
| 41 | #include <JavaScriptCore/JSArray.h> |
| 42 | #include <JavaScriptCore/JSCInlines.h> |
| 43 | #include <wtf/GetPtr.h> |
| 44 | #include <wtf/PointerPreparations.h> |
| 45 | #include <wtf/URL.h> |
| 46 | #include <wtf/Variant.h> |
| 47 | |
| 48 | |
| 49 | namespace WebCore { |
| 50 | using namespace JSC; |
| 51 | |
| 52 | // Functions |
| 53 | |
| 54 | JSC::EncodedJSValue JSC_HOST_CALL jsDOMCachePrototypeFunctionMatch(JSC::ExecState*); |
| 55 | JSC::EncodedJSValue JSC_HOST_CALL jsDOMCachePrototypeFunctionMatchAll(JSC::ExecState*); |
| 56 | JSC::EncodedJSValue JSC_HOST_CALL jsDOMCachePrototypeFunctionAdd(JSC::ExecState*); |
| 57 | JSC::EncodedJSValue JSC_HOST_CALL jsDOMCachePrototypeFunctionAddAll(JSC::ExecState*); |
| 58 | JSC::EncodedJSValue JSC_HOST_CALL jsDOMCachePrototypeFunctionPut(JSC::ExecState*); |
| 59 | JSC::EncodedJSValue JSC_HOST_CALL jsDOMCachePrototypeFunctionDelete(JSC::ExecState*); |
| 60 | JSC::EncodedJSValue JSC_HOST_CALL jsDOMCachePrototypeFunctionKeys(JSC::ExecState*); |
| 61 | |
| 62 | // Attributes |
| 63 | |
| 64 | JSC::EncodedJSValue jsDOMCacheConstructor(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
| 65 | bool setJSDOMCacheConstructor(JSC::ExecState*, JSC::EncodedJSValue, JSC::EncodedJSValue); |
| 66 | |
| 67 | class JSDOMCachePrototype : public JSC::JSNonFinalObject { |
| 68 | public: |
| 69 | using Base = JSC::JSNonFinalObject; |
| 70 | static JSDOMCachePrototype* create(JSC::VM& vm, JSDOMGlobalObject* globalObject, JSC::Structure* structure) |
| 71 | { |
| 72 | JSDOMCachePrototype* ptr = new (NotNull, JSC::allocateCell<JSDOMCachePrototype>(vm.heap)) JSDOMCachePrototype(vm, globalObject, structure); |
| 73 | ptr->finishCreation(vm); |
| 74 | return ptr; |
| 75 | } |
| 76 | |
| 77 | DECLARE_INFO; |
| 78 | static JSC::Structure* createStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype) |
| 79 | { |
| 80 | return JSC::Structure::create(vm, globalObject, prototype, JSC::TypeInfo(JSC::ObjectType, StructureFlags), info()); |
| 81 | } |
| 82 | |
| 83 | private: |
| 84 | JSDOMCachePrototype(JSC::VM& vm, JSC::JSGlobalObject*, JSC::Structure* structure) |
| 85 | : JSC::JSNonFinalObject(vm, structure) |
| 86 | { |
| 87 | } |
| 88 | |
| 89 | void finishCreation(JSC::VM&); |
| 90 | }; |
| 91 | |
| 92 | using JSDOMCacheConstructor = JSDOMConstructorNotConstructable<JSDOMCache>; |
| 93 | |
| 94 | template<> JSValue JSDOMCacheConstructor::prototypeForStructure(JSC::VM& vm, const JSDOMGlobalObject& globalObject) |
| 95 | { |
| 96 | UNUSED_PARAM(vm); |
| 97 | return globalObject.functionPrototype(); |
| 98 | } |
| 99 | |
| 100 | template<> void JSDOMCacheConstructor::initializeProperties(VM& vm, JSDOMGlobalObject& globalObject) |
| 101 | { |
| 102 | putDirect(vm, vm.propertyNames->prototype, JSDOMCache::prototype(vm, globalObject), JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum); |
| 103 | putDirect(vm, vm.propertyNames->name, jsNontrivialString(&vm, String("Cache"_s )), JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum); |
| 104 | putDirect(vm, vm.propertyNames->length, jsNumber(0), JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum); |
| 105 | } |
| 106 | |
| 107 | template<> const ClassInfo JSDOMCacheConstructor::s_info = { "Cache" , &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSDOMCacheConstructor) }; |
| 108 | |
| 109 | /* Hash table for prototype */ |
| 110 | |
| 111 | static const HashTableValue JSDOMCachePrototypeTableValues[] = |
| 112 | { |
| 113 | { "constructor" , static_cast<unsigned>(JSC::PropertyAttribute::DontEnum), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsDOMCacheConstructor), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(setJSDOMCacheConstructor) } }, |
| 114 | { "match" , static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t)static_cast<RawNativeFunction>(jsDOMCachePrototypeFunctionMatch), (intptr_t) (1) } }, |
| 115 | { "matchAll" , static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t)static_cast<RawNativeFunction>(jsDOMCachePrototypeFunctionMatchAll), (intptr_t) (0) } }, |
| 116 | { "add" , static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t)static_cast<RawNativeFunction>(jsDOMCachePrototypeFunctionAdd), (intptr_t) (1) } }, |
| 117 | { "addAll" , static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t)static_cast<RawNativeFunction>(jsDOMCachePrototypeFunctionAddAll), (intptr_t) (1) } }, |
| 118 | { "put" , static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t)static_cast<RawNativeFunction>(jsDOMCachePrototypeFunctionPut), (intptr_t) (2) } }, |
| 119 | { "delete" , static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t)static_cast<RawNativeFunction>(jsDOMCachePrototypeFunctionDelete), (intptr_t) (1) } }, |
| 120 | { "keys" , static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t)static_cast<RawNativeFunction>(jsDOMCachePrototypeFunctionKeys), (intptr_t) (0) } }, |
| 121 | }; |
| 122 | |
| 123 | const ClassInfo JSDOMCachePrototype::s_info = { "CachePrototype" , &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSDOMCachePrototype) }; |
| 124 | |
| 125 | void JSDOMCachePrototype::finishCreation(VM& vm) |
| 126 | { |
| 127 | Base::finishCreation(vm); |
| 128 | reifyStaticProperties(vm, JSDOMCache::info(), JSDOMCachePrototypeTableValues, *this); |
| 129 | } |
| 130 | |
| 131 | const ClassInfo JSDOMCache::s_info = { "Cache" , &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSDOMCache) }; |
| 132 | |
| 133 | JSDOMCache::JSDOMCache(Structure* structure, JSDOMGlobalObject& globalObject, Ref<DOMCache>&& impl) |
| 134 | : JSDOMWrapper<DOMCache>(structure, globalObject, WTFMove(impl)) |
| 135 | { |
| 136 | } |
| 137 | |
| 138 | void JSDOMCache::finishCreation(VM& vm) |
| 139 | { |
| 140 | Base::finishCreation(vm); |
| 141 | ASSERT(inherits(vm, info())); |
| 142 | |
| 143 | } |
| 144 | |
| 145 | JSObject* JSDOMCache::createPrototype(VM& vm, JSDOMGlobalObject& globalObject) |
| 146 | { |
| 147 | return JSDOMCachePrototype::create(vm, &globalObject, JSDOMCachePrototype::createStructure(vm, &globalObject, globalObject.objectPrototype())); |
| 148 | } |
| 149 | |
| 150 | JSObject* JSDOMCache::prototype(VM& vm, JSDOMGlobalObject& globalObject) |
| 151 | { |
| 152 | return getDOMPrototype<JSDOMCache>(vm, globalObject); |
| 153 | } |
| 154 | |
| 155 | JSValue JSDOMCache::getConstructor(VM& vm, const JSGlobalObject* globalObject) |
| 156 | { |
| 157 | return getDOMConstructor<JSDOMCacheConstructor>(vm, *jsCast<const JSDOMGlobalObject*>(globalObject)); |
| 158 | } |
| 159 | |
| 160 | void JSDOMCache::destroy(JSC::JSCell* cell) |
| 161 | { |
| 162 | JSDOMCache* thisObject = static_cast<JSDOMCache*>(cell); |
| 163 | thisObject->JSDOMCache::~JSDOMCache(); |
| 164 | } |
| 165 | |
| 166 | template<> inline JSDOMCache* IDLOperation<JSDOMCache>::cast(ExecState& state) |
| 167 | { |
| 168 | return jsDynamicCast<JSDOMCache*>(state.vm(), state.thisValue()); |
| 169 | } |
| 170 | |
| 171 | EncodedJSValue jsDOMCacheConstructor(ExecState* state, EncodedJSValue thisValue, PropertyName) |
| 172 | { |
| 173 | VM& vm = state->vm(); |
| 174 | auto throwScope = DECLARE_THROW_SCOPE(vm); |
| 175 | auto* prototype = jsDynamicCast<JSDOMCachePrototype*>(vm, JSValue::decode(thisValue)); |
| 176 | if (UNLIKELY(!prototype)) |
| 177 | return throwVMTypeError(state, throwScope); |
| 178 | return JSValue::encode(JSDOMCache::getConstructor(state->vm(), prototype->globalObject())); |
| 179 | } |
| 180 | |
| 181 | bool setJSDOMCacheConstructor(ExecState* state, EncodedJSValue thisValue, EncodedJSValue encodedValue) |
| 182 | { |
| 183 | VM& vm = state->vm(); |
| 184 | auto throwScope = DECLARE_THROW_SCOPE(vm); |
| 185 | auto* prototype = jsDynamicCast<JSDOMCachePrototype*>(vm, JSValue::decode(thisValue)); |
| 186 | if (UNLIKELY(!prototype)) { |
| 187 | throwVMTypeError(state, throwScope); |
| 188 | return false; |
| 189 | } |
| 190 | // Shadowing a built-in constructor |
| 191 | return prototype->putDirect(vm, vm.propertyNames->constructor, JSValue::decode(encodedValue)); |
| 192 | } |
| 193 | |
| 194 | static inline JSC::EncodedJSValue jsDOMCachePrototypeFunctionMatchBody(JSC::ExecState* state, typename IDLOperationReturningPromise<JSDOMCache>::ClassParameter castedThis, Ref<DeferredPromise>&& promise, JSC::ThrowScope& throwScope) |
| 195 | { |
| 196 | UNUSED_PARAM(state); |
| 197 | UNUSED_PARAM(throwScope); |
| 198 | auto& impl = castedThis->wrapped(); |
| 199 | if (UNLIKELY(state->argumentCount() < 1)) |
| 200 | return throwVMError(state, throwScope, createNotEnoughArgumentsError(state)); |
| 201 | auto request = convert<IDLUnion<IDLInterface<FetchRequest>, IDLUSVString>>(*state, state->uncheckedArgument(0)); |
| 202 | RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); |
| 203 | auto options = convert<IDLDictionary<CacheQueryOptions>>(*state, state->argument(1)); |
| 204 | RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); |
| 205 | impl.match(WTFMove(request), WTFMove(options), WTFMove(promise)); |
| 206 | return JSValue::encode(jsUndefined()); |
| 207 | } |
| 208 | |
| 209 | EncodedJSValue JSC_HOST_CALL jsDOMCachePrototypeFunctionMatch(ExecState* state) |
| 210 | { |
| 211 | return IDLOperationReturningPromise<JSDOMCache>::call<jsDOMCachePrototypeFunctionMatchBody, PromiseExecutionScope::WindowOrWorker>(*state, "match" ); |
| 212 | } |
| 213 | |
| 214 | static inline JSC::EncodedJSValue jsDOMCachePrototypeFunctionMatchAllBody(JSC::ExecState* state, typename IDLOperationReturningPromise<JSDOMCache>::ClassParameter castedThis, Ref<DeferredPromise>&& promise, JSC::ThrowScope& throwScope) |
| 215 | { |
| 216 | UNUSED_PARAM(state); |
| 217 | UNUSED_PARAM(throwScope); |
| 218 | auto& impl = castedThis->wrapped(); |
| 219 | auto request = state->argument(0).isUndefined() ? Optional<Converter<IDLUnion<IDLInterface<FetchRequest>, IDLUSVString>>::ReturnType>() : Optional<Converter<IDLUnion<IDLInterface<FetchRequest>, IDLUSVString>>::ReturnType>(convert<IDLUnion<IDLInterface<FetchRequest>, IDLUSVString>>(*state, state->uncheckedArgument(0))); |
| 220 | RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); |
| 221 | auto options = convert<IDLDictionary<CacheQueryOptions>>(*state, state->argument(1)); |
| 222 | RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); |
| 223 | impl.matchAll(WTFMove(request), WTFMove(options), WTFMove(promise)); |
| 224 | return JSValue::encode(jsUndefined()); |
| 225 | } |
| 226 | |
| 227 | EncodedJSValue JSC_HOST_CALL jsDOMCachePrototypeFunctionMatchAll(ExecState* state) |
| 228 | { |
| 229 | return IDLOperationReturningPromise<JSDOMCache>::call<jsDOMCachePrototypeFunctionMatchAllBody, PromiseExecutionScope::WindowOrWorker>(*state, "matchAll" ); |
| 230 | } |
| 231 | |
| 232 | static inline JSC::EncodedJSValue jsDOMCachePrototypeFunctionAddBody(JSC::ExecState* state, typename IDLOperationReturningPromise<JSDOMCache>::ClassParameter castedThis, Ref<DeferredPromise>&& promise, JSC::ThrowScope& throwScope) |
| 233 | { |
| 234 | UNUSED_PARAM(state); |
| 235 | UNUSED_PARAM(throwScope); |
| 236 | auto& impl = castedThis->wrapped(); |
| 237 | if (UNLIKELY(state->argumentCount() < 1)) |
| 238 | return throwVMError(state, throwScope, createNotEnoughArgumentsError(state)); |
| 239 | auto request = convert<IDLUnion<IDLInterface<FetchRequest>, IDLUSVString>>(*state, state->uncheckedArgument(0)); |
| 240 | RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); |
| 241 | impl.add(WTFMove(request), WTFMove(promise)); |
| 242 | return JSValue::encode(jsUndefined()); |
| 243 | } |
| 244 | |
| 245 | EncodedJSValue JSC_HOST_CALL jsDOMCachePrototypeFunctionAdd(ExecState* state) |
| 246 | { |
| 247 | return IDLOperationReturningPromise<JSDOMCache>::call<jsDOMCachePrototypeFunctionAddBody, PromiseExecutionScope::WindowOrWorker>(*state, "add" ); |
| 248 | } |
| 249 | |
| 250 | static inline JSC::EncodedJSValue jsDOMCachePrototypeFunctionAddAllBody(JSC::ExecState* state, typename IDLOperationReturningPromise<JSDOMCache>::ClassParameter castedThis, Ref<DeferredPromise>&& promise, JSC::ThrowScope& throwScope) |
| 251 | { |
| 252 | UNUSED_PARAM(state); |
| 253 | UNUSED_PARAM(throwScope); |
| 254 | auto& impl = castedThis->wrapped(); |
| 255 | if (UNLIKELY(state->argumentCount() < 1)) |
| 256 | return throwVMError(state, throwScope, createNotEnoughArgumentsError(state)); |
| 257 | auto requests = convert<IDLSequence<IDLUnion<IDLInterface<FetchRequest>, IDLUSVString>>>(*state, state->uncheckedArgument(0)); |
| 258 | RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); |
| 259 | impl.addAll(WTFMove(requests), WTFMove(promise)); |
| 260 | return JSValue::encode(jsUndefined()); |
| 261 | } |
| 262 | |
| 263 | EncodedJSValue JSC_HOST_CALL jsDOMCachePrototypeFunctionAddAll(ExecState* state) |
| 264 | { |
| 265 | return IDLOperationReturningPromise<JSDOMCache>::call<jsDOMCachePrototypeFunctionAddAllBody, PromiseExecutionScope::WindowOrWorker>(*state, "addAll" ); |
| 266 | } |
| 267 | |
| 268 | static inline JSC::EncodedJSValue jsDOMCachePrototypeFunctionPutBody(JSC::ExecState* state, typename IDLOperationReturningPromise<JSDOMCache>::ClassParameter castedThis, Ref<DeferredPromise>&& promise, JSC::ThrowScope& throwScope) |
| 269 | { |
| 270 | UNUSED_PARAM(state); |
| 271 | UNUSED_PARAM(throwScope); |
| 272 | auto& impl = castedThis->wrapped(); |
| 273 | if (UNLIKELY(state->argumentCount() < 2)) |
| 274 | return throwVMError(state, throwScope, createNotEnoughArgumentsError(state)); |
| 275 | auto request = convert<IDLUnion<IDLInterface<FetchRequest>, IDLUSVString>>(*state, state->uncheckedArgument(0)); |
| 276 | RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); |
| 277 | auto response = convert<IDLInterface<FetchResponse>>(*state, state->uncheckedArgument(1), [](JSC::ExecState& state, JSC::ThrowScope& scope) { throwArgumentTypeError(state, scope, 1, "response" , "Cache" , "put" , "FetchResponse" ); }); |
| 278 | RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); |
| 279 | impl.put(WTFMove(request), *response, WTFMove(promise)); |
| 280 | return JSValue::encode(jsUndefined()); |
| 281 | } |
| 282 | |
| 283 | EncodedJSValue JSC_HOST_CALL jsDOMCachePrototypeFunctionPut(ExecState* state) |
| 284 | { |
| 285 | return IDLOperationReturningPromise<JSDOMCache>::call<jsDOMCachePrototypeFunctionPutBody, PromiseExecutionScope::WindowOrWorker>(*state, "put" ); |
| 286 | } |
| 287 | |
| 288 | static inline JSC::EncodedJSValue jsDOMCachePrototypeFunctionDeleteBody(JSC::ExecState* state, typename IDLOperationReturningPromise<JSDOMCache>::ClassParameter castedThis, Ref<DeferredPromise>&& promise, JSC::ThrowScope& throwScope) |
| 289 | { |
| 290 | UNUSED_PARAM(state); |
| 291 | UNUSED_PARAM(throwScope); |
| 292 | auto& impl = castedThis->wrapped(); |
| 293 | if (UNLIKELY(state->argumentCount() < 1)) |
| 294 | return throwVMError(state, throwScope, createNotEnoughArgumentsError(state)); |
| 295 | auto request = convert<IDLUnion<IDLInterface<FetchRequest>, IDLUSVString>>(*state, state->uncheckedArgument(0)); |
| 296 | RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); |
| 297 | auto options = convert<IDLDictionary<CacheQueryOptions>>(*state, state->argument(1)); |
| 298 | RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); |
| 299 | impl.remove(WTFMove(request), WTFMove(options), WTFMove(promise)); |
| 300 | return JSValue::encode(jsUndefined()); |
| 301 | } |
| 302 | |
| 303 | EncodedJSValue JSC_HOST_CALL jsDOMCachePrototypeFunctionDelete(ExecState* state) |
| 304 | { |
| 305 | return IDLOperationReturningPromise<JSDOMCache>::call<jsDOMCachePrototypeFunctionDeleteBody, PromiseExecutionScope::WindowOrWorker>(*state, "delete" ); |
| 306 | } |
| 307 | |
| 308 | static inline JSC::EncodedJSValue jsDOMCachePrototypeFunctionKeysBody(JSC::ExecState* state, typename IDLOperationReturningPromise<JSDOMCache>::ClassParameter castedThis, Ref<DeferredPromise>&& promise, JSC::ThrowScope& throwScope) |
| 309 | { |
| 310 | UNUSED_PARAM(state); |
| 311 | UNUSED_PARAM(throwScope); |
| 312 | auto& impl = castedThis->wrapped(); |
| 313 | auto request = state->argument(0).isUndefined() ? Optional<Converter<IDLUnion<IDLInterface<FetchRequest>, IDLUSVString>>::ReturnType>() : Optional<Converter<IDLUnion<IDLInterface<FetchRequest>, IDLUSVString>>::ReturnType>(convert<IDLUnion<IDLInterface<FetchRequest>, IDLUSVString>>(*state, state->uncheckedArgument(0))); |
| 314 | RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); |
| 315 | auto options = convert<IDLDictionary<CacheQueryOptions>>(*state, state->argument(1)); |
| 316 | RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); |
| 317 | impl.keys(WTFMove(request), WTFMove(options), WTFMove(promise)); |
| 318 | return JSValue::encode(jsUndefined()); |
| 319 | } |
| 320 | |
| 321 | EncodedJSValue JSC_HOST_CALL jsDOMCachePrototypeFunctionKeys(ExecState* state) |
| 322 | { |
| 323 | return IDLOperationReturningPromise<JSDOMCache>::call<jsDOMCachePrototypeFunctionKeysBody, PromiseExecutionScope::WindowOrWorker>(*state, "keys" ); |
| 324 | } |
| 325 | |
| 326 | void JSDOMCache::heapSnapshot(JSCell* cell, HeapSnapshotBuilder& builder) |
| 327 | { |
| 328 | auto* thisObject = jsCast<JSDOMCache*>(cell); |
| 329 | builder.setWrappedObjectForCell(cell, &thisObject->wrapped()); |
| 330 | if (thisObject->scriptExecutionContext()) |
| 331 | builder.setLabelForCell(cell, "url " + thisObject->scriptExecutionContext()->url().string()); |
| 332 | Base::heapSnapshot(cell, builder); |
| 333 | } |
| 334 | |
| 335 | bool JSDOMCacheOwner::isReachableFromOpaqueRoots(JSC::Handle<JSC::Unknown> handle, void*, SlotVisitor& visitor, const char** reason) |
| 336 | { |
| 337 | UNUSED_PARAM(handle); |
| 338 | UNUSED_PARAM(visitor); |
| 339 | UNUSED_PARAM(reason); |
| 340 | return false; |
| 341 | } |
| 342 | |
| 343 | void JSDOMCacheOwner::finalize(JSC::Handle<JSC::Unknown> handle, void* context) |
| 344 | { |
| 345 | auto* jsDOMCache = static_cast<JSDOMCache*>(handle.slot()->asCell()); |
| 346 | auto& world = *static_cast<DOMWrapperWorld*>(context); |
| 347 | uncacheWrapper(world, &jsDOMCache->wrapped(), jsDOMCache); |
| 348 | } |
| 349 | |
| 350 | #if ENABLE(BINDING_INTEGRITY) |
| 351 | #if PLATFORM(WIN) |
| 352 | #pragma warning(disable: 4483) |
| 353 | extern "C" { extern void (*const __identifier("??_7DOMCache@WebCore@@6B@" )[])(); } |
| 354 | #else |
| 355 | extern "C" { extern void* _ZTVN7WebCore8DOMCacheE[]; } |
| 356 | #endif |
| 357 | #endif |
| 358 | |
| 359 | JSC::JSValue toJSNewlyCreated(JSC::ExecState*, JSDOMGlobalObject* globalObject, Ref<DOMCache>&& impl) |
| 360 | { |
| 361 | |
| 362 | #if ENABLE(BINDING_INTEGRITY) |
| 363 | void* actualVTablePointer = *(reinterpret_cast<void**>(impl.ptr())); |
| 364 | #if PLATFORM(WIN) |
| 365 | void* expectedVTablePointer = WTF_PREPARE_VTBL_POINTER_FOR_INSPECTION(__identifier("??_7DOMCache@WebCore@@6B@" )); |
| 366 | #else |
| 367 | void* expectedVTablePointer = WTF_PREPARE_VTBL_POINTER_FOR_INSPECTION(&_ZTVN7WebCore8DOMCacheE[2]); |
| 368 | #endif |
| 369 | |
| 370 | // If this fails DOMCache does not have a vtable, so you need to add the |
| 371 | // ImplementationLacksVTable attribute to the interface definition |
| 372 | static_assert(std::is_polymorphic<DOMCache>::value, "DOMCache is not polymorphic" ); |
| 373 | |
| 374 | // If you hit this assertion you either have a use after free bug, or |
| 375 | // DOMCache has subclasses. If DOMCache has subclasses that get passed |
| 376 | // to toJS() we currently require DOMCache you to opt out of binding hardening |
| 377 | // by adding the SkipVTableValidation attribute to the interface IDL definition |
| 378 | RELEASE_ASSERT(actualVTablePointer == expectedVTablePointer); |
| 379 | #endif |
| 380 | return createWrapper<DOMCache>(globalObject, WTFMove(impl)); |
| 381 | } |
| 382 | |
| 383 | JSC::JSValue toJS(JSC::ExecState* state, JSDOMGlobalObject* globalObject, DOMCache& impl) |
| 384 | { |
| 385 | return wrap(state, globalObject, impl); |
| 386 | } |
| 387 | |
| 388 | DOMCache* JSDOMCache::toWrapped(JSC::VM& vm, JSC::JSValue value) |
| 389 | { |
| 390 | if (auto* wrapper = jsDynamicCast<JSDOMCache*>(vm, value)) |
| 391 | return &wrapper->wrapped(); |
| 392 | return nullptr; |
| 393 | } |
| 394 | |
| 395 | } |
| 396 | |