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