| 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 "JSServiceWorkerGlobalScope.h" |
| 26 | |
| 27 | #include "EventNames.h" |
| 28 | #include "JSDOMAttribute.h" |
| 29 | #include "JSDOMBinding.h" |
| 30 | #include "JSDOMConstructorNotConstructable.h" |
| 31 | #include "JSDOMConvertInterface.h" |
| 32 | #include "JSDOMExceptionHandling.h" |
| 33 | #include "JSDOMGlobalObject.h" |
| 34 | #include "JSDOMOperation.h" |
| 35 | #include "JSDOMOperationReturningPromise.h" |
| 36 | #include "JSDOMWrapperCache.h" |
| 37 | #include "JSEventListener.h" |
| 38 | #include "JSServiceWorkerClients.h" |
| 39 | #include "JSServiceWorkerRegistration.h" |
| 40 | #include "RuntimeEnabledFeatures.h" |
| 41 | #include "ScriptExecutionContext.h" |
| 42 | #include "ServiceWorkerGlobalScope.h" |
| 43 | #include "WebCoreJSClientData.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 | #if ENABLE(SERVICE_WORKER) |
| 51 | #include "JSExtendableEvent.h" |
| 52 | #include "JSExtendableMessageEvent.h" |
| 53 | #include "JSFetchEvent.h" |
| 54 | #include "JSServiceWorker.h" |
| 55 | #include "JSServiceWorkerClient.h" |
| 56 | #include "JSServiceWorkerContainer.h" |
| 57 | #include "JSServiceWorkerGlobalScope.h" |
| 58 | #include "JSServiceWorkerWindowClient.h" |
| 59 | #endif |
| 60 | |
| 61 | |
| 62 | namespace WebCore { |
| 63 | using namespace JSC; |
| 64 | |
| 65 | // Functions |
| 66 | |
| 67 | JSC::EncodedJSValue JSC_HOST_CALL jsServiceWorkerGlobalScopeInstanceFunctionSkipWaiting(JSC::ExecState*); |
| 68 | |
| 69 | // Attributes |
| 70 | |
| 71 | JSC::EncodedJSValue jsServiceWorkerGlobalScopeConstructor(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
| 72 | bool setJSServiceWorkerGlobalScopeConstructor(JSC::ExecState*, JSC::EncodedJSValue, JSC::EncodedJSValue); |
| 73 | JSC::EncodedJSValue jsServiceWorkerGlobalScopeClients(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
| 74 | JSC::EncodedJSValue jsServiceWorkerGlobalScopeRegistration(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
| 75 | JSC::EncodedJSValue jsServiceWorkerGlobalScopeOninstall(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
| 76 | bool setJSServiceWorkerGlobalScopeOninstall(JSC::ExecState*, JSC::EncodedJSValue, JSC::EncodedJSValue); |
| 77 | JSC::EncodedJSValue jsServiceWorkerGlobalScopeOnactivate(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
| 78 | bool setJSServiceWorkerGlobalScopeOnactivate(JSC::ExecState*, JSC::EncodedJSValue, JSC::EncodedJSValue); |
| 79 | JSC::EncodedJSValue jsServiceWorkerGlobalScopeOnfetch(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
| 80 | bool setJSServiceWorkerGlobalScopeOnfetch(JSC::ExecState*, JSC::EncodedJSValue, JSC::EncodedJSValue); |
| 81 | JSC::EncodedJSValue jsServiceWorkerGlobalScopeOnmessage(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
| 82 | bool setJSServiceWorkerGlobalScopeOnmessage(JSC::ExecState*, JSC::EncodedJSValue, JSC::EncodedJSValue); |
| 83 | JSC::EncodedJSValue jsServiceWorkerGlobalScopeOnmessageerror(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
| 84 | bool setJSServiceWorkerGlobalScopeOnmessageerror(JSC::ExecState*, JSC::EncodedJSValue, JSC::EncodedJSValue); |
| 85 | #if ENABLE(SERVICE_WORKER) |
| 86 | JSC::EncodedJSValue jsServiceWorkerGlobalScopeExtendableEventConstructor(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
| 87 | bool setJSServiceWorkerGlobalScopeExtendableEventConstructor(JSC::ExecState*, JSC::EncodedJSValue, JSC::EncodedJSValue); |
| 88 | #endif |
| 89 | #if ENABLE(SERVICE_WORKER) |
| 90 | JSC::EncodedJSValue jsServiceWorkerGlobalScopeExtendableMessageEventConstructor(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
| 91 | bool setJSServiceWorkerGlobalScopeExtendableMessageEventConstructor(JSC::ExecState*, JSC::EncodedJSValue, JSC::EncodedJSValue); |
| 92 | #endif |
| 93 | #if ENABLE(SERVICE_WORKER) |
| 94 | JSC::EncodedJSValue jsServiceWorkerGlobalScopeFetchEventConstructor(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
| 95 | bool setJSServiceWorkerGlobalScopeFetchEventConstructor(JSC::ExecState*, JSC::EncodedJSValue, JSC::EncodedJSValue); |
| 96 | #endif |
| 97 | #if ENABLE(SERVICE_WORKER) |
| 98 | JSC::EncodedJSValue jsServiceWorkerGlobalScopeServiceWorkerConstructor(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
| 99 | bool setJSServiceWorkerGlobalScopeServiceWorkerConstructor(JSC::ExecState*, JSC::EncodedJSValue, JSC::EncodedJSValue); |
| 100 | #endif |
| 101 | #if ENABLE(SERVICE_WORKER) |
| 102 | JSC::EncodedJSValue jsServiceWorkerGlobalScopeClientConstructor(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
| 103 | bool setJSServiceWorkerGlobalScopeClientConstructor(JSC::ExecState*, JSC::EncodedJSValue, JSC::EncodedJSValue); |
| 104 | #endif |
| 105 | #if ENABLE(SERVICE_WORKER) |
| 106 | JSC::EncodedJSValue jsServiceWorkerGlobalScopeClientsConstructor(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
| 107 | bool setJSServiceWorkerGlobalScopeClientsConstructor(JSC::ExecState*, JSC::EncodedJSValue, JSC::EncodedJSValue); |
| 108 | #endif |
| 109 | #if ENABLE(SERVICE_WORKER) |
| 110 | JSC::EncodedJSValue jsServiceWorkerGlobalScopeServiceWorkerContainerConstructor(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
| 111 | bool setJSServiceWorkerGlobalScopeServiceWorkerContainerConstructor(JSC::ExecState*, JSC::EncodedJSValue, JSC::EncodedJSValue); |
| 112 | #endif |
| 113 | #if ENABLE(SERVICE_WORKER) |
| 114 | JSC::EncodedJSValue jsServiceWorkerGlobalScopeServiceWorkerGlobalScopeConstructor(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
| 115 | bool setJSServiceWorkerGlobalScopeServiceWorkerGlobalScopeConstructor(JSC::ExecState*, JSC::EncodedJSValue, JSC::EncodedJSValue); |
| 116 | #endif |
| 117 | #if ENABLE(SERVICE_WORKER) |
| 118 | JSC::EncodedJSValue jsServiceWorkerGlobalScopeServiceWorkerRegistrationConstructor(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
| 119 | bool setJSServiceWorkerGlobalScopeServiceWorkerRegistrationConstructor(JSC::ExecState*, JSC::EncodedJSValue, JSC::EncodedJSValue); |
| 120 | #endif |
| 121 | #if ENABLE(SERVICE_WORKER) |
| 122 | JSC::EncodedJSValue jsServiceWorkerGlobalScopeWindowClientConstructor(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
| 123 | bool setJSServiceWorkerGlobalScopeWindowClientConstructor(JSC::ExecState*, JSC::EncodedJSValue, JSC::EncodedJSValue); |
| 124 | #endif |
| 125 | |
| 126 | using JSServiceWorkerGlobalScopeConstructor = JSDOMConstructorNotConstructable<JSServiceWorkerGlobalScope>; |
| 127 | |
| 128 | /* Hash table */ |
| 129 | |
| 130 | static const struct CompactHashIndex JSServiceWorkerGlobalScopeTableIndex[17] = { |
| 131 | { -1, -1 }, |
| 132 | { -1, -1 }, |
| 133 | { -1, -1 }, |
| 134 | { 6, -1 }, |
| 135 | { 5, -1 }, |
| 136 | { 1, -1 }, |
| 137 | { -1, -1 }, |
| 138 | { 0, 16 }, |
| 139 | { 3, -1 }, |
| 140 | { -1, -1 }, |
| 141 | { -1, -1 }, |
| 142 | { 7, -1 }, |
| 143 | { 2, -1 }, |
| 144 | { -1, -1 }, |
| 145 | { -1, -1 }, |
| 146 | { -1, -1 }, |
| 147 | { 4, -1 }, |
| 148 | }; |
| 149 | |
| 150 | |
| 151 | static const HashTableValue JSServiceWorkerGlobalScopeTableValues[] = |
| 152 | { |
| 153 | { "clients" , static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsServiceWorkerGlobalScopeClients), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } }, |
| 154 | { "registration" , static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsServiceWorkerGlobalScopeRegistration), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } }, |
| 155 | { "oninstall" , static_cast<unsigned>(JSC::PropertyAttribute::CustomAccessor), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsServiceWorkerGlobalScopeOninstall), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(setJSServiceWorkerGlobalScopeOninstall) } }, |
| 156 | { "onactivate" , static_cast<unsigned>(JSC::PropertyAttribute::CustomAccessor), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsServiceWorkerGlobalScopeOnactivate), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(setJSServiceWorkerGlobalScopeOnactivate) } }, |
| 157 | { "onfetch" , static_cast<unsigned>(JSC::PropertyAttribute::CustomAccessor), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsServiceWorkerGlobalScopeOnfetch), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(setJSServiceWorkerGlobalScopeOnfetch) } }, |
| 158 | { "onmessage" , static_cast<unsigned>(JSC::PropertyAttribute::CustomAccessor), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsServiceWorkerGlobalScopeOnmessage), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(setJSServiceWorkerGlobalScopeOnmessage) } }, |
| 159 | { "onmessageerror" , static_cast<unsigned>(JSC::PropertyAttribute::CustomAccessor), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsServiceWorkerGlobalScopeOnmessageerror), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(setJSServiceWorkerGlobalScopeOnmessageerror) } }, |
| 160 | { "skipWaiting" , static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t)static_cast<RawNativeFunction>(jsServiceWorkerGlobalScopeInstanceFunctionSkipWaiting), (intptr_t) (0) } }, |
| 161 | }; |
| 162 | |
| 163 | static const HashTable JSServiceWorkerGlobalScopeTable = { 8, 15, true, JSServiceWorkerGlobalScope::info(), JSServiceWorkerGlobalScopeTableValues, JSServiceWorkerGlobalScopeTableIndex }; |
| 164 | template<> JSValue JSServiceWorkerGlobalScopeConstructor::prototypeForStructure(JSC::VM& vm, const JSDOMGlobalObject& globalObject) |
| 165 | { |
| 166 | return JSWorkerGlobalScope::getConstructor(vm, &globalObject); |
| 167 | } |
| 168 | |
| 169 | template<> void JSServiceWorkerGlobalScopeConstructor::initializeProperties(VM& vm, JSDOMGlobalObject& globalObject) |
| 170 | { |
| 171 | putDirect(vm, vm.propertyNames->prototype, globalObject.getPrototypeDirect(vm), JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum); |
| 172 | putDirect(vm, vm.propertyNames->name, jsNontrivialString(&vm, String("ServiceWorkerGlobalScope"_s )), JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum); |
| 173 | putDirect(vm, vm.propertyNames->length, jsNumber(0), JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum); |
| 174 | } |
| 175 | |
| 176 | template<> const ClassInfo JSServiceWorkerGlobalScopeConstructor::s_info = { "ServiceWorkerGlobalScope" , &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSServiceWorkerGlobalScopeConstructor) }; |
| 177 | |
| 178 | /* Hash table for prototype */ |
| 179 | |
| 180 | static const struct CompactHashIndex JSServiceWorkerGlobalScopePrototypeTableIndex[2] = { |
| 181 | { -1, -1 }, |
| 182 | { 0, -1 }, |
| 183 | }; |
| 184 | |
| 185 | |
| 186 | static const HashTableValue JSServiceWorkerGlobalScopePrototypeTableValues[] = |
| 187 | { |
| 188 | { "constructor" , static_cast<unsigned>(JSC::PropertyAttribute::DontEnum), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsServiceWorkerGlobalScopeConstructor), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(setJSServiceWorkerGlobalScopeConstructor) } }, |
| 189 | }; |
| 190 | |
| 191 | static const HashTable JSServiceWorkerGlobalScopePrototypeTable = { 1, 1, true, JSServiceWorkerGlobalScope::info(), JSServiceWorkerGlobalScopePrototypeTableValues, JSServiceWorkerGlobalScopePrototypeTableIndex }; |
| 192 | const ClassInfo JSServiceWorkerGlobalScopePrototype::s_info = { "ServiceWorkerGlobalScopePrototype" , &Base::s_info, &JSServiceWorkerGlobalScopePrototypeTable, nullptr, CREATE_METHOD_TABLE(JSServiceWorkerGlobalScopePrototype) }; |
| 193 | |
| 194 | const ClassInfo JSServiceWorkerGlobalScope::s_info = { "ServiceWorkerGlobalScope" , &Base::s_info, &JSServiceWorkerGlobalScopeTable, nullptr, CREATE_METHOD_TABLE(JSServiceWorkerGlobalScope) }; |
| 195 | |
| 196 | JSServiceWorkerGlobalScope::JSServiceWorkerGlobalScope(VM& vm, Structure* structure, Ref<ServiceWorkerGlobalScope>&& impl) |
| 197 | : JSWorkerGlobalScope(vm, structure, WTFMove(impl)) |
| 198 | { |
| 199 | } |
| 200 | |
| 201 | void JSServiceWorkerGlobalScope::finishCreation(VM& vm, JSProxy* proxy) |
| 202 | { |
| 203 | Base::finishCreation(vm, proxy); |
| 204 | |
| 205 | #if ENABLE(SERVICE_WORKER) |
| 206 | if (RuntimeEnabledFeatures::sharedFeatures().serviceWorkerEnabled()) |
| 207 | putDirectCustomAccessor(vm, static_cast<JSVMClientData*>(vm.clientData)->builtinNames().ExtendableEventPublicName(), CustomGetterSetter::create(vm, jsServiceWorkerGlobalScopeExtendableEventConstructor, setJSServiceWorkerGlobalScopeExtendableEventConstructor), attributesForStructure(static_cast<unsigned>(JSC::PropertyAttribute::DontEnum))); |
| 208 | #endif |
| 209 | #if ENABLE(SERVICE_WORKER) |
| 210 | if (RuntimeEnabledFeatures::sharedFeatures().serviceWorkerEnabled()) |
| 211 | putDirectCustomAccessor(vm, static_cast<JSVMClientData*>(vm.clientData)->builtinNames().ExtendableMessageEventPublicName(), CustomGetterSetter::create(vm, jsServiceWorkerGlobalScopeExtendableMessageEventConstructor, setJSServiceWorkerGlobalScopeExtendableMessageEventConstructor), attributesForStructure(static_cast<unsigned>(JSC::PropertyAttribute::DontEnum))); |
| 212 | #endif |
| 213 | #if ENABLE(SERVICE_WORKER) |
| 214 | if (RuntimeEnabledFeatures::sharedFeatures().serviceWorkerEnabled()) |
| 215 | putDirectCustomAccessor(vm, static_cast<JSVMClientData*>(vm.clientData)->builtinNames().FetchEventPublicName(), CustomGetterSetter::create(vm, jsServiceWorkerGlobalScopeFetchEventConstructor, setJSServiceWorkerGlobalScopeFetchEventConstructor), attributesForStructure(static_cast<unsigned>(JSC::PropertyAttribute::DontEnum))); |
| 216 | #endif |
| 217 | #if ENABLE(SERVICE_WORKER) |
| 218 | if ((jsCast<JSDOMGlobalObject*>(globalObject())->scriptExecutionContext()->isSecureContext() && RuntimeEnabledFeatures::sharedFeatures().serviceWorkerEnabled())) |
| 219 | putDirectCustomAccessor(vm, static_cast<JSVMClientData*>(vm.clientData)->builtinNames().ServiceWorkerPublicName(), CustomGetterSetter::create(vm, jsServiceWorkerGlobalScopeServiceWorkerConstructor, setJSServiceWorkerGlobalScopeServiceWorkerConstructor), attributesForStructure(static_cast<unsigned>(JSC::PropertyAttribute::DontEnum))); |
| 220 | #endif |
| 221 | #if ENABLE(SERVICE_WORKER) |
| 222 | if (RuntimeEnabledFeatures::sharedFeatures().serviceWorkerEnabled()) |
| 223 | putDirectCustomAccessor(vm, static_cast<JSVMClientData*>(vm.clientData)->builtinNames().ClientPublicName(), CustomGetterSetter::create(vm, jsServiceWorkerGlobalScopeClientConstructor, setJSServiceWorkerGlobalScopeClientConstructor), attributesForStructure(static_cast<unsigned>(JSC::PropertyAttribute::DontEnum))); |
| 224 | #endif |
| 225 | #if ENABLE(SERVICE_WORKER) |
| 226 | if (RuntimeEnabledFeatures::sharedFeatures().serviceWorkerEnabled()) |
| 227 | putDirectCustomAccessor(vm, static_cast<JSVMClientData*>(vm.clientData)->builtinNames().ClientsPublicName(), CustomGetterSetter::create(vm, jsServiceWorkerGlobalScopeClientsConstructor, setJSServiceWorkerGlobalScopeClientsConstructor), attributesForStructure(static_cast<unsigned>(JSC::PropertyAttribute::DontEnum))); |
| 228 | #endif |
| 229 | #if ENABLE(SERVICE_WORKER) |
| 230 | if ((jsCast<JSDOMGlobalObject*>(globalObject())->scriptExecutionContext()->isSecureContext() && RuntimeEnabledFeatures::sharedFeatures().serviceWorkerEnabled())) |
| 231 | putDirectCustomAccessor(vm, static_cast<JSVMClientData*>(vm.clientData)->builtinNames().ServiceWorkerContainerPublicName(), CustomGetterSetter::create(vm, jsServiceWorkerGlobalScopeServiceWorkerContainerConstructor, setJSServiceWorkerGlobalScopeServiceWorkerContainerConstructor), attributesForStructure(static_cast<unsigned>(JSC::PropertyAttribute::DontEnum))); |
| 232 | #endif |
| 233 | #if ENABLE(SERVICE_WORKER) |
| 234 | if (RuntimeEnabledFeatures::sharedFeatures().serviceWorkerEnabled()) |
| 235 | putDirectCustomAccessor(vm, static_cast<JSVMClientData*>(vm.clientData)->builtinNames().ServiceWorkerGlobalScopePublicName(), CustomGetterSetter::create(vm, jsServiceWorkerGlobalScopeServiceWorkerGlobalScopeConstructor, setJSServiceWorkerGlobalScopeServiceWorkerGlobalScopeConstructor), attributesForStructure(static_cast<unsigned>(JSC::PropertyAttribute::DontEnum))); |
| 236 | #endif |
| 237 | #if ENABLE(SERVICE_WORKER) |
| 238 | if ((jsCast<JSDOMGlobalObject*>(globalObject())->scriptExecutionContext()->isSecureContext() && RuntimeEnabledFeatures::sharedFeatures().serviceWorkerEnabled())) |
| 239 | putDirectCustomAccessor(vm, static_cast<JSVMClientData*>(vm.clientData)->builtinNames().ServiceWorkerRegistrationPublicName(), CustomGetterSetter::create(vm, jsServiceWorkerGlobalScopeServiceWorkerRegistrationConstructor, setJSServiceWorkerGlobalScopeServiceWorkerRegistrationConstructor), attributesForStructure(static_cast<unsigned>(JSC::PropertyAttribute::DontEnum))); |
| 240 | #endif |
| 241 | #if ENABLE(SERVICE_WORKER) |
| 242 | if (RuntimeEnabledFeatures::sharedFeatures().serviceWorkerEnabled()) |
| 243 | putDirectCustomAccessor(vm, static_cast<JSVMClientData*>(vm.clientData)->builtinNames().WindowClientPublicName(), CustomGetterSetter::create(vm, jsServiceWorkerGlobalScopeWindowClientConstructor, setJSServiceWorkerGlobalScopeWindowClientConstructor), attributesForStructure(static_cast<unsigned>(JSC::PropertyAttribute::DontEnum))); |
| 244 | #endif |
| 245 | } |
| 246 | |
| 247 | JSValue JSServiceWorkerGlobalScope::getConstructor(VM& vm, const JSGlobalObject* globalObject) |
| 248 | { |
| 249 | return getDOMConstructor<JSServiceWorkerGlobalScopeConstructor>(vm, *jsCast<const JSDOMGlobalObject*>(globalObject)); |
| 250 | } |
| 251 | |
| 252 | template<> inline JSServiceWorkerGlobalScope* IDLAttribute<JSServiceWorkerGlobalScope>::cast(ExecState& state, EncodedJSValue thisValue) |
| 253 | { |
| 254 | auto decodedThisValue = JSValue::decode(thisValue); |
| 255 | if (decodedThisValue.isUndefinedOrNull()) |
| 256 | decodedThisValue = state.thisValue().toThis(&state, NotStrictMode); |
| 257 | return toJSServiceWorkerGlobalScope(state.vm(), decodedThisValue);} |
| 258 | |
| 259 | template<> inline JSServiceWorkerGlobalScope* IDLOperation<JSServiceWorkerGlobalScope>::cast(ExecState& state) |
| 260 | { |
| 261 | return toJSServiceWorkerGlobalScope(state.vm(), state.thisValue().toThis(&state, NotStrictMode)); |
| 262 | } |
| 263 | |
| 264 | EncodedJSValue jsServiceWorkerGlobalScopeConstructor(ExecState* state, EncodedJSValue thisValue, PropertyName) |
| 265 | { |
| 266 | VM& vm = state->vm(); |
| 267 | auto throwScope = DECLARE_THROW_SCOPE(vm); |
| 268 | auto* prototype = jsDynamicCast<JSServiceWorkerGlobalScopePrototype*>(vm, JSValue::decode(thisValue)); |
| 269 | if (UNLIKELY(!prototype)) |
| 270 | return throwVMTypeError(state, throwScope); |
| 271 | return JSValue::encode(JSServiceWorkerGlobalScope::getConstructor(state->vm(), prototype->globalObject())); |
| 272 | } |
| 273 | |
| 274 | bool setJSServiceWorkerGlobalScopeConstructor(ExecState* state, EncodedJSValue thisValue, EncodedJSValue encodedValue) |
| 275 | { |
| 276 | VM& vm = state->vm(); |
| 277 | auto throwScope = DECLARE_THROW_SCOPE(vm); |
| 278 | auto* prototype = jsDynamicCast<JSServiceWorkerGlobalScopePrototype*>(vm, JSValue::decode(thisValue)); |
| 279 | if (UNLIKELY(!prototype)) { |
| 280 | throwVMTypeError(state, throwScope); |
| 281 | return false; |
| 282 | } |
| 283 | // Shadowing a built-in constructor |
| 284 | return prototype->putDirect(vm, vm.propertyNames->constructor, JSValue::decode(encodedValue)); |
| 285 | } |
| 286 | |
| 287 | static inline JSValue jsServiceWorkerGlobalScopeClientsGetter(ExecState& state, JSServiceWorkerGlobalScope& thisObject, ThrowScope& throwScope) |
| 288 | { |
| 289 | UNUSED_PARAM(throwScope); |
| 290 | UNUSED_PARAM(state); |
| 291 | auto& impl = thisObject.wrapped(); |
| 292 | JSValue result = toJS<IDLInterface<ServiceWorkerClients>>(state, *thisObject.globalObject(), throwScope, impl.clients()); |
| 293 | return result; |
| 294 | } |
| 295 | |
| 296 | EncodedJSValue jsServiceWorkerGlobalScopeClients(ExecState* state, EncodedJSValue thisValue, PropertyName) |
| 297 | { |
| 298 | return IDLAttribute<JSServiceWorkerGlobalScope>::get<jsServiceWorkerGlobalScopeClientsGetter>(*state, thisValue, "clients" ); |
| 299 | } |
| 300 | |
| 301 | static inline JSValue jsServiceWorkerGlobalScopeRegistrationGetter(ExecState& state, JSServiceWorkerGlobalScope& thisObject, ThrowScope& throwScope) |
| 302 | { |
| 303 | UNUSED_PARAM(throwScope); |
| 304 | UNUSED_PARAM(state); |
| 305 | auto& impl = thisObject.wrapped(); |
| 306 | JSValue result = toJS<IDLInterface<ServiceWorkerRegistration>>(state, *thisObject.globalObject(), throwScope, impl.registration()); |
| 307 | return result; |
| 308 | } |
| 309 | |
| 310 | EncodedJSValue jsServiceWorkerGlobalScopeRegistration(ExecState* state, EncodedJSValue thisValue, PropertyName) |
| 311 | { |
| 312 | return IDLAttribute<JSServiceWorkerGlobalScope>::get<jsServiceWorkerGlobalScopeRegistrationGetter>(*state, thisValue, "registration" ); |
| 313 | } |
| 314 | |
| 315 | static inline JSValue jsServiceWorkerGlobalScopeOninstallGetter(ExecState& state, JSServiceWorkerGlobalScope& thisObject, ThrowScope& throwScope) |
| 316 | { |
| 317 | UNUSED_PARAM(throwScope); |
| 318 | UNUSED_PARAM(state); |
| 319 | return eventHandlerAttribute(thisObject.wrapped(), eventNames().installEvent, worldForDOMObject(thisObject)); |
| 320 | } |
| 321 | |
| 322 | EncodedJSValue jsServiceWorkerGlobalScopeOninstall(ExecState* state, EncodedJSValue thisValue, PropertyName) |
| 323 | { |
| 324 | return IDLAttribute<JSServiceWorkerGlobalScope>::get<jsServiceWorkerGlobalScopeOninstallGetter>(*state, thisValue, "oninstall" ); |
| 325 | } |
| 326 | |
| 327 | static inline bool setJSServiceWorkerGlobalScopeOninstallSetter(ExecState& state, JSServiceWorkerGlobalScope& thisObject, JSValue value, ThrowScope& throwScope) |
| 328 | { |
| 329 | UNUSED_PARAM(throwScope); |
| 330 | setEventHandlerAttribute(state, thisObject, thisObject.wrapped(), eventNames().installEvent, value); |
| 331 | return true; |
| 332 | } |
| 333 | |
| 334 | bool setJSServiceWorkerGlobalScopeOninstall(ExecState* state, EncodedJSValue thisValue, EncodedJSValue encodedValue) |
| 335 | { |
| 336 | return IDLAttribute<JSServiceWorkerGlobalScope>::set<setJSServiceWorkerGlobalScopeOninstallSetter>(*state, thisValue, encodedValue, "oninstall" ); |
| 337 | } |
| 338 | |
| 339 | static inline JSValue jsServiceWorkerGlobalScopeOnactivateGetter(ExecState& state, JSServiceWorkerGlobalScope& thisObject, ThrowScope& throwScope) |
| 340 | { |
| 341 | UNUSED_PARAM(throwScope); |
| 342 | UNUSED_PARAM(state); |
| 343 | return eventHandlerAttribute(thisObject.wrapped(), eventNames().activateEvent, worldForDOMObject(thisObject)); |
| 344 | } |
| 345 | |
| 346 | EncodedJSValue jsServiceWorkerGlobalScopeOnactivate(ExecState* state, EncodedJSValue thisValue, PropertyName) |
| 347 | { |
| 348 | return IDLAttribute<JSServiceWorkerGlobalScope>::get<jsServiceWorkerGlobalScopeOnactivateGetter>(*state, thisValue, "onactivate" ); |
| 349 | } |
| 350 | |
| 351 | static inline bool setJSServiceWorkerGlobalScopeOnactivateSetter(ExecState& state, JSServiceWorkerGlobalScope& thisObject, JSValue value, ThrowScope& throwScope) |
| 352 | { |
| 353 | UNUSED_PARAM(throwScope); |
| 354 | setEventHandlerAttribute(state, thisObject, thisObject.wrapped(), eventNames().activateEvent, value); |
| 355 | return true; |
| 356 | } |
| 357 | |
| 358 | bool setJSServiceWorkerGlobalScopeOnactivate(ExecState* state, EncodedJSValue thisValue, EncodedJSValue encodedValue) |
| 359 | { |
| 360 | return IDLAttribute<JSServiceWorkerGlobalScope>::set<setJSServiceWorkerGlobalScopeOnactivateSetter>(*state, thisValue, encodedValue, "onactivate" ); |
| 361 | } |
| 362 | |
| 363 | static inline JSValue jsServiceWorkerGlobalScopeOnfetchGetter(ExecState& state, JSServiceWorkerGlobalScope& thisObject, ThrowScope& throwScope) |
| 364 | { |
| 365 | UNUSED_PARAM(throwScope); |
| 366 | UNUSED_PARAM(state); |
| 367 | return eventHandlerAttribute(thisObject.wrapped(), eventNames().fetchEvent, worldForDOMObject(thisObject)); |
| 368 | } |
| 369 | |
| 370 | EncodedJSValue jsServiceWorkerGlobalScopeOnfetch(ExecState* state, EncodedJSValue thisValue, PropertyName) |
| 371 | { |
| 372 | return IDLAttribute<JSServiceWorkerGlobalScope>::get<jsServiceWorkerGlobalScopeOnfetchGetter>(*state, thisValue, "onfetch" ); |
| 373 | } |
| 374 | |
| 375 | static inline bool setJSServiceWorkerGlobalScopeOnfetchSetter(ExecState& state, JSServiceWorkerGlobalScope& thisObject, JSValue value, ThrowScope& throwScope) |
| 376 | { |
| 377 | UNUSED_PARAM(throwScope); |
| 378 | setEventHandlerAttribute(state, thisObject, thisObject.wrapped(), eventNames().fetchEvent, value); |
| 379 | return true; |
| 380 | } |
| 381 | |
| 382 | bool setJSServiceWorkerGlobalScopeOnfetch(ExecState* state, EncodedJSValue thisValue, EncodedJSValue encodedValue) |
| 383 | { |
| 384 | return IDLAttribute<JSServiceWorkerGlobalScope>::set<setJSServiceWorkerGlobalScopeOnfetchSetter>(*state, thisValue, encodedValue, "onfetch" ); |
| 385 | } |
| 386 | |
| 387 | static inline JSValue jsServiceWorkerGlobalScopeOnmessageGetter(ExecState& state, JSServiceWorkerGlobalScope& thisObject, ThrowScope& throwScope) |
| 388 | { |
| 389 | UNUSED_PARAM(throwScope); |
| 390 | UNUSED_PARAM(state); |
| 391 | return eventHandlerAttribute(thisObject.wrapped(), eventNames().messageEvent, worldForDOMObject(thisObject)); |
| 392 | } |
| 393 | |
| 394 | EncodedJSValue jsServiceWorkerGlobalScopeOnmessage(ExecState* state, EncodedJSValue thisValue, PropertyName) |
| 395 | { |
| 396 | return IDLAttribute<JSServiceWorkerGlobalScope>::get<jsServiceWorkerGlobalScopeOnmessageGetter>(*state, thisValue, "onmessage" ); |
| 397 | } |
| 398 | |
| 399 | static inline bool setJSServiceWorkerGlobalScopeOnmessageSetter(ExecState& state, JSServiceWorkerGlobalScope& thisObject, JSValue value, ThrowScope& throwScope) |
| 400 | { |
| 401 | UNUSED_PARAM(throwScope); |
| 402 | setEventHandlerAttribute(state, thisObject, thisObject.wrapped(), eventNames().messageEvent, value); |
| 403 | return true; |
| 404 | } |
| 405 | |
| 406 | bool setJSServiceWorkerGlobalScopeOnmessage(ExecState* state, EncodedJSValue thisValue, EncodedJSValue encodedValue) |
| 407 | { |
| 408 | return IDLAttribute<JSServiceWorkerGlobalScope>::set<setJSServiceWorkerGlobalScopeOnmessageSetter>(*state, thisValue, encodedValue, "onmessage" ); |
| 409 | } |
| 410 | |
| 411 | static inline JSValue jsServiceWorkerGlobalScopeOnmessageerrorGetter(ExecState& state, JSServiceWorkerGlobalScope& thisObject, ThrowScope& throwScope) |
| 412 | { |
| 413 | UNUSED_PARAM(throwScope); |
| 414 | UNUSED_PARAM(state); |
| 415 | return eventHandlerAttribute(thisObject.wrapped(), eventNames().messageerrorEvent, worldForDOMObject(thisObject)); |
| 416 | } |
| 417 | |
| 418 | EncodedJSValue jsServiceWorkerGlobalScopeOnmessageerror(ExecState* state, EncodedJSValue thisValue, PropertyName) |
| 419 | { |
| 420 | return IDLAttribute<JSServiceWorkerGlobalScope>::get<jsServiceWorkerGlobalScopeOnmessageerrorGetter>(*state, thisValue, "onmessageerror" ); |
| 421 | } |
| 422 | |
| 423 | static inline bool setJSServiceWorkerGlobalScopeOnmessageerrorSetter(ExecState& state, JSServiceWorkerGlobalScope& thisObject, JSValue value, ThrowScope& throwScope) |
| 424 | { |
| 425 | UNUSED_PARAM(throwScope); |
| 426 | setEventHandlerAttribute(state, thisObject, thisObject.wrapped(), eventNames().messageerrorEvent, value); |
| 427 | return true; |
| 428 | } |
| 429 | |
| 430 | bool setJSServiceWorkerGlobalScopeOnmessageerror(ExecState* state, EncodedJSValue thisValue, EncodedJSValue encodedValue) |
| 431 | { |
| 432 | return IDLAttribute<JSServiceWorkerGlobalScope>::set<setJSServiceWorkerGlobalScopeOnmessageerrorSetter>(*state, thisValue, encodedValue, "onmessageerror" ); |
| 433 | } |
| 434 | |
| 435 | #if ENABLE(SERVICE_WORKER) |
| 436 | static inline JSValue jsServiceWorkerGlobalScopeExtendableEventConstructorGetter(ExecState& state, JSServiceWorkerGlobalScope& thisObject, ThrowScope& throwScope) |
| 437 | { |
| 438 | UNUSED_PARAM(throwScope); |
| 439 | UNUSED_PARAM(state); |
| 440 | return JSExtendableEvent::getConstructor(state.vm(), thisObject.globalObject()); |
| 441 | } |
| 442 | |
| 443 | EncodedJSValue jsServiceWorkerGlobalScopeExtendableEventConstructor(ExecState* state, EncodedJSValue thisValue, PropertyName) |
| 444 | { |
| 445 | return IDLAttribute<JSServiceWorkerGlobalScope>::get<jsServiceWorkerGlobalScopeExtendableEventConstructorGetter>(*state, thisValue, "ExtendableEvent" ); |
| 446 | } |
| 447 | |
| 448 | #endif |
| 449 | |
| 450 | #if ENABLE(SERVICE_WORKER) |
| 451 | static inline bool setJSServiceWorkerGlobalScopeExtendableEventConstructorSetter(ExecState& state, JSServiceWorkerGlobalScope& thisObject, JSValue value, ThrowScope& throwScope) |
| 452 | { |
| 453 | UNUSED_PARAM(throwScope); |
| 454 | // Shadowing a built-in constructor. |
| 455 | return thisObject.putDirect(state.vm(), Identifier::fromString(&state.vm(), reinterpret_cast<const LChar*>("ExtendableEvent" ), strlen("ExtendableEvent" )), value); |
| 456 | } |
| 457 | |
| 458 | bool setJSServiceWorkerGlobalScopeExtendableEventConstructor(ExecState* state, EncodedJSValue thisValue, EncodedJSValue encodedValue) |
| 459 | { |
| 460 | return IDLAttribute<JSServiceWorkerGlobalScope>::set<setJSServiceWorkerGlobalScopeExtendableEventConstructorSetter>(*state, thisValue, encodedValue, "ExtendableEvent" ); |
| 461 | } |
| 462 | |
| 463 | #endif |
| 464 | |
| 465 | #if ENABLE(SERVICE_WORKER) |
| 466 | static inline JSValue jsServiceWorkerGlobalScopeExtendableMessageEventConstructorGetter(ExecState& state, JSServiceWorkerGlobalScope& thisObject, ThrowScope& throwScope) |
| 467 | { |
| 468 | UNUSED_PARAM(throwScope); |
| 469 | UNUSED_PARAM(state); |
| 470 | return JSExtendableMessageEvent::getConstructor(state.vm(), thisObject.globalObject()); |
| 471 | } |
| 472 | |
| 473 | EncodedJSValue jsServiceWorkerGlobalScopeExtendableMessageEventConstructor(ExecState* state, EncodedJSValue thisValue, PropertyName) |
| 474 | { |
| 475 | return IDLAttribute<JSServiceWorkerGlobalScope>::get<jsServiceWorkerGlobalScopeExtendableMessageEventConstructorGetter>(*state, thisValue, "ExtendableMessageEvent" ); |
| 476 | } |
| 477 | |
| 478 | #endif |
| 479 | |
| 480 | #if ENABLE(SERVICE_WORKER) |
| 481 | static inline bool setJSServiceWorkerGlobalScopeExtendableMessageEventConstructorSetter(ExecState& state, JSServiceWorkerGlobalScope& thisObject, JSValue value, ThrowScope& throwScope) |
| 482 | { |
| 483 | UNUSED_PARAM(throwScope); |
| 484 | // Shadowing a built-in constructor. |
| 485 | return thisObject.putDirect(state.vm(), Identifier::fromString(&state.vm(), reinterpret_cast<const LChar*>("ExtendableMessageEvent" ), strlen("ExtendableMessageEvent" )), value); |
| 486 | } |
| 487 | |
| 488 | bool setJSServiceWorkerGlobalScopeExtendableMessageEventConstructor(ExecState* state, EncodedJSValue thisValue, EncodedJSValue encodedValue) |
| 489 | { |
| 490 | return IDLAttribute<JSServiceWorkerGlobalScope>::set<setJSServiceWorkerGlobalScopeExtendableMessageEventConstructorSetter>(*state, thisValue, encodedValue, "ExtendableMessageEvent" ); |
| 491 | } |
| 492 | |
| 493 | #endif |
| 494 | |
| 495 | #if ENABLE(SERVICE_WORKER) |
| 496 | static inline JSValue jsServiceWorkerGlobalScopeFetchEventConstructorGetter(ExecState& state, JSServiceWorkerGlobalScope& thisObject, ThrowScope& throwScope) |
| 497 | { |
| 498 | UNUSED_PARAM(throwScope); |
| 499 | UNUSED_PARAM(state); |
| 500 | return JSFetchEvent::getConstructor(state.vm(), thisObject.globalObject()); |
| 501 | } |
| 502 | |
| 503 | EncodedJSValue jsServiceWorkerGlobalScopeFetchEventConstructor(ExecState* state, EncodedJSValue thisValue, PropertyName) |
| 504 | { |
| 505 | return IDLAttribute<JSServiceWorkerGlobalScope>::get<jsServiceWorkerGlobalScopeFetchEventConstructorGetter>(*state, thisValue, "FetchEvent" ); |
| 506 | } |
| 507 | |
| 508 | #endif |
| 509 | |
| 510 | #if ENABLE(SERVICE_WORKER) |
| 511 | static inline bool setJSServiceWorkerGlobalScopeFetchEventConstructorSetter(ExecState& state, JSServiceWorkerGlobalScope& thisObject, JSValue value, ThrowScope& throwScope) |
| 512 | { |
| 513 | UNUSED_PARAM(throwScope); |
| 514 | // Shadowing a built-in constructor. |
| 515 | return thisObject.putDirect(state.vm(), Identifier::fromString(&state.vm(), reinterpret_cast<const LChar*>("FetchEvent" ), strlen("FetchEvent" )), value); |
| 516 | } |
| 517 | |
| 518 | bool setJSServiceWorkerGlobalScopeFetchEventConstructor(ExecState* state, EncodedJSValue thisValue, EncodedJSValue encodedValue) |
| 519 | { |
| 520 | return IDLAttribute<JSServiceWorkerGlobalScope>::set<setJSServiceWorkerGlobalScopeFetchEventConstructorSetter>(*state, thisValue, encodedValue, "FetchEvent" ); |
| 521 | } |
| 522 | |
| 523 | #endif |
| 524 | |
| 525 | #if ENABLE(SERVICE_WORKER) |
| 526 | static inline JSValue jsServiceWorkerGlobalScopeServiceWorkerConstructorGetter(ExecState& state, JSServiceWorkerGlobalScope& thisObject, ThrowScope& throwScope) |
| 527 | { |
| 528 | UNUSED_PARAM(throwScope); |
| 529 | UNUSED_PARAM(state); |
| 530 | return JSServiceWorker::getConstructor(state.vm(), thisObject.globalObject()); |
| 531 | } |
| 532 | |
| 533 | EncodedJSValue jsServiceWorkerGlobalScopeServiceWorkerConstructor(ExecState* state, EncodedJSValue thisValue, PropertyName) |
| 534 | { |
| 535 | return IDLAttribute<JSServiceWorkerGlobalScope>::get<jsServiceWorkerGlobalScopeServiceWorkerConstructorGetter>(*state, thisValue, "ServiceWorker" ); |
| 536 | } |
| 537 | |
| 538 | #endif |
| 539 | |
| 540 | #if ENABLE(SERVICE_WORKER) |
| 541 | static inline bool setJSServiceWorkerGlobalScopeServiceWorkerConstructorSetter(ExecState& state, JSServiceWorkerGlobalScope& thisObject, JSValue value, ThrowScope& throwScope) |
| 542 | { |
| 543 | UNUSED_PARAM(throwScope); |
| 544 | // Shadowing a built-in constructor. |
| 545 | return thisObject.putDirect(state.vm(), Identifier::fromString(&state.vm(), reinterpret_cast<const LChar*>("ServiceWorker" ), strlen("ServiceWorker" )), value); |
| 546 | } |
| 547 | |
| 548 | bool setJSServiceWorkerGlobalScopeServiceWorkerConstructor(ExecState* state, EncodedJSValue thisValue, EncodedJSValue encodedValue) |
| 549 | { |
| 550 | return IDLAttribute<JSServiceWorkerGlobalScope>::set<setJSServiceWorkerGlobalScopeServiceWorkerConstructorSetter>(*state, thisValue, encodedValue, "ServiceWorker" ); |
| 551 | } |
| 552 | |
| 553 | #endif |
| 554 | |
| 555 | #if ENABLE(SERVICE_WORKER) |
| 556 | static inline JSValue jsServiceWorkerGlobalScopeClientConstructorGetter(ExecState& state, JSServiceWorkerGlobalScope& thisObject, ThrowScope& throwScope) |
| 557 | { |
| 558 | UNUSED_PARAM(throwScope); |
| 559 | UNUSED_PARAM(state); |
| 560 | return JSServiceWorkerClient::getConstructor(state.vm(), thisObject.globalObject()); |
| 561 | } |
| 562 | |
| 563 | EncodedJSValue jsServiceWorkerGlobalScopeClientConstructor(ExecState* state, EncodedJSValue thisValue, PropertyName) |
| 564 | { |
| 565 | return IDLAttribute<JSServiceWorkerGlobalScope>::get<jsServiceWorkerGlobalScopeClientConstructorGetter>(*state, thisValue, "Client" ); |
| 566 | } |
| 567 | |
| 568 | #endif |
| 569 | |
| 570 | #if ENABLE(SERVICE_WORKER) |
| 571 | static inline bool setJSServiceWorkerGlobalScopeClientConstructorSetter(ExecState& state, JSServiceWorkerGlobalScope& thisObject, JSValue value, ThrowScope& throwScope) |
| 572 | { |
| 573 | UNUSED_PARAM(throwScope); |
| 574 | // Shadowing a built-in constructor. |
| 575 | return thisObject.putDirect(state.vm(), Identifier::fromString(&state.vm(), reinterpret_cast<const LChar*>("Client" ), strlen("Client" )), value); |
| 576 | } |
| 577 | |
| 578 | bool setJSServiceWorkerGlobalScopeClientConstructor(ExecState* state, EncodedJSValue thisValue, EncodedJSValue encodedValue) |
| 579 | { |
| 580 | return IDLAttribute<JSServiceWorkerGlobalScope>::set<setJSServiceWorkerGlobalScopeClientConstructorSetter>(*state, thisValue, encodedValue, "Client" ); |
| 581 | } |
| 582 | |
| 583 | #endif |
| 584 | |
| 585 | #if ENABLE(SERVICE_WORKER) |
| 586 | static inline JSValue jsServiceWorkerGlobalScopeClientsConstructorGetter(ExecState& state, JSServiceWorkerGlobalScope& thisObject, ThrowScope& throwScope) |
| 587 | { |
| 588 | UNUSED_PARAM(throwScope); |
| 589 | UNUSED_PARAM(state); |
| 590 | return JSServiceWorkerClients::getConstructor(state.vm(), thisObject.globalObject()); |
| 591 | } |
| 592 | |
| 593 | EncodedJSValue jsServiceWorkerGlobalScopeClientsConstructor(ExecState* state, EncodedJSValue thisValue, PropertyName) |
| 594 | { |
| 595 | return IDLAttribute<JSServiceWorkerGlobalScope>::get<jsServiceWorkerGlobalScopeClientsConstructorGetter>(*state, thisValue, "Clients" ); |
| 596 | } |
| 597 | |
| 598 | #endif |
| 599 | |
| 600 | #if ENABLE(SERVICE_WORKER) |
| 601 | static inline bool setJSServiceWorkerGlobalScopeClientsConstructorSetter(ExecState& state, JSServiceWorkerGlobalScope& thisObject, JSValue value, ThrowScope& throwScope) |
| 602 | { |
| 603 | UNUSED_PARAM(throwScope); |
| 604 | // Shadowing a built-in constructor. |
| 605 | return thisObject.putDirect(state.vm(), Identifier::fromString(&state.vm(), reinterpret_cast<const LChar*>("Clients" ), strlen("Clients" )), value); |
| 606 | } |
| 607 | |
| 608 | bool setJSServiceWorkerGlobalScopeClientsConstructor(ExecState* state, EncodedJSValue thisValue, EncodedJSValue encodedValue) |
| 609 | { |
| 610 | return IDLAttribute<JSServiceWorkerGlobalScope>::set<setJSServiceWorkerGlobalScopeClientsConstructorSetter>(*state, thisValue, encodedValue, "Clients" ); |
| 611 | } |
| 612 | |
| 613 | #endif |
| 614 | |
| 615 | #if ENABLE(SERVICE_WORKER) |
| 616 | static inline JSValue jsServiceWorkerGlobalScopeServiceWorkerContainerConstructorGetter(ExecState& state, JSServiceWorkerGlobalScope& thisObject, ThrowScope& throwScope) |
| 617 | { |
| 618 | UNUSED_PARAM(throwScope); |
| 619 | UNUSED_PARAM(state); |
| 620 | return JSServiceWorkerContainer::getConstructor(state.vm(), thisObject.globalObject()); |
| 621 | } |
| 622 | |
| 623 | EncodedJSValue jsServiceWorkerGlobalScopeServiceWorkerContainerConstructor(ExecState* state, EncodedJSValue thisValue, PropertyName) |
| 624 | { |
| 625 | return IDLAttribute<JSServiceWorkerGlobalScope>::get<jsServiceWorkerGlobalScopeServiceWorkerContainerConstructorGetter>(*state, thisValue, "ServiceWorkerContainer" ); |
| 626 | } |
| 627 | |
| 628 | #endif |
| 629 | |
| 630 | #if ENABLE(SERVICE_WORKER) |
| 631 | static inline bool setJSServiceWorkerGlobalScopeServiceWorkerContainerConstructorSetter(ExecState& state, JSServiceWorkerGlobalScope& thisObject, JSValue value, ThrowScope& throwScope) |
| 632 | { |
| 633 | UNUSED_PARAM(throwScope); |
| 634 | // Shadowing a built-in constructor. |
| 635 | return thisObject.putDirect(state.vm(), Identifier::fromString(&state.vm(), reinterpret_cast<const LChar*>("ServiceWorkerContainer" ), strlen("ServiceWorkerContainer" )), value); |
| 636 | } |
| 637 | |
| 638 | bool setJSServiceWorkerGlobalScopeServiceWorkerContainerConstructor(ExecState* state, EncodedJSValue thisValue, EncodedJSValue encodedValue) |
| 639 | { |
| 640 | return IDLAttribute<JSServiceWorkerGlobalScope>::set<setJSServiceWorkerGlobalScopeServiceWorkerContainerConstructorSetter>(*state, thisValue, encodedValue, "ServiceWorkerContainer" ); |
| 641 | } |
| 642 | |
| 643 | #endif |
| 644 | |
| 645 | #if ENABLE(SERVICE_WORKER) |
| 646 | static inline JSValue jsServiceWorkerGlobalScopeServiceWorkerGlobalScopeConstructorGetter(ExecState& state, JSServiceWorkerGlobalScope& thisObject, ThrowScope& throwScope) |
| 647 | { |
| 648 | UNUSED_PARAM(throwScope); |
| 649 | UNUSED_PARAM(state); |
| 650 | return JSServiceWorkerGlobalScope::getConstructor(state.vm(), thisObject.globalObject()); |
| 651 | } |
| 652 | |
| 653 | EncodedJSValue jsServiceWorkerGlobalScopeServiceWorkerGlobalScopeConstructor(ExecState* state, EncodedJSValue thisValue, PropertyName) |
| 654 | { |
| 655 | return IDLAttribute<JSServiceWorkerGlobalScope>::get<jsServiceWorkerGlobalScopeServiceWorkerGlobalScopeConstructorGetter>(*state, thisValue, "ServiceWorkerGlobalScope" ); |
| 656 | } |
| 657 | |
| 658 | #endif |
| 659 | |
| 660 | #if ENABLE(SERVICE_WORKER) |
| 661 | static inline bool setJSServiceWorkerGlobalScopeServiceWorkerGlobalScopeConstructorSetter(ExecState& state, JSServiceWorkerGlobalScope& thisObject, JSValue value, ThrowScope& throwScope) |
| 662 | { |
| 663 | UNUSED_PARAM(throwScope); |
| 664 | // Shadowing a built-in constructor. |
| 665 | return thisObject.putDirect(state.vm(), Identifier::fromString(&state.vm(), reinterpret_cast<const LChar*>("ServiceWorkerGlobalScope" ), strlen("ServiceWorkerGlobalScope" )), value); |
| 666 | } |
| 667 | |
| 668 | bool setJSServiceWorkerGlobalScopeServiceWorkerGlobalScopeConstructor(ExecState* state, EncodedJSValue thisValue, EncodedJSValue encodedValue) |
| 669 | { |
| 670 | return IDLAttribute<JSServiceWorkerGlobalScope>::set<setJSServiceWorkerGlobalScopeServiceWorkerGlobalScopeConstructorSetter>(*state, thisValue, encodedValue, "ServiceWorkerGlobalScope" ); |
| 671 | } |
| 672 | |
| 673 | #endif |
| 674 | |
| 675 | #if ENABLE(SERVICE_WORKER) |
| 676 | static inline JSValue jsServiceWorkerGlobalScopeServiceWorkerRegistrationConstructorGetter(ExecState& state, JSServiceWorkerGlobalScope& thisObject, ThrowScope& throwScope) |
| 677 | { |
| 678 | UNUSED_PARAM(throwScope); |
| 679 | UNUSED_PARAM(state); |
| 680 | return JSServiceWorkerRegistration::getConstructor(state.vm(), thisObject.globalObject()); |
| 681 | } |
| 682 | |
| 683 | EncodedJSValue jsServiceWorkerGlobalScopeServiceWorkerRegistrationConstructor(ExecState* state, EncodedJSValue thisValue, PropertyName) |
| 684 | { |
| 685 | return IDLAttribute<JSServiceWorkerGlobalScope>::get<jsServiceWorkerGlobalScopeServiceWorkerRegistrationConstructorGetter>(*state, thisValue, "ServiceWorkerRegistration" ); |
| 686 | } |
| 687 | |
| 688 | #endif |
| 689 | |
| 690 | #if ENABLE(SERVICE_WORKER) |
| 691 | static inline bool setJSServiceWorkerGlobalScopeServiceWorkerRegistrationConstructorSetter(ExecState& state, JSServiceWorkerGlobalScope& thisObject, JSValue value, ThrowScope& throwScope) |
| 692 | { |
| 693 | UNUSED_PARAM(throwScope); |
| 694 | // Shadowing a built-in constructor. |
| 695 | return thisObject.putDirect(state.vm(), Identifier::fromString(&state.vm(), reinterpret_cast<const LChar*>("ServiceWorkerRegistration" ), strlen("ServiceWorkerRegistration" )), value); |
| 696 | } |
| 697 | |
| 698 | bool setJSServiceWorkerGlobalScopeServiceWorkerRegistrationConstructor(ExecState* state, EncodedJSValue thisValue, EncodedJSValue encodedValue) |
| 699 | { |
| 700 | return IDLAttribute<JSServiceWorkerGlobalScope>::set<setJSServiceWorkerGlobalScopeServiceWorkerRegistrationConstructorSetter>(*state, thisValue, encodedValue, "ServiceWorkerRegistration" ); |
| 701 | } |
| 702 | |
| 703 | #endif |
| 704 | |
| 705 | #if ENABLE(SERVICE_WORKER) |
| 706 | static inline JSValue jsServiceWorkerGlobalScopeWindowClientConstructorGetter(ExecState& state, JSServiceWorkerGlobalScope& thisObject, ThrowScope& throwScope) |
| 707 | { |
| 708 | UNUSED_PARAM(throwScope); |
| 709 | UNUSED_PARAM(state); |
| 710 | return JSServiceWorkerWindowClient::getConstructor(state.vm(), thisObject.globalObject()); |
| 711 | } |
| 712 | |
| 713 | EncodedJSValue jsServiceWorkerGlobalScopeWindowClientConstructor(ExecState* state, EncodedJSValue thisValue, PropertyName) |
| 714 | { |
| 715 | return IDLAttribute<JSServiceWorkerGlobalScope>::get<jsServiceWorkerGlobalScopeWindowClientConstructorGetter>(*state, thisValue, "WindowClient" ); |
| 716 | } |
| 717 | |
| 718 | #endif |
| 719 | |
| 720 | #if ENABLE(SERVICE_WORKER) |
| 721 | static inline bool setJSServiceWorkerGlobalScopeWindowClientConstructorSetter(ExecState& state, JSServiceWorkerGlobalScope& thisObject, JSValue value, ThrowScope& throwScope) |
| 722 | { |
| 723 | UNUSED_PARAM(throwScope); |
| 724 | // Shadowing a built-in constructor. |
| 725 | return thisObject.putDirect(state.vm(), Identifier::fromString(&state.vm(), reinterpret_cast<const LChar*>("WindowClient" ), strlen("WindowClient" )), value); |
| 726 | } |
| 727 | |
| 728 | bool setJSServiceWorkerGlobalScopeWindowClientConstructor(ExecState* state, EncodedJSValue thisValue, EncodedJSValue encodedValue) |
| 729 | { |
| 730 | return IDLAttribute<JSServiceWorkerGlobalScope>::set<setJSServiceWorkerGlobalScopeWindowClientConstructorSetter>(*state, thisValue, encodedValue, "WindowClient" ); |
| 731 | } |
| 732 | |
| 733 | #endif |
| 734 | |
| 735 | static inline JSC::EncodedJSValue jsServiceWorkerGlobalScopeInstanceFunctionSkipWaitingBody(JSC::ExecState* state, typename IDLOperationReturningPromise<JSServiceWorkerGlobalScope>::ClassParameter castedThis, Ref<DeferredPromise>&& promise, JSC::ThrowScope& throwScope) |
| 736 | { |
| 737 | UNUSED_PARAM(state); |
| 738 | UNUSED_PARAM(throwScope); |
| 739 | auto& impl = castedThis->wrapped(); |
| 740 | impl.skipWaiting(WTFMove(promise)); |
| 741 | return JSValue::encode(jsUndefined()); |
| 742 | } |
| 743 | |
| 744 | EncodedJSValue JSC_HOST_CALL jsServiceWorkerGlobalScopeInstanceFunctionSkipWaiting(ExecState* state) |
| 745 | { |
| 746 | return IDLOperationReturningPromise<JSServiceWorkerGlobalScope>::call<jsServiceWorkerGlobalScopeInstanceFunctionSkipWaitingBody, PromiseExecutionScope::WindowOrWorker>(*state, "skipWaiting" ); |
| 747 | } |
| 748 | |
| 749 | void JSServiceWorkerGlobalScope::visitChildren(JSCell* cell, SlotVisitor& visitor) |
| 750 | { |
| 751 | auto* thisObject = jsCast<JSServiceWorkerGlobalScope*>(cell); |
| 752 | ASSERT_GC_OBJECT_INHERITS(thisObject, info()); |
| 753 | Base::visitChildren(thisObject, visitor); |
| 754 | thisObject->visitAdditionalChildren(visitor); |
| 755 | } |
| 756 | |
| 757 | void JSServiceWorkerGlobalScope::visitOutputConstraints(JSCell* cell, SlotVisitor& visitor) |
| 758 | { |
| 759 | auto* thisObject = jsCast<JSServiceWorkerGlobalScope*>(cell); |
| 760 | ASSERT_GC_OBJECT_INHERITS(thisObject, info()); |
| 761 | Base::visitOutputConstraints(thisObject, visitor); |
| 762 | thisObject->visitAdditionalChildren(visitor); |
| 763 | } |
| 764 | |
| 765 | void JSServiceWorkerGlobalScope::heapSnapshot(JSCell* cell, HeapSnapshotBuilder& builder) |
| 766 | { |
| 767 | auto* thisObject = jsCast<JSServiceWorkerGlobalScope*>(cell); |
| 768 | builder.setWrappedObjectForCell(cell, &thisObject->wrapped()); |
| 769 | if (thisObject->scriptExecutionContext()) |
| 770 | builder.setLabelForCell(cell, "url " + thisObject->scriptExecutionContext()->url().string()); |
| 771 | Base::heapSnapshot(cell, builder); |
| 772 | } |
| 773 | |
| 774 | |
| 775 | } |
| 776 | |
| 777 | #endif // ENABLE(SERVICE_WORKER) |
| 778 | |