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 "JSWorkerNavigator.h" |
23 | |
24 | #include "JSDOMAttribute.h" |
25 | #include "JSDOMBinding.h" |
26 | #include "JSDOMConstructorNotConstructable.h" |
27 | #include "JSDOMConvertBoolean.h" |
28 | #include "JSDOMConvertSequences.h" |
29 | #include "JSDOMConvertStrings.h" |
30 | #include "JSDOMExceptionHandling.h" |
31 | #include "JSDOMGlobalObject.h" |
32 | #include "JSDOMWrapperCache.h" |
33 | #include "RuntimeEnabledFeatures.h" |
34 | #include "ScriptExecutionContext.h" |
35 | #include <JavaScriptCore/FunctionPrototype.h> |
36 | #include <JavaScriptCore/HeapSnapshotBuilder.h> |
37 | #include <JavaScriptCore/JSArray.h> |
38 | #include <JavaScriptCore/JSCInlines.h> |
39 | #include <wtf/GetPtr.h> |
40 | #include <wtf/PointerPreparations.h> |
41 | #include <wtf/URL.h> |
42 | |
43 | #if ENABLE(SERVICE_WORKER) |
44 | #include "JSServiceWorkerContainer.h" |
45 | #endif |
46 | |
47 | #if ENABLE(SERVICE_WORKER) || ENABLE(WEBGPU) |
48 | #include "JSDOMConvertInterface.h" |
49 | #endif |
50 | |
51 | #if ENABLE(WEBGPU) |
52 | #include "JSWebGPU.h" |
53 | #include "WorkerNavigatorGPU.h" |
54 | #endif |
55 | |
56 | |
57 | namespace WebCore { |
58 | using namespace JSC; |
59 | |
60 | // Attributes |
61 | |
62 | JSC::EncodedJSValue jsWorkerNavigatorConstructor(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
63 | bool setJSWorkerNavigatorConstructor(JSC::ExecState*, JSC::EncodedJSValue, JSC::EncodedJSValue); |
64 | #if ENABLE(WEBGPU) |
65 | JSC::EncodedJSValue jsWorkerNavigatorGpu(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
66 | #endif |
67 | JSC::EncodedJSValue jsWorkerNavigatorAppCodeName(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
68 | JSC::EncodedJSValue jsWorkerNavigatorAppName(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
69 | JSC::EncodedJSValue jsWorkerNavigatorAppVersion(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
70 | JSC::EncodedJSValue jsWorkerNavigatorPlatform(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
71 | JSC::EncodedJSValue jsWorkerNavigatorProduct(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
72 | JSC::EncodedJSValue jsWorkerNavigatorUserAgent(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
73 | JSC::EncodedJSValue jsWorkerNavigatorLanguage(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
74 | JSC::EncodedJSValue jsWorkerNavigatorLanguages(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
75 | JSC::EncodedJSValue jsWorkerNavigatorOnLine(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
76 | #if ENABLE(SERVICE_WORKER) |
77 | JSC::EncodedJSValue jsWorkerNavigatorServiceWorker(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
78 | #endif |
79 | |
80 | class JSWorkerNavigatorPrototype : public JSC::JSNonFinalObject { |
81 | public: |
82 | using Base = JSC::JSNonFinalObject; |
83 | static JSWorkerNavigatorPrototype* create(JSC::VM& vm, JSDOMGlobalObject* globalObject, JSC::Structure* structure) |
84 | { |
85 | JSWorkerNavigatorPrototype* ptr = new (NotNull, JSC::allocateCell<JSWorkerNavigatorPrototype>(vm.heap)) JSWorkerNavigatorPrototype(vm, globalObject, structure); |
86 | ptr->finishCreation(vm); |
87 | return ptr; |
88 | } |
89 | |
90 | DECLARE_INFO; |
91 | static JSC::Structure* createStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype) |
92 | { |
93 | return JSC::Structure::create(vm, globalObject, prototype, JSC::TypeInfo(JSC::ObjectType, StructureFlags), info()); |
94 | } |
95 | |
96 | private: |
97 | JSWorkerNavigatorPrototype(JSC::VM& vm, JSC::JSGlobalObject*, JSC::Structure* structure) |
98 | : JSC::JSNonFinalObject(vm, structure) |
99 | { |
100 | } |
101 | |
102 | void finishCreation(JSC::VM&); |
103 | }; |
104 | |
105 | using JSWorkerNavigatorConstructor = JSDOMConstructorNotConstructable<JSWorkerNavigator>; |
106 | |
107 | template<> JSValue JSWorkerNavigatorConstructor::prototypeForStructure(JSC::VM& vm, const JSDOMGlobalObject& globalObject) |
108 | { |
109 | UNUSED_PARAM(vm); |
110 | return globalObject.functionPrototype(); |
111 | } |
112 | |
113 | template<> void JSWorkerNavigatorConstructor::initializeProperties(VM& vm, JSDOMGlobalObject& globalObject) |
114 | { |
115 | putDirect(vm, vm.propertyNames->prototype, JSWorkerNavigator::prototype(vm, globalObject), JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum); |
116 | putDirect(vm, vm.propertyNames->name, jsNontrivialString(&vm, String("WorkerNavigator"_s )), JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum); |
117 | putDirect(vm, vm.propertyNames->length, jsNumber(0), JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum); |
118 | } |
119 | |
120 | template<> const ClassInfo JSWorkerNavigatorConstructor::s_info = { "WorkerNavigator" , &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSWorkerNavigatorConstructor) }; |
121 | |
122 | /* Hash table for prototype */ |
123 | |
124 | static const HashTableValue JSWorkerNavigatorPrototypeTableValues[] = |
125 | { |
126 | { "constructor" , static_cast<unsigned>(JSC::PropertyAttribute::DontEnum), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsWorkerNavigatorConstructor), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(setJSWorkerNavigatorConstructor) } }, |
127 | #if ENABLE(WEBGPU) |
128 | { "gpu" , static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsWorkerNavigatorGpu), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } }, |
129 | #else |
130 | { 0, 0, NoIntrinsic, { 0, 0 } }, |
131 | #endif |
132 | { "appCodeName" , static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsWorkerNavigatorAppCodeName), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } }, |
133 | { "appName" , static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsWorkerNavigatorAppName), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } }, |
134 | { "appVersion" , static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsWorkerNavigatorAppVersion), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } }, |
135 | { "platform" , static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsWorkerNavigatorPlatform), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } }, |
136 | { "product" , static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsWorkerNavigatorProduct), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } }, |
137 | { "userAgent" , static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsWorkerNavigatorUserAgent), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } }, |
138 | { "language" , static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsWorkerNavigatorLanguage), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } }, |
139 | { "languages" , static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsWorkerNavigatorLanguages), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } }, |
140 | { "onLine" , static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsWorkerNavigatorOnLine), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } }, |
141 | #if ENABLE(SERVICE_WORKER) |
142 | { "serviceWorker" , static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsWorkerNavigatorServiceWorker), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } }, |
143 | #else |
144 | { 0, 0, NoIntrinsic, { 0, 0 } }, |
145 | #endif |
146 | }; |
147 | |
148 | const ClassInfo JSWorkerNavigatorPrototype::s_info = { "WorkerNavigatorPrototype" , &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSWorkerNavigatorPrototype) }; |
149 | |
150 | void JSWorkerNavigatorPrototype::finishCreation(VM& vm) |
151 | { |
152 | Base::finishCreation(vm); |
153 | reifyStaticProperties(vm, JSWorkerNavigator::info(), JSWorkerNavigatorPrototypeTableValues, *this); |
154 | bool hasDisabledRuntimeProperties = false; |
155 | #if ENABLE(WEBGPU) |
156 | if (!RuntimeEnabledFeatures::sharedFeatures().webGPUEnabled()) { |
157 | hasDisabledRuntimeProperties = true; |
158 | auto propertyName = Identifier::fromString(&vm, reinterpret_cast<const LChar*>("gpu" ), strlen("gpu" )); |
159 | VM::DeletePropertyModeScope scope(vm, VM::DeletePropertyMode::IgnoreConfigurable); |
160 | JSObject::deleteProperty(this, globalObject()->globalExec(), propertyName); |
161 | } |
162 | #endif |
163 | #if ENABLE(SERVICE_WORKER) |
164 | if (!((jsCast<JSDOMGlobalObject*>(globalObject())->scriptExecutionContext()->isSecureContext()|| jsCast<JSDOMGlobalObject*>(globalObject())->scriptExecutionContext()->hasServiceWorkerScheme()) && RuntimeEnabledFeatures::sharedFeatures().serviceWorkerEnabled())) { |
165 | hasDisabledRuntimeProperties = true; |
166 | auto propertyName = Identifier::fromString(&vm, reinterpret_cast<const LChar*>("serviceWorker" ), strlen("serviceWorker" )); |
167 | VM::DeletePropertyModeScope scope(vm, VM::DeletePropertyMode::IgnoreConfigurable); |
168 | JSObject::deleteProperty(this, globalObject()->globalExec(), propertyName); |
169 | } |
170 | #endif |
171 | if (hasDisabledRuntimeProperties && structure()->isDictionary()) |
172 | flattenDictionaryObject(vm); |
173 | } |
174 | |
175 | const ClassInfo JSWorkerNavigator::s_info = { "WorkerNavigator" , &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSWorkerNavigator) }; |
176 | |
177 | JSWorkerNavigator::JSWorkerNavigator(Structure* structure, JSDOMGlobalObject& globalObject, Ref<WorkerNavigator>&& impl) |
178 | : JSDOMWrapper<WorkerNavigator>(structure, globalObject, WTFMove(impl)) |
179 | { |
180 | } |
181 | |
182 | void JSWorkerNavigator::finishCreation(VM& vm) |
183 | { |
184 | Base::finishCreation(vm); |
185 | ASSERT(inherits(vm, info())); |
186 | |
187 | } |
188 | |
189 | JSObject* JSWorkerNavigator::createPrototype(VM& vm, JSDOMGlobalObject& globalObject) |
190 | { |
191 | return JSWorkerNavigatorPrototype::create(vm, &globalObject, JSWorkerNavigatorPrototype::createStructure(vm, &globalObject, globalObject.objectPrototype())); |
192 | } |
193 | |
194 | JSObject* JSWorkerNavigator::prototype(VM& vm, JSDOMGlobalObject& globalObject) |
195 | { |
196 | return getDOMPrototype<JSWorkerNavigator>(vm, globalObject); |
197 | } |
198 | |
199 | JSValue JSWorkerNavigator::getConstructor(VM& vm, const JSGlobalObject* globalObject) |
200 | { |
201 | return getDOMConstructor<JSWorkerNavigatorConstructor>(vm, *jsCast<const JSDOMGlobalObject*>(globalObject)); |
202 | } |
203 | |
204 | void JSWorkerNavigator::destroy(JSC::JSCell* cell) |
205 | { |
206 | JSWorkerNavigator* thisObject = static_cast<JSWorkerNavigator*>(cell); |
207 | thisObject->JSWorkerNavigator::~JSWorkerNavigator(); |
208 | } |
209 | |
210 | template<> inline JSWorkerNavigator* IDLAttribute<JSWorkerNavigator>::cast(ExecState& state, EncodedJSValue thisValue) |
211 | { |
212 | return jsDynamicCast<JSWorkerNavigator*>(state.vm(), JSValue::decode(thisValue)); |
213 | } |
214 | |
215 | EncodedJSValue jsWorkerNavigatorConstructor(ExecState* state, EncodedJSValue thisValue, PropertyName) |
216 | { |
217 | VM& vm = state->vm(); |
218 | auto throwScope = DECLARE_THROW_SCOPE(vm); |
219 | auto* prototype = jsDynamicCast<JSWorkerNavigatorPrototype*>(vm, JSValue::decode(thisValue)); |
220 | if (UNLIKELY(!prototype)) |
221 | return throwVMTypeError(state, throwScope); |
222 | return JSValue::encode(JSWorkerNavigator::getConstructor(state->vm(), prototype->globalObject())); |
223 | } |
224 | |
225 | bool setJSWorkerNavigatorConstructor(ExecState* state, EncodedJSValue thisValue, EncodedJSValue encodedValue) |
226 | { |
227 | VM& vm = state->vm(); |
228 | auto throwScope = DECLARE_THROW_SCOPE(vm); |
229 | auto* prototype = jsDynamicCast<JSWorkerNavigatorPrototype*>(vm, JSValue::decode(thisValue)); |
230 | if (UNLIKELY(!prototype)) { |
231 | throwVMTypeError(state, throwScope); |
232 | return false; |
233 | } |
234 | // Shadowing a built-in constructor |
235 | return prototype->putDirect(vm, vm.propertyNames->constructor, JSValue::decode(encodedValue)); |
236 | } |
237 | |
238 | #if ENABLE(WEBGPU) |
239 | static inline JSValue jsWorkerNavigatorGpuGetter(ExecState& state, JSWorkerNavigator& thisObject, ThrowScope& throwScope) |
240 | { |
241 | UNUSED_PARAM(throwScope); |
242 | UNUSED_PARAM(state); |
243 | auto& impl = thisObject.wrapped(); |
244 | JSValue result = toJS<IDLInterface<WebGPU>>(state, *thisObject.globalObject(), throwScope, WebCore::WorkerNavigatorGPU::gpu(impl)); |
245 | return result; |
246 | } |
247 | |
248 | EncodedJSValue jsWorkerNavigatorGpu(ExecState* state, EncodedJSValue thisValue, PropertyName) |
249 | { |
250 | return IDLAttribute<JSWorkerNavigator>::get<jsWorkerNavigatorGpuGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "gpu" ); |
251 | } |
252 | |
253 | #endif |
254 | |
255 | static inline JSValue jsWorkerNavigatorAppCodeNameGetter(ExecState& state, JSWorkerNavigator& thisObject, ThrowScope& throwScope) |
256 | { |
257 | UNUSED_PARAM(throwScope); |
258 | UNUSED_PARAM(state); |
259 | auto& impl = thisObject.wrapped(); |
260 | JSValue result = toJS<IDLDOMString>(state, throwScope, impl.appCodeName()); |
261 | return result; |
262 | } |
263 | |
264 | EncodedJSValue jsWorkerNavigatorAppCodeName(ExecState* state, EncodedJSValue thisValue, PropertyName) |
265 | { |
266 | return IDLAttribute<JSWorkerNavigator>::get<jsWorkerNavigatorAppCodeNameGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "appCodeName" ); |
267 | } |
268 | |
269 | static inline JSValue jsWorkerNavigatorAppNameGetter(ExecState& state, JSWorkerNavigator& thisObject, ThrowScope& throwScope) |
270 | { |
271 | UNUSED_PARAM(throwScope); |
272 | UNUSED_PARAM(state); |
273 | auto& impl = thisObject.wrapped(); |
274 | JSValue result = toJS<IDLDOMString>(state, throwScope, impl.appName()); |
275 | return result; |
276 | } |
277 | |
278 | EncodedJSValue jsWorkerNavigatorAppName(ExecState* state, EncodedJSValue thisValue, PropertyName) |
279 | { |
280 | return IDLAttribute<JSWorkerNavigator>::get<jsWorkerNavigatorAppNameGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "appName" ); |
281 | } |
282 | |
283 | static inline JSValue jsWorkerNavigatorAppVersionGetter(ExecState& state, JSWorkerNavigator& thisObject, ThrowScope& throwScope) |
284 | { |
285 | UNUSED_PARAM(throwScope); |
286 | UNUSED_PARAM(state); |
287 | auto& impl = thisObject.wrapped(); |
288 | JSValue result = toJS<IDLDOMString>(state, throwScope, impl.appVersion()); |
289 | return result; |
290 | } |
291 | |
292 | EncodedJSValue jsWorkerNavigatorAppVersion(ExecState* state, EncodedJSValue thisValue, PropertyName) |
293 | { |
294 | return IDLAttribute<JSWorkerNavigator>::get<jsWorkerNavigatorAppVersionGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "appVersion" ); |
295 | } |
296 | |
297 | static inline JSValue jsWorkerNavigatorPlatformGetter(ExecState& state, JSWorkerNavigator& thisObject, ThrowScope& throwScope) |
298 | { |
299 | UNUSED_PARAM(throwScope); |
300 | UNUSED_PARAM(state); |
301 | auto& impl = thisObject.wrapped(); |
302 | JSValue result = toJS<IDLDOMString>(state, throwScope, impl.platform()); |
303 | return result; |
304 | } |
305 | |
306 | EncodedJSValue jsWorkerNavigatorPlatform(ExecState* state, EncodedJSValue thisValue, PropertyName) |
307 | { |
308 | return IDLAttribute<JSWorkerNavigator>::get<jsWorkerNavigatorPlatformGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "platform" ); |
309 | } |
310 | |
311 | static inline JSValue jsWorkerNavigatorProductGetter(ExecState& state, JSWorkerNavigator& thisObject, ThrowScope& throwScope) |
312 | { |
313 | UNUSED_PARAM(throwScope); |
314 | UNUSED_PARAM(state); |
315 | auto& impl = thisObject.wrapped(); |
316 | JSValue result = toJS<IDLDOMString>(state, throwScope, impl.product()); |
317 | return result; |
318 | } |
319 | |
320 | EncodedJSValue jsWorkerNavigatorProduct(ExecState* state, EncodedJSValue thisValue, PropertyName) |
321 | { |
322 | return IDLAttribute<JSWorkerNavigator>::get<jsWorkerNavigatorProductGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "product" ); |
323 | } |
324 | |
325 | static inline JSValue jsWorkerNavigatorUserAgentGetter(ExecState& state, JSWorkerNavigator& thisObject, ThrowScope& throwScope) |
326 | { |
327 | UNUSED_PARAM(throwScope); |
328 | UNUSED_PARAM(state); |
329 | auto& impl = thisObject.wrapped(); |
330 | JSValue result = toJS<IDLDOMString>(state, throwScope, impl.userAgent()); |
331 | return result; |
332 | } |
333 | |
334 | EncodedJSValue jsWorkerNavigatorUserAgent(ExecState* state, EncodedJSValue thisValue, PropertyName) |
335 | { |
336 | return IDLAttribute<JSWorkerNavigator>::get<jsWorkerNavigatorUserAgentGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "userAgent" ); |
337 | } |
338 | |
339 | static inline JSValue jsWorkerNavigatorLanguageGetter(ExecState& state, JSWorkerNavigator& thisObject, ThrowScope& throwScope) |
340 | { |
341 | UNUSED_PARAM(throwScope); |
342 | UNUSED_PARAM(state); |
343 | auto& impl = thisObject.wrapped(); |
344 | JSValue result = toJS<IDLDOMString>(state, throwScope, impl.language()); |
345 | return result; |
346 | } |
347 | |
348 | EncodedJSValue jsWorkerNavigatorLanguage(ExecState* state, EncodedJSValue thisValue, PropertyName) |
349 | { |
350 | return IDLAttribute<JSWorkerNavigator>::get<jsWorkerNavigatorLanguageGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "language" ); |
351 | } |
352 | |
353 | static inline JSValue jsWorkerNavigatorLanguagesGetter(ExecState& state, JSWorkerNavigator& thisObject, ThrowScope& throwScope) |
354 | { |
355 | UNUSED_PARAM(throwScope); |
356 | UNUSED_PARAM(state); |
357 | auto& impl = thisObject.wrapped(); |
358 | JSValue result = toJS<IDLFrozenArray<IDLDOMString>>(state, *thisObject.globalObject(), throwScope, impl.languages()); |
359 | return result; |
360 | } |
361 | |
362 | EncodedJSValue jsWorkerNavigatorLanguages(ExecState* state, EncodedJSValue thisValue, PropertyName) |
363 | { |
364 | return IDLAttribute<JSWorkerNavigator>::get<jsWorkerNavigatorLanguagesGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "languages" ); |
365 | } |
366 | |
367 | static inline JSValue jsWorkerNavigatorOnLineGetter(ExecState& state, JSWorkerNavigator& thisObject, ThrowScope& throwScope) |
368 | { |
369 | UNUSED_PARAM(throwScope); |
370 | UNUSED_PARAM(state); |
371 | auto& impl = thisObject.wrapped(); |
372 | JSValue result = toJS<IDLBoolean>(state, throwScope, impl.onLine()); |
373 | return result; |
374 | } |
375 | |
376 | EncodedJSValue jsWorkerNavigatorOnLine(ExecState* state, EncodedJSValue thisValue, PropertyName) |
377 | { |
378 | return IDLAttribute<JSWorkerNavigator>::get<jsWorkerNavigatorOnLineGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "onLine" ); |
379 | } |
380 | |
381 | #if ENABLE(SERVICE_WORKER) |
382 | static inline JSValue jsWorkerNavigatorServiceWorkerGetter(ExecState& state, JSWorkerNavigator& thisObject, ThrowScope& throwScope) |
383 | { |
384 | UNUSED_PARAM(throwScope); |
385 | UNUSED_PARAM(state); |
386 | auto* context = jsCast<JSDOMGlobalObject*>(state.lexicalGlobalObject())->scriptExecutionContext(); |
387 | if (UNLIKELY(!context)) |
388 | return jsUndefined(); |
389 | auto& impl = thisObject.wrapped(); |
390 | JSValue result = toJS<IDLInterface<ServiceWorkerContainer>>(state, *thisObject.globalObject(), throwScope, impl.serviceWorker(*context)); |
391 | return result; |
392 | } |
393 | |
394 | EncodedJSValue jsWorkerNavigatorServiceWorker(ExecState* state, EncodedJSValue thisValue, PropertyName) |
395 | { |
396 | return IDLAttribute<JSWorkerNavigator>::get<jsWorkerNavigatorServiceWorkerGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "serviceWorker" ); |
397 | } |
398 | |
399 | #endif |
400 | |
401 | void JSWorkerNavigator::visitChildren(JSCell* cell, SlotVisitor& visitor) |
402 | { |
403 | auto* thisObject = jsCast<JSWorkerNavigator*>(cell); |
404 | ASSERT_GC_OBJECT_INHERITS(thisObject, info()); |
405 | Base::visitChildren(thisObject, visitor); |
406 | thisObject->visitAdditionalChildren(visitor); |
407 | } |
408 | |
409 | void JSWorkerNavigator::visitOutputConstraints(JSCell* cell, SlotVisitor& visitor) |
410 | { |
411 | auto* thisObject = jsCast<JSWorkerNavigator*>(cell); |
412 | ASSERT_GC_OBJECT_INHERITS(thisObject, info()); |
413 | Base::visitOutputConstraints(thisObject, visitor); |
414 | thisObject->visitAdditionalChildren(visitor); |
415 | } |
416 | |
417 | void JSWorkerNavigator::heapSnapshot(JSCell* cell, HeapSnapshotBuilder& builder) |
418 | { |
419 | auto* thisObject = jsCast<JSWorkerNavigator*>(cell); |
420 | builder.setWrappedObjectForCell(cell, &thisObject->wrapped()); |
421 | if (thisObject->scriptExecutionContext()) |
422 | builder.setLabelForCell(cell, "url " + thisObject->scriptExecutionContext()->url().string()); |
423 | Base::heapSnapshot(cell, builder); |
424 | } |
425 | |
426 | bool JSWorkerNavigatorOwner::isReachableFromOpaqueRoots(JSC::Handle<JSC::Unknown> handle, void*, SlotVisitor& visitor, const char** reason) |
427 | { |
428 | auto* jsWorkerNavigator = jsCast<JSWorkerNavigator*>(handle.slot()->asCell()); |
429 | WorkerNavigator* root = &jsWorkerNavigator->wrapped(); |
430 | if (UNLIKELY(reason)) |
431 | *reason = "Reachable from WorkerNavigator" ; |
432 | return visitor.containsOpaqueRoot(root); |
433 | } |
434 | |
435 | void JSWorkerNavigatorOwner::finalize(JSC::Handle<JSC::Unknown> handle, void* context) |
436 | { |
437 | auto* jsWorkerNavigator = static_cast<JSWorkerNavigator*>(handle.slot()->asCell()); |
438 | auto& world = *static_cast<DOMWrapperWorld*>(context); |
439 | uncacheWrapper(world, &jsWorkerNavigator->wrapped(), jsWorkerNavigator); |
440 | } |
441 | |
442 | #if ENABLE(BINDING_INTEGRITY) |
443 | #if PLATFORM(WIN) |
444 | #pragma warning(disable: 4483) |
445 | extern "C" { extern void (*const __identifier("??_7WorkerNavigator@WebCore@@6B@" )[])(); } |
446 | #else |
447 | extern "C" { extern void* _ZTVN7WebCore15WorkerNavigatorE[]; } |
448 | #endif |
449 | #endif |
450 | |
451 | JSC::JSValue toJSNewlyCreated(JSC::ExecState*, JSDOMGlobalObject* globalObject, Ref<WorkerNavigator>&& impl) |
452 | { |
453 | |
454 | #if ENABLE(BINDING_INTEGRITY) |
455 | void* actualVTablePointer = *(reinterpret_cast<void**>(impl.ptr())); |
456 | #if PLATFORM(WIN) |
457 | void* expectedVTablePointer = WTF_PREPARE_VTBL_POINTER_FOR_INSPECTION(__identifier("??_7WorkerNavigator@WebCore@@6B@" )); |
458 | #else |
459 | void* expectedVTablePointer = WTF_PREPARE_VTBL_POINTER_FOR_INSPECTION(&_ZTVN7WebCore15WorkerNavigatorE[2]); |
460 | #endif |
461 | |
462 | // If this fails WorkerNavigator does not have a vtable, so you need to add the |
463 | // ImplementationLacksVTable attribute to the interface definition |
464 | static_assert(std::is_polymorphic<WorkerNavigator>::value, "WorkerNavigator is not polymorphic" ); |
465 | |
466 | // If you hit this assertion you either have a use after free bug, or |
467 | // WorkerNavigator has subclasses. If WorkerNavigator has subclasses that get passed |
468 | // to toJS() we currently require WorkerNavigator you to opt out of binding hardening |
469 | // by adding the SkipVTableValidation attribute to the interface IDL definition |
470 | RELEASE_ASSERT(actualVTablePointer == expectedVTablePointer); |
471 | #endif |
472 | return createWrapper<WorkerNavigator>(globalObject, WTFMove(impl)); |
473 | } |
474 | |
475 | JSC::JSValue toJS(JSC::ExecState* state, JSDOMGlobalObject* globalObject, WorkerNavigator& impl) |
476 | { |
477 | return wrap(state, globalObject, impl); |
478 | } |
479 | |
480 | WorkerNavigator* JSWorkerNavigator::toWrapped(JSC::VM& vm, JSC::JSValue value) |
481 | { |
482 | if (auto* wrapper = jsDynamicCast<JSWorkerNavigator*>(vm, value)) |
483 | return &wrapper->wrapped(); |
484 | return nullptr; |
485 | } |
486 | |
487 | } |
488 | |