Line data Source code
1 : /* THIS FILE IS AUTOGENERATED FROM WorkerNavigator.webidl BY Codegen.py - DO NOT EDIT */
2 :
3 : #include "WorkerNavigatorBinding.h"
4 : #include "WrapperFactory.h"
5 : #include "mozilla/OwningNonNull.h"
6 : #include "mozilla/dom/BindingUtils.h"
7 : #include "mozilla/dom/DOMJSClass.h"
8 : #include "mozilla/dom/NonRefcountedDOMObject.h"
9 : #include "mozilla/dom/Nullable.h"
10 : #include "mozilla/dom/PrimitiveConversions.h"
11 : #include "mozilla/dom/StorageManager.h"
12 : #include "mozilla/dom/WorkerNavigator.h"
13 : #include "mozilla/dom/network/Connection.h"
14 : #include "nsContentUtils.h"
15 :
16 : namespace mozilla {
17 : namespace dom {
18 :
19 : namespace WorkerNavigatorBinding {
20 :
21 : static bool
22 0 : get_connection(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::WorkerNavigator* self, JSJitGetterCallArgs args)
23 : {
24 0 : binding_detail::FastErrorResult rv;
25 0 : auto result(StrongOrRawPtr<mozilla::dom::network::Connection>(self->GetConnection(rv)));
26 0 : if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
27 0 : return false;
28 : }
29 0 : MOZ_ASSERT(!JS_IsExceptionPending(cx));
30 0 : if (!GetOrCreateDOMReflector(cx, result, args.rval())) {
31 0 : MOZ_ASSERT(true || JS_IsExceptionPending(cx));
32 0 : return false;
33 : }
34 0 : return true;
35 : }
36 :
37 : static const JSJitInfo connection_getterinfo = {
38 : { (JSJitGetterOp)get_connection },
39 : { prototypes::id::WorkerNavigator },
40 : { PrototypeTraits<prototypes::id::WorkerNavigator>::Depth },
41 : JSJitInfo::Getter,
42 : JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */
43 : JSVAL_TYPE_OBJECT, /* returnType. Not relevant for setters. */
44 : false, /* isInfallible. False in setters. */
45 : false, /* isMovable. Not relevant for setters. */
46 : false, /* isEliminatable. Not relevant for setters. */
47 : false, /* isAlwaysInSlot. Only relevant for getters. */
48 : false, /* isLazilyCachedInSlot. Only relevant for getters. */
49 : false, /* isTypedMethod. Only relevant for methods. */
50 : 0 /* Reserved slot index, if we're stored in a slot, else 0. */
51 : };
52 : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
53 : static_assert(0 < 9, "There is no slot for us");
54 :
55 : static bool
56 0 : get_hardwareConcurrency(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::WorkerNavigator* self, JSJitGetterCallArgs args)
57 : {
58 0 : uint64_t result(self->HardwareConcurrency());
59 0 : MOZ_ASSERT(!JS_IsExceptionPending(cx));
60 0 : args.rval().set(JS_NumberValue(double(result)));
61 0 : return true;
62 : }
63 :
64 : static const JSJitInfo hardwareConcurrency_getterinfo = {
65 : { (JSJitGetterOp)get_hardwareConcurrency },
66 : { prototypes::id::WorkerNavigator },
67 : { PrototypeTraits<prototypes::id::WorkerNavigator>::Depth },
68 : JSJitInfo::Getter,
69 : JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */
70 : JSVAL_TYPE_DOUBLE, /* returnType. Not relevant for setters. */
71 : true, /* isInfallible. False in setters. */
72 : false, /* isMovable. Not relevant for setters. */
73 : false, /* isEliminatable. Not relevant for setters. */
74 : false, /* isAlwaysInSlot. Only relevant for getters. */
75 : false, /* isLazilyCachedInSlot. Only relevant for getters. */
76 : false, /* isTypedMethod. Only relevant for methods. */
77 : 0 /* Reserved slot index, if we're stored in a slot, else 0. */
78 : };
79 : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
80 : static_assert(0 < 9, "There is no slot for us");
81 :
82 : static bool
83 0 : get_appCodeName(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::WorkerNavigator* self, JSJitGetterCallArgs args)
84 : {
85 : // Have to either root across the getter call or reget after.
86 0 : JS::Rooted<JSObject*> slotStorage(cx, js::UncheckedUnwrap(obj, /* stopAtWindowProxy = */ false));
87 0 : MOZ_ASSERT(IsDOMObject(slotStorage));
88 0 : const size_t slotIndex = (DOM_INSTANCE_RESERVED_SLOTS + 0);
89 0 : MOZ_ASSERT(JSCLASS_RESERVED_SLOTS(js::GetObjectClass(slotStorage)) > slotIndex);
90 : {
91 : // Scope for cachedVal
92 0 : JS::Value cachedVal = js::GetReservedSlot(slotStorage, slotIndex);
93 0 : if (!cachedVal.isUndefined()) {
94 0 : args.rval().set(cachedVal);
95 : // The cached value is in the compartment of slotStorage,
96 : // so wrap into the caller compartment as needed.
97 0 : return MaybeWrapValue(cx, args.rval());
98 : }
99 : }
100 :
101 0 : DOMString result;
102 0 : self->GetAppCodeName(result);
103 0 : MOZ_ASSERT(!JS_IsExceptionPending(cx));
104 : {
105 0 : JS::Rooted<JSObject*> conversionScope(cx, slotStorage);
106 0 : JSAutoCompartment ac(cx, conversionScope);
107 : do { // block we break out of when done wrapping
108 0 : if (!xpc::NonVoidStringToJsval(cx, result, args.rval())) {
109 0 : return false;
110 : }
111 0 : break;
112 : } while (0);
113 : }
114 : { // And now store things in the compartment of our slotStorage.
115 0 : JSAutoCompartment ac(cx, slotStorage);
116 : // Make a copy so that we don't do unnecessary wrapping on args.rval().
117 0 : JS::Rooted<JS::Value> storedVal(cx, args.rval());
118 0 : if (!MaybeWrapValue(cx, &storedVal)) {
119 0 : return false;
120 : }
121 0 : js::SetReservedSlot(slotStorage, slotIndex, storedVal);
122 0 : PreserveWrapper(self);
123 : }
124 : // And now make sure args.rval() is in the caller compartment
125 0 : return MaybeWrapValue(cx, args.rval());
126 : }
127 :
128 : static const JSJitInfo appCodeName_getterinfo = {
129 : { (JSJitGetterOp)get_appCodeName },
130 : { prototypes::id::WorkerNavigator },
131 : { PrototypeTraits<prototypes::id::WorkerNavigator>::Depth },
132 : JSJitInfo::Getter,
133 : JSJitInfo::AliasNone, /* aliasSet. Not relevant for setters. */
134 : JSVAL_TYPE_STRING, /* returnType. Not relevant for setters. */
135 : false, /* isInfallible. False in setters. */
136 : true, /* isMovable. Not relevant for setters. */
137 : true, /* isEliminatable. Not relevant for setters. */
138 : false, /* isAlwaysInSlot. Only relevant for getters. */
139 : true, /* isLazilyCachedInSlot. Only relevant for getters. */
140 : false, /* isTypedMethod. Only relevant for methods. */
141 : (DOM_INSTANCE_RESERVED_SLOTS + 0) /* Reserved slot index, if we're stored in a slot, else 0. */
142 : };
143 : static_assert((DOM_INSTANCE_RESERVED_SLOTS + 0) <= JSJitInfo::maxSlotIndex, "We won't fit");
144 : static_assert((DOM_INSTANCE_RESERVED_SLOTS + 0) < 9, "There is no slot for us");
145 :
146 : static bool
147 0 : get_appName(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::WorkerNavigator* self, JSJitGetterCallArgs args)
148 : {
149 : // Have to either root across the getter call or reget after.
150 0 : JS::Rooted<JSObject*> slotStorage(cx, js::UncheckedUnwrap(obj, /* stopAtWindowProxy = */ false));
151 0 : MOZ_ASSERT(IsDOMObject(slotStorage));
152 0 : const size_t slotIndex = (DOM_INSTANCE_RESERVED_SLOTS + 1);
153 0 : MOZ_ASSERT(JSCLASS_RESERVED_SLOTS(js::GetObjectClass(slotStorage)) > slotIndex);
154 : {
155 : // Scope for cachedVal
156 0 : JS::Value cachedVal = js::GetReservedSlot(slotStorage, slotIndex);
157 0 : if (!cachedVal.isUndefined()) {
158 0 : args.rval().set(cachedVal);
159 : // The cached value is in the compartment of slotStorage,
160 : // so wrap into the caller compartment as needed.
161 0 : return MaybeWrapValue(cx, args.rval());
162 : }
163 : }
164 :
165 0 : DOMString result;
166 0 : self->GetAppName(result, nsContentUtils::ThreadsafeIsSystemCaller(cx) ? CallerType::System : CallerType::NonSystem);
167 0 : MOZ_ASSERT(!JS_IsExceptionPending(cx));
168 : {
169 0 : JS::Rooted<JSObject*> conversionScope(cx, slotStorage);
170 0 : JSAutoCompartment ac(cx, conversionScope);
171 : do { // block we break out of when done wrapping
172 0 : if (!xpc::NonVoidStringToJsval(cx, result, args.rval())) {
173 0 : return false;
174 : }
175 0 : break;
176 : } while (0);
177 : }
178 : { // And now store things in the compartment of our slotStorage.
179 0 : JSAutoCompartment ac(cx, slotStorage);
180 : // Make a copy so that we don't do unnecessary wrapping on args.rval().
181 0 : JS::Rooted<JS::Value> storedVal(cx, args.rval());
182 0 : if (!MaybeWrapValue(cx, &storedVal)) {
183 0 : return false;
184 : }
185 0 : js::SetReservedSlot(slotStorage, slotIndex, storedVal);
186 0 : PreserveWrapper(self);
187 : }
188 : // And now make sure args.rval() is in the caller compartment
189 0 : return MaybeWrapValue(cx, args.rval());
190 : }
191 :
192 : static const JSJitInfo appName_getterinfo = {
193 : { (JSJitGetterOp)get_appName },
194 : { prototypes::id::WorkerNavigator },
195 : { PrototypeTraits<prototypes::id::WorkerNavigator>::Depth },
196 : JSJitInfo::Getter,
197 : JSJitInfo::AliasNone, /* aliasSet. Not relevant for setters. */
198 : JSVAL_TYPE_STRING, /* returnType. Not relevant for setters. */
199 : false, /* isInfallible. False in setters. */
200 : true, /* isMovable. Not relevant for setters. */
201 : true, /* isEliminatable. Not relevant for setters. */
202 : false, /* isAlwaysInSlot. Only relevant for getters. */
203 : true, /* isLazilyCachedInSlot. Only relevant for getters. */
204 : false, /* isTypedMethod. Only relevant for methods. */
205 : (DOM_INSTANCE_RESERVED_SLOTS + 1) /* Reserved slot index, if we're stored in a slot, else 0. */
206 : };
207 : static_assert((DOM_INSTANCE_RESERVED_SLOTS + 1) <= JSJitInfo::maxSlotIndex, "We won't fit");
208 : static_assert((DOM_INSTANCE_RESERVED_SLOTS + 1) < 9, "There is no slot for us");
209 :
210 : static bool
211 0 : get_appVersion(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::WorkerNavigator* self, JSJitGetterCallArgs args)
212 : {
213 : // Have to either root across the getter call or reget after.
214 0 : JS::Rooted<JSObject*> slotStorage(cx, js::UncheckedUnwrap(obj, /* stopAtWindowProxy = */ false));
215 0 : MOZ_ASSERT(IsDOMObject(slotStorage));
216 0 : const size_t slotIndex = (DOM_INSTANCE_RESERVED_SLOTS + 2);
217 0 : MOZ_ASSERT(JSCLASS_RESERVED_SLOTS(js::GetObjectClass(slotStorage)) > slotIndex);
218 : {
219 : // Scope for cachedVal
220 0 : JS::Value cachedVal = js::GetReservedSlot(slotStorage, slotIndex);
221 0 : if (!cachedVal.isUndefined()) {
222 0 : args.rval().set(cachedVal);
223 : // The cached value is in the compartment of slotStorage,
224 : // so wrap into the caller compartment as needed.
225 0 : return MaybeWrapValue(cx, args.rval());
226 : }
227 : }
228 :
229 0 : binding_detail::FastErrorResult rv;
230 0 : DOMString result;
231 0 : self->GetAppVersion(result, nsContentUtils::ThreadsafeIsSystemCaller(cx) ? CallerType::System : CallerType::NonSystem, rv);
232 0 : if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
233 0 : return false;
234 : }
235 0 : MOZ_ASSERT(!JS_IsExceptionPending(cx));
236 : {
237 0 : JS::Rooted<JSObject*> conversionScope(cx, slotStorage);
238 0 : JSAutoCompartment ac(cx, conversionScope);
239 : do { // block we break out of when done wrapping
240 0 : if (!xpc::NonVoidStringToJsval(cx, result, args.rval())) {
241 0 : return false;
242 : }
243 0 : break;
244 : } while (0);
245 : }
246 : { // And now store things in the compartment of our slotStorage.
247 0 : JSAutoCompartment ac(cx, slotStorage);
248 : // Make a copy so that we don't do unnecessary wrapping on args.rval().
249 0 : JS::Rooted<JS::Value> storedVal(cx, args.rval());
250 0 : if (!MaybeWrapValue(cx, &storedVal)) {
251 0 : return false;
252 : }
253 0 : js::SetReservedSlot(slotStorage, slotIndex, storedVal);
254 0 : PreserveWrapper(self);
255 : }
256 : // And now make sure args.rval() is in the caller compartment
257 0 : return MaybeWrapValue(cx, args.rval());
258 : }
259 :
260 : static const JSJitInfo appVersion_getterinfo = {
261 : { (JSJitGetterOp)get_appVersion },
262 : { prototypes::id::WorkerNavigator },
263 : { PrototypeTraits<prototypes::id::WorkerNavigator>::Depth },
264 : JSJitInfo::Getter,
265 : JSJitInfo::AliasNone, /* aliasSet. Not relevant for setters. */
266 : JSVAL_TYPE_STRING, /* returnType. Not relevant for setters. */
267 : false, /* isInfallible. False in setters. */
268 : false, /* isMovable. Not relevant for setters. */
269 : false, /* isEliminatable. Not relevant for setters. */
270 : false, /* isAlwaysInSlot. Only relevant for getters. */
271 : true, /* isLazilyCachedInSlot. Only relevant for getters. */
272 : false, /* isTypedMethod. Only relevant for methods. */
273 : (DOM_INSTANCE_RESERVED_SLOTS + 2) /* Reserved slot index, if we're stored in a slot, else 0. */
274 : };
275 : static_assert((DOM_INSTANCE_RESERVED_SLOTS + 2) <= JSJitInfo::maxSlotIndex, "We won't fit");
276 : static_assert((DOM_INSTANCE_RESERVED_SLOTS + 2) < 9, "There is no slot for us");
277 :
278 : static bool
279 0 : get_platform(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::WorkerNavigator* self, JSJitGetterCallArgs args)
280 : {
281 : // Have to either root across the getter call or reget after.
282 0 : JS::Rooted<JSObject*> slotStorage(cx, js::UncheckedUnwrap(obj, /* stopAtWindowProxy = */ false));
283 0 : MOZ_ASSERT(IsDOMObject(slotStorage));
284 0 : const size_t slotIndex = (DOM_INSTANCE_RESERVED_SLOTS + 3);
285 0 : MOZ_ASSERT(JSCLASS_RESERVED_SLOTS(js::GetObjectClass(slotStorage)) > slotIndex);
286 : {
287 : // Scope for cachedVal
288 0 : JS::Value cachedVal = js::GetReservedSlot(slotStorage, slotIndex);
289 0 : if (!cachedVal.isUndefined()) {
290 0 : args.rval().set(cachedVal);
291 : // The cached value is in the compartment of slotStorage,
292 : // so wrap into the caller compartment as needed.
293 0 : return MaybeWrapValue(cx, args.rval());
294 : }
295 : }
296 :
297 0 : binding_detail::FastErrorResult rv;
298 0 : DOMString result;
299 0 : self->GetPlatform(result, nsContentUtils::ThreadsafeIsSystemCaller(cx) ? CallerType::System : CallerType::NonSystem, rv);
300 0 : if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
301 0 : return false;
302 : }
303 0 : MOZ_ASSERT(!JS_IsExceptionPending(cx));
304 : {
305 0 : JS::Rooted<JSObject*> conversionScope(cx, slotStorage);
306 0 : JSAutoCompartment ac(cx, conversionScope);
307 : do { // block we break out of when done wrapping
308 0 : if (!xpc::NonVoidStringToJsval(cx, result, args.rval())) {
309 0 : return false;
310 : }
311 0 : break;
312 : } while (0);
313 : }
314 : { // And now store things in the compartment of our slotStorage.
315 0 : JSAutoCompartment ac(cx, slotStorage);
316 : // Make a copy so that we don't do unnecessary wrapping on args.rval().
317 0 : JS::Rooted<JS::Value> storedVal(cx, args.rval());
318 0 : if (!MaybeWrapValue(cx, &storedVal)) {
319 0 : return false;
320 : }
321 0 : js::SetReservedSlot(slotStorage, slotIndex, storedVal);
322 0 : PreserveWrapper(self);
323 : }
324 : // And now make sure args.rval() is in the caller compartment
325 0 : return MaybeWrapValue(cx, args.rval());
326 : }
327 :
328 : static const JSJitInfo platform_getterinfo = {
329 : { (JSJitGetterOp)get_platform },
330 : { prototypes::id::WorkerNavigator },
331 : { PrototypeTraits<prototypes::id::WorkerNavigator>::Depth },
332 : JSJitInfo::Getter,
333 : JSJitInfo::AliasNone, /* aliasSet. Not relevant for setters. */
334 : JSVAL_TYPE_STRING, /* returnType. Not relevant for setters. */
335 : false, /* isInfallible. False in setters. */
336 : false, /* isMovable. Not relevant for setters. */
337 : false, /* isEliminatable. Not relevant for setters. */
338 : false, /* isAlwaysInSlot. Only relevant for getters. */
339 : true, /* isLazilyCachedInSlot. Only relevant for getters. */
340 : false, /* isTypedMethod. Only relevant for methods. */
341 : (DOM_INSTANCE_RESERVED_SLOTS + 3) /* Reserved slot index, if we're stored in a slot, else 0. */
342 : };
343 : static_assert((DOM_INSTANCE_RESERVED_SLOTS + 3) <= JSJitInfo::maxSlotIndex, "We won't fit");
344 : static_assert((DOM_INSTANCE_RESERVED_SLOTS + 3) < 9, "There is no slot for us");
345 :
346 : static bool
347 0 : get_userAgent(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::WorkerNavigator* self, JSJitGetterCallArgs args)
348 : {
349 : // Have to either root across the getter call or reget after.
350 0 : JS::Rooted<JSObject*> slotStorage(cx, js::UncheckedUnwrap(obj, /* stopAtWindowProxy = */ false));
351 0 : MOZ_ASSERT(IsDOMObject(slotStorage));
352 0 : const size_t slotIndex = (DOM_INSTANCE_RESERVED_SLOTS + 4);
353 0 : MOZ_ASSERT(JSCLASS_RESERVED_SLOTS(js::GetObjectClass(slotStorage)) > slotIndex);
354 : {
355 : // Scope for cachedVal
356 0 : JS::Value cachedVal = js::GetReservedSlot(slotStorage, slotIndex);
357 0 : if (!cachedVal.isUndefined()) {
358 0 : args.rval().set(cachedVal);
359 : // The cached value is in the compartment of slotStorage,
360 : // so wrap into the caller compartment as needed.
361 0 : return MaybeWrapValue(cx, args.rval());
362 : }
363 : }
364 :
365 0 : binding_detail::FastErrorResult rv;
366 0 : DOMString result;
367 0 : self->GetUserAgent(result, nsContentUtils::ThreadsafeIsSystemCaller(cx) ? CallerType::System : CallerType::NonSystem, rv);
368 0 : if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
369 0 : return false;
370 : }
371 0 : MOZ_ASSERT(!JS_IsExceptionPending(cx));
372 : {
373 0 : JS::Rooted<JSObject*> conversionScope(cx, slotStorage);
374 0 : JSAutoCompartment ac(cx, conversionScope);
375 : do { // block we break out of when done wrapping
376 0 : if (!xpc::NonVoidStringToJsval(cx, result, args.rval())) {
377 0 : return false;
378 : }
379 0 : break;
380 : } while (0);
381 : }
382 : { // And now store things in the compartment of our slotStorage.
383 0 : JSAutoCompartment ac(cx, slotStorage);
384 : // Make a copy so that we don't do unnecessary wrapping on args.rval().
385 0 : JS::Rooted<JS::Value> storedVal(cx, args.rval());
386 0 : if (!MaybeWrapValue(cx, &storedVal)) {
387 0 : return false;
388 : }
389 0 : js::SetReservedSlot(slotStorage, slotIndex, storedVal);
390 0 : PreserveWrapper(self);
391 : }
392 : // And now make sure args.rval() is in the caller compartment
393 0 : return MaybeWrapValue(cx, args.rval());
394 : }
395 :
396 : static const JSJitInfo userAgent_getterinfo = {
397 : { (JSJitGetterOp)get_userAgent },
398 : { prototypes::id::WorkerNavigator },
399 : { PrototypeTraits<prototypes::id::WorkerNavigator>::Depth },
400 : JSJitInfo::Getter,
401 : JSJitInfo::AliasDOMSets, /* aliasSet. Not relevant for setters. */
402 : JSVAL_TYPE_STRING, /* returnType. Not relevant for setters. */
403 : false, /* isInfallible. False in setters. */
404 : false, /* isMovable. Not relevant for setters. */
405 : false, /* isEliminatable. Not relevant for setters. */
406 : false, /* isAlwaysInSlot. Only relevant for getters. */
407 : true, /* isLazilyCachedInSlot. Only relevant for getters. */
408 : false, /* isTypedMethod. Only relevant for methods. */
409 : (DOM_INSTANCE_RESERVED_SLOTS + 4) /* Reserved slot index, if we're stored in a slot, else 0. */
410 : };
411 : static_assert((DOM_INSTANCE_RESERVED_SLOTS + 4) <= JSJitInfo::maxSlotIndex, "We won't fit");
412 : static_assert((DOM_INSTANCE_RESERVED_SLOTS + 4) < 9, "There is no slot for us");
413 :
414 : static bool
415 0 : get_product(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::WorkerNavigator* self, JSJitGetterCallArgs args)
416 : {
417 : // Have to either root across the getter call or reget after.
418 0 : JS::Rooted<JSObject*> slotStorage(cx, js::UncheckedUnwrap(obj, /* stopAtWindowProxy = */ false));
419 0 : MOZ_ASSERT(IsDOMObject(slotStorage));
420 0 : const size_t slotIndex = (DOM_INSTANCE_RESERVED_SLOTS + 5);
421 0 : MOZ_ASSERT(JSCLASS_RESERVED_SLOTS(js::GetObjectClass(slotStorage)) > slotIndex);
422 : {
423 : // Scope for cachedVal
424 0 : JS::Value cachedVal = js::GetReservedSlot(slotStorage, slotIndex);
425 0 : if (!cachedVal.isUndefined()) {
426 0 : args.rval().set(cachedVal);
427 : // The cached value is in the compartment of slotStorage,
428 : // so wrap into the caller compartment as needed.
429 0 : return MaybeWrapValue(cx, args.rval());
430 : }
431 : }
432 :
433 0 : DOMString result;
434 0 : self->GetProduct(result);
435 0 : MOZ_ASSERT(!JS_IsExceptionPending(cx));
436 : {
437 0 : JS::Rooted<JSObject*> conversionScope(cx, slotStorage);
438 0 : JSAutoCompartment ac(cx, conversionScope);
439 : do { // block we break out of when done wrapping
440 0 : if (!xpc::NonVoidStringToJsval(cx, result, args.rval())) {
441 0 : return false;
442 : }
443 0 : break;
444 : } while (0);
445 : }
446 : { // And now store things in the compartment of our slotStorage.
447 0 : JSAutoCompartment ac(cx, slotStorage);
448 : // Make a copy so that we don't do unnecessary wrapping on args.rval().
449 0 : JS::Rooted<JS::Value> storedVal(cx, args.rval());
450 0 : if (!MaybeWrapValue(cx, &storedVal)) {
451 0 : return false;
452 : }
453 0 : js::SetReservedSlot(slotStorage, slotIndex, storedVal);
454 0 : PreserveWrapper(self);
455 : }
456 : // And now make sure args.rval() is in the caller compartment
457 0 : return MaybeWrapValue(cx, args.rval());
458 : }
459 :
460 : static const JSJitInfo product_getterinfo = {
461 : { (JSJitGetterOp)get_product },
462 : { prototypes::id::WorkerNavigator },
463 : { PrototypeTraits<prototypes::id::WorkerNavigator>::Depth },
464 : JSJitInfo::Getter,
465 : JSJitInfo::AliasNone, /* aliasSet. Not relevant for setters. */
466 : JSVAL_TYPE_STRING, /* returnType. Not relevant for setters. */
467 : false, /* isInfallible. False in setters. */
468 : true, /* isMovable. Not relevant for setters. */
469 : true, /* isEliminatable. Not relevant for setters. */
470 : false, /* isAlwaysInSlot. Only relevant for getters. */
471 : true, /* isLazilyCachedInSlot. Only relevant for getters. */
472 : false, /* isTypedMethod. Only relevant for methods. */
473 : (DOM_INSTANCE_RESERVED_SLOTS + 5) /* Reserved slot index, if we're stored in a slot, else 0. */
474 : };
475 : static_assert((DOM_INSTANCE_RESERVED_SLOTS + 5) <= JSJitInfo::maxSlotIndex, "We won't fit");
476 : static_assert((DOM_INSTANCE_RESERVED_SLOTS + 5) < 9, "There is no slot for us");
477 :
478 : static bool
479 0 : taintEnabled(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::WorkerNavigator* self, const JSJitMethodCallArgs& args)
480 : {
481 0 : bool result(self->TaintEnabled());
482 0 : MOZ_ASSERT(!JS_IsExceptionPending(cx));
483 0 : args.rval().setBoolean(result);
484 0 : return true;
485 : }
486 :
487 : static const JSJitInfo taintEnabled_methodinfo = {
488 : { (JSJitGetterOp)taintEnabled },
489 : { prototypes::id::WorkerNavigator },
490 : { PrototypeTraits<prototypes::id::WorkerNavigator>::Depth },
491 : JSJitInfo::Method,
492 : JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */
493 : JSVAL_TYPE_BOOLEAN, /* returnType. Not relevant for setters. */
494 : true, /* isInfallible. False in setters. */
495 : false, /* isMovable. Not relevant for setters. */
496 : false, /* isEliminatable. Not relevant for setters. */
497 : false, /* isAlwaysInSlot. Only relevant for getters. */
498 : false, /* isLazilyCachedInSlot. Only relevant for getters. */
499 : false, /* isTypedMethod. Only relevant for methods. */
500 : 0 /* Reserved slot index, if we're stored in a slot, else 0. */
501 : };
502 : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
503 : static_assert(0 < 9, "There is no slot for us");
504 :
505 : static bool
506 0 : get_language(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::WorkerNavigator* self, JSJitGetterCallArgs args)
507 : {
508 : // Have to either root across the getter call or reget after.
509 0 : JS::Rooted<JSObject*> slotStorage(cx, js::UncheckedUnwrap(obj, /* stopAtWindowProxy = */ false));
510 0 : MOZ_ASSERT(IsDOMObject(slotStorage));
511 0 : const size_t slotIndex = (DOM_INSTANCE_RESERVED_SLOTS + 6);
512 0 : MOZ_ASSERT(JSCLASS_RESERVED_SLOTS(js::GetObjectClass(slotStorage)) > slotIndex);
513 : {
514 : // Scope for cachedVal
515 0 : JS::Value cachedVal = js::GetReservedSlot(slotStorage, slotIndex);
516 0 : if (!cachedVal.isUndefined()) {
517 0 : args.rval().set(cachedVal);
518 : // The cached value is in the compartment of slotStorage,
519 : // so wrap into the caller compartment as needed.
520 0 : return MaybeWrapValue(cx, args.rval());
521 : }
522 : }
523 :
524 0 : DOMString result;
525 0 : self->GetLanguage(result);
526 0 : MOZ_ASSERT(!JS_IsExceptionPending(cx));
527 : {
528 0 : JS::Rooted<JSObject*> conversionScope(cx, slotStorage);
529 0 : JSAutoCompartment ac(cx, conversionScope);
530 : do { // block we break out of when done wrapping
531 0 : if (!xpc::StringToJsval(cx, result, args.rval())) {
532 0 : return false;
533 : }
534 0 : break;
535 : } while (0);
536 : }
537 : { // And now store things in the compartment of our slotStorage.
538 0 : JSAutoCompartment ac(cx, slotStorage);
539 : // Make a copy so that we don't do unnecessary wrapping on args.rval().
540 0 : JS::Rooted<JS::Value> storedVal(cx, args.rval());
541 0 : if (!MaybeWrapValue(cx, &storedVal)) {
542 0 : return false;
543 : }
544 0 : js::SetReservedSlot(slotStorage, slotIndex, storedVal);
545 0 : PreserveWrapper(self);
546 : }
547 : // And now make sure args.rval() is in the caller compartment
548 0 : return MaybeWrapValue(cx, args.rval());
549 : }
550 :
551 : static const JSJitInfo language_getterinfo = {
552 : { (JSJitGetterOp)get_language },
553 : { prototypes::id::WorkerNavigator },
554 : { PrototypeTraits<prototypes::id::WorkerNavigator>::Depth },
555 : JSJitInfo::Getter,
556 : JSJitInfo::AliasDOMSets, /* aliasSet. Not relevant for setters. */
557 : JSVAL_TYPE_UNKNOWN, /* returnType. Not relevant for setters. */
558 : false, /* isInfallible. False in setters. */
559 : true, /* isMovable. Not relevant for setters. */
560 : true, /* isEliminatable. Not relevant for setters. */
561 : false, /* isAlwaysInSlot. Only relevant for getters. */
562 : true, /* isLazilyCachedInSlot. Only relevant for getters. */
563 : false, /* isTypedMethod. Only relevant for methods. */
564 : (DOM_INSTANCE_RESERVED_SLOTS + 6) /* Reserved slot index, if we're stored in a slot, else 0. */
565 : };
566 : static_assert((DOM_INSTANCE_RESERVED_SLOTS + 6) <= JSJitInfo::maxSlotIndex, "We won't fit");
567 : static_assert((DOM_INSTANCE_RESERVED_SLOTS + 6) < 9, "There is no slot for us");
568 :
569 : static bool
570 0 : get_languages(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::WorkerNavigator* self, JSJitGetterCallArgs args)
571 : {
572 : // Have to either root across the getter call or reget after.
573 0 : JS::Rooted<JSObject*> slotStorage(cx, js::UncheckedUnwrap(obj, /* stopAtWindowProxy = */ false));
574 0 : MOZ_ASSERT(IsDOMObject(slotStorage));
575 0 : const size_t slotIndex = (DOM_INSTANCE_RESERVED_SLOTS + 7);
576 0 : MOZ_ASSERT(JSCLASS_RESERVED_SLOTS(js::GetObjectClass(slotStorage)) > slotIndex);
577 : {
578 : // Scope for cachedVal
579 0 : JS::Value cachedVal = js::GetReservedSlot(slotStorage, slotIndex);
580 0 : if (!cachedVal.isUndefined()) {
581 0 : args.rval().set(cachedVal);
582 : // The cached value is in the compartment of slotStorage,
583 : // so wrap into the caller compartment as needed.
584 0 : return MaybeWrapNonDOMObjectValue(cx, args.rval());
585 : }
586 : }
587 :
588 0 : nsTArray<nsString> result;
589 0 : self->GetLanguages(result);
590 0 : MOZ_ASSERT(!JS_IsExceptionPending(cx));
591 : {
592 0 : JS::Rooted<JSObject*> conversionScope(cx, slotStorage);
593 0 : JSAutoCompartment ac(cx, conversionScope);
594 : do { // block we break out of when done wrapping
595 :
596 0 : uint32_t length = result.Length();
597 0 : JS::Rooted<JSObject*> returnArray(cx, JS_NewArrayObject(cx, length));
598 0 : if (!returnArray) {
599 0 : return false;
600 : }
601 : // Scope for 'tmp'
602 : {
603 0 : JS::Rooted<JS::Value> tmp(cx);
604 0 : for (uint32_t sequenceIdx0 = 0; sequenceIdx0 < length; ++sequenceIdx0) {
605 : // Control block to let us common up the JS_DefineElement calls when there
606 : // are different ways to succeed at wrapping the object.
607 : do {
608 0 : if (!xpc::NonVoidStringToJsval(cx, result[sequenceIdx0], &tmp)) {
609 0 : return false;
610 : }
611 0 : break;
612 : } while (0);
613 0 : if (!JS_DefineElement(cx, returnArray, sequenceIdx0, tmp,
614 : JSPROP_ENUMERATE)) {
615 0 : return false;
616 : }
617 : }
618 : }
619 0 : args.rval().setObject(*returnArray);
620 0 : break;
621 : } while (0);
622 0 : JS::Rooted<JSObject*> rvalObj(cx, &args.rval().toObject());
623 0 : if (!JS_FreezeObject(cx, rvalObj)) {
624 0 : return false;
625 : }
626 : }
627 : { // And now store things in the compartment of our slotStorage.
628 0 : JSAutoCompartment ac(cx, slotStorage);
629 : // Make a copy so that we don't do unnecessary wrapping on args.rval().
630 0 : JS::Rooted<JS::Value> storedVal(cx, args.rval());
631 0 : if (!MaybeWrapNonDOMObjectValue(cx, &storedVal)) {
632 0 : return false;
633 : }
634 0 : js::SetReservedSlot(slotStorage, slotIndex, storedVal);
635 0 : PreserveWrapper(self);
636 : }
637 : // And now make sure args.rval() is in the caller compartment
638 0 : return MaybeWrapNonDOMObjectValue(cx, args.rval());
639 : }
640 :
641 : static const JSJitInfo languages_getterinfo = {
642 : { (JSJitGetterOp)get_languages },
643 : { prototypes::id::WorkerNavigator },
644 : { PrototypeTraits<prototypes::id::WorkerNavigator>::Depth },
645 : JSJitInfo::Getter,
646 : JSJitInfo::AliasDOMSets, /* aliasSet. Not relevant for setters. */
647 : JSVAL_TYPE_OBJECT, /* returnType. Not relevant for setters. */
648 : false, /* isInfallible. False in setters. */
649 : true, /* isMovable. Not relevant for setters. */
650 : true, /* isEliminatable. Not relevant for setters. */
651 : false, /* isAlwaysInSlot. Only relevant for getters. */
652 : true, /* isLazilyCachedInSlot. Only relevant for getters. */
653 : false, /* isTypedMethod. Only relevant for methods. */
654 : (DOM_INSTANCE_RESERVED_SLOTS + 7) /* Reserved slot index, if we're stored in a slot, else 0. */
655 : };
656 : static_assert((DOM_INSTANCE_RESERVED_SLOTS + 7) <= JSJitInfo::maxSlotIndex, "We won't fit");
657 : static_assert((DOM_INSTANCE_RESERVED_SLOTS + 7) < 9, "There is no slot for us");
658 :
659 : static bool
660 0 : get_onLine(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::WorkerNavigator* self, JSJitGetterCallArgs args)
661 : {
662 0 : bool result(self->OnLine());
663 0 : MOZ_ASSERT(!JS_IsExceptionPending(cx));
664 0 : args.rval().setBoolean(result);
665 0 : return true;
666 : }
667 :
668 : static const JSJitInfo onLine_getterinfo = {
669 : { (JSJitGetterOp)get_onLine },
670 : { prototypes::id::WorkerNavigator },
671 : { PrototypeTraits<prototypes::id::WorkerNavigator>::Depth },
672 : JSJitInfo::Getter,
673 : JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */
674 : JSVAL_TYPE_BOOLEAN, /* returnType. Not relevant for setters. */
675 : true, /* isInfallible. False in setters. */
676 : false, /* isMovable. Not relevant for setters. */
677 : false, /* isEliminatable. Not relevant for setters. */
678 : false, /* isAlwaysInSlot. Only relevant for getters. */
679 : false, /* isLazilyCachedInSlot. Only relevant for getters. */
680 : false, /* isTypedMethod. Only relevant for methods. */
681 : 0 /* Reserved slot index, if we're stored in a slot, else 0. */
682 : };
683 : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
684 : static_assert(0 < 9, "There is no slot for us");
685 :
686 : static bool
687 0 : get_storage(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::WorkerNavigator* self, JSJitGetterCallArgs args)
688 : {
689 0 : auto result(StrongOrRawPtr<mozilla::dom::StorageManager>(self->Storage()));
690 0 : MOZ_ASSERT(!JS_IsExceptionPending(cx));
691 0 : if (!GetOrCreateDOMReflector(cx, result, args.rval())) {
692 0 : MOZ_ASSERT(true || JS_IsExceptionPending(cx));
693 0 : return false;
694 : }
695 0 : return true;
696 : }
697 :
698 : static const JSJitInfo storage_getterinfo = {
699 : { (JSJitGetterOp)get_storage },
700 : { prototypes::id::WorkerNavigator },
701 : { PrototypeTraits<prototypes::id::WorkerNavigator>::Depth },
702 : JSJitInfo::Getter,
703 : JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */
704 : JSVAL_TYPE_OBJECT, /* returnType. Not relevant for setters. */
705 : false, /* isInfallible. False in setters. */
706 : false, /* isMovable. Not relevant for setters. */
707 : false, /* isEliminatable. Not relevant for setters. */
708 : false, /* isAlwaysInSlot. Only relevant for getters. */
709 : false, /* isLazilyCachedInSlot. Only relevant for getters. */
710 : false, /* isTypedMethod. Only relevant for methods. */
711 : 0 /* Reserved slot index, if we're stored in a slot, else 0. */
712 : };
713 : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
714 : static_assert(0 < 9, "There is no slot for us");
715 :
716 : static bool
717 0 : _addProperty(JSContext* cx, JS::Handle<JSObject*> obj, JS::Handle<jsid> id, JS::Handle<JS::Value> val)
718 : {
719 0 : mozilla::dom::WorkerNavigator* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::WorkerNavigator>(obj);
720 : // We don't want to preserve if we don't have a wrapper, and we
721 : // obviously can't preserve if we're not initialized.
722 0 : if (self && self->GetWrapperPreserveColor()) {
723 0 : PreserveWrapper(self);
724 : }
725 0 : return true;
726 : }
727 :
728 : static void
729 0 : _finalize(js::FreeOp* fop, JSObject* obj)
730 : {
731 0 : mozilla::dom::WorkerNavigator* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::WorkerNavigator>(obj);
732 0 : if (self) {
733 0 : ClearWrapper(self, self, obj);
734 0 : AddForDeferredFinalization<mozilla::dom::WorkerNavigator>(self);
735 : }
736 0 : }
737 :
738 : static void
739 0 : _objectMoved(JSObject* obj, const JSObject* old)
740 : {
741 0 : mozilla::dom::WorkerNavigator* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::WorkerNavigator>(obj);
742 0 : if (self) {
743 0 : UpdateWrapper(self, self, obj, old);
744 : }
745 0 : }
746 :
747 : // We deliberately use brace-elision to make Visual Studio produce better initalization code.
748 : #if defined(__clang__)
749 : #pragma clang diagnostic push
750 : #pragma clang diagnostic ignored "-Wmissing-braces"
751 : #endif
752 : static const JSFunctionSpec sMethods_specs[] = {
753 : JS_FNSPEC("taintEnabled", GenericBindingMethod, reinterpret_cast<const JSJitInfo*>(&taintEnabled_methodinfo), 0, JSPROP_ENUMERATE, nullptr),
754 : JS_FS_END
755 : };
756 : #if defined(__clang__)
757 : #pragma clang diagnostic pop
758 : #endif
759 :
760 : static PrefableDisablers sMethods_disablers0 = {
761 : true, false, GlobalNames::DedicatedWorkerGlobalScope | GlobalNames::ServiceWorkerGlobalScope | GlobalNames::SharedWorkerGlobalScope, nullptr
762 : };
763 :
764 : // Can't be const because the pref-enabled boolean needs to be writable
765 : static Prefable<const JSFunctionSpec> sMethods[] = {
766 : { &sMethods_disablers0, &sMethods_specs[0] },
767 : { nullptr, nullptr }
768 : };
769 :
770 : // We deliberately use brace-elision to make Visual Studio produce better initalization code.
771 : #if defined(__clang__)
772 : #pragma clang diagnostic push
773 : #pragma clang diagnostic ignored "-Wmissing-braces"
774 : #endif
775 : static const JSPropertySpec sAttributes_specs[] = {
776 : { "connection", JSPROP_SHARED | JSPROP_ENUMERATE, GenericBindingGetter, &connection_getterinfo, nullptr, nullptr },
777 : { nullptr, 0, nullptr, nullptr, nullptr, nullptr },
778 : { "hardwareConcurrency", JSPROP_SHARED | JSPROP_ENUMERATE, GenericBindingGetter, &hardwareConcurrency_getterinfo, nullptr, nullptr },
779 : { "appCodeName", JSPROP_SHARED | JSPROP_ENUMERATE, GenericBindingGetter, &appCodeName_getterinfo, nullptr, nullptr },
780 : { "appName", JSPROP_SHARED | JSPROP_ENUMERATE, GenericBindingGetter, &appName_getterinfo, nullptr, nullptr },
781 : { "appVersion", JSPROP_SHARED | JSPROP_ENUMERATE, GenericBindingGetter, &appVersion_getterinfo, nullptr, nullptr },
782 : { "platform", JSPROP_SHARED | JSPROP_ENUMERATE, GenericBindingGetter, &platform_getterinfo, nullptr, nullptr },
783 : { "userAgent", JSPROP_SHARED | JSPROP_ENUMERATE, GenericBindingGetter, &userAgent_getterinfo, nullptr, nullptr },
784 : { "product", JSPROP_SHARED | JSPROP_ENUMERATE, GenericBindingGetter, &product_getterinfo, nullptr, nullptr },
785 : { "language", JSPROP_SHARED | JSPROP_ENUMERATE, GenericBindingGetter, &language_getterinfo, nullptr, nullptr },
786 : { "languages", JSPROP_SHARED | JSPROP_ENUMERATE, GenericBindingGetter, &languages_getterinfo, nullptr, nullptr },
787 : { "onLine", JSPROP_SHARED | JSPROP_ENUMERATE, GenericBindingGetter, &onLine_getterinfo, nullptr, nullptr },
788 : { nullptr, 0, nullptr, nullptr, nullptr, nullptr },
789 : { "storage", JSPROP_SHARED | JSPROP_ENUMERATE, GenericBindingGetter, &storage_getterinfo, nullptr, nullptr },
790 : { nullptr, 0, nullptr, nullptr, nullptr, nullptr }
791 : };
792 : #if defined(__clang__)
793 : #pragma clang diagnostic pop
794 : #endif
795 :
796 : static PrefableDisablers sAttributes_disablers0 = {
797 : true, false, 0, &mozilla::dom::network::Connection::IsEnabled
798 : };
799 :
800 : static PrefableDisablers sAttributes_disablers13 = {
801 : true, true, 0, &mozilla::dom::StorageManager::PrefEnabled
802 : };
803 :
804 : // Can't be const because the pref-enabled boolean needs to be writable
805 : static Prefable<const JSPropertySpec> sAttributes[] = {
806 : { &sAttributes_disablers0, &sAttributes_specs[0] },
807 : { nullptr, &sAttributes_specs[2] },
808 : { &sAttributes_disablers13, &sAttributes_specs[13] },
809 : { nullptr, nullptr }
810 : };
811 :
812 :
813 : static const NativePropertiesN<2> sNativeProperties = {
814 : false, 0,
815 : false, 0,
816 : true, 0 /* sMethods */,
817 : true, 1 /* sAttributes */,
818 : false, 0,
819 : false, 0,
820 : false, 0,
821 : -1,
822 : 0,
823 : nullptr,
824 : {
825 : { sMethods, nullptr },
826 : { sAttributes, nullptr }
827 : }
828 : };
829 :
830 : static const DOMIfaceAndProtoJSClass sInterfaceObjectClass = {
831 : {
832 : "Function",
833 : JSCLASS_IS_DOMIFACEANDPROTOJSCLASS | JSCLASS_HAS_RESERVED_SLOTS(DOM_INTERFACE_SLOTS_BASE),
834 : &sBoringInterfaceObjectClassClassOps,
835 : JS_NULL_CLASS_SPEC,
836 : JS_NULL_CLASS_EXT,
837 : &sInterfaceObjectClassObjectOps
838 : },
839 : eInterface,
840 : true,
841 : prototypes::id::WorkerNavigator,
842 : PrototypeTraits<prototypes::id::WorkerNavigator>::Depth,
843 : &sEmptyNativePropertyHooks,
844 : "function WorkerNavigator() {\n [native code]\n}",
845 : JS::GetRealmFunctionPrototype
846 : };
847 :
848 : static const DOMIfaceAndProtoJSClass sPrototypeClass = {
849 : {
850 : "WorkerNavigatorPrototype",
851 : JSCLASS_IS_DOMIFACEANDPROTOJSCLASS | JSCLASS_HAS_RESERVED_SLOTS(DOM_INTERFACE_PROTO_SLOTS_BASE),
852 : JS_NULL_CLASS_OPS,
853 : JS_NULL_CLASS_SPEC,
854 : JS_NULL_CLASS_EXT,
855 : JS_NULL_OBJECT_OPS
856 : },
857 : eInterfacePrototype,
858 : false,
859 : prototypes::id::WorkerNavigator,
860 : PrototypeTraits<prototypes::id::WorkerNavigator>::Depth,
861 : &sEmptyNativePropertyHooks,
862 : "[object WorkerNavigatorPrototype]",
863 : JS::GetRealmObjectPrototype
864 : };
865 :
866 : static const js::ClassOps sClassOps = {
867 : _addProperty, /* addProperty */
868 : nullptr, /* delProperty */
869 : nullptr, /* getProperty */
870 : nullptr, /* setProperty */
871 : nullptr, /* enumerate */
872 : nullptr, /* newEnumerate */
873 : nullptr, /* resolve */
874 : nullptr, /* mayResolve */
875 : _finalize, /* finalize */
876 : nullptr, /* call */
877 : nullptr, /* hasInstance */
878 : nullptr, /* construct */
879 : nullptr, /* trace */
880 : };
881 :
882 : static const js::ClassExtension sClassExtension = {
883 : nullptr, /* weakmapKeyDelegateOp */
884 : _objectMoved /* objectMovedOp */
885 : };
886 :
887 : static const DOMJSClass sClass = {
888 : { "WorkerNavigator",
889 : JSCLASS_IS_DOMJSCLASS | JSCLASS_FOREGROUND_FINALIZE | JSCLASS_HAS_RESERVED_SLOTS(9),
890 : &sClassOps,
891 : JS_NULL_CLASS_SPEC,
892 : &sClassExtension,
893 : JS_NULL_OBJECT_OPS
894 : },
895 : { prototypes::id::WorkerNavigator, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count },
896 : IsBaseOf<nsISupports, mozilla::dom::WorkerNavigator >::value,
897 : &sEmptyNativePropertyHooks,
898 : FindAssociatedGlobalForNative<mozilla::dom::WorkerNavigator>::Get,
899 : GetProtoObjectHandle,
900 : GetCCParticipant<mozilla::dom::WorkerNavigator>::Get()
901 : };
902 : static_assert(1 == DOM_INSTANCE_RESERVED_SLOTS,
903 : "Must have the right minimal number of reserved slots.");
904 : static_assert(9 >= 9,
905 : "Must have enough reserved slots.");
906 :
907 : const JSClass*
908 0 : GetJSClass()
909 : {
910 0 : return sClass.ToJSClass();
911 : }
912 :
913 : bool
914 0 : Wrap(JSContext* aCx, mozilla::dom::WorkerNavigator* aObject, nsWrapperCache* aCache, JS::Handle<JSObject*> aGivenProto, JS::MutableHandle<JSObject*> aReflector)
915 : {
916 : MOZ_ASSERT(static_cast<mozilla::dom::WorkerNavigator*>(aObject) ==
917 : reinterpret_cast<mozilla::dom::WorkerNavigator*>(aObject),
918 : "Multiple inheritance for mozilla::dom::WorkerNavigator is broken.");
919 0 : MOZ_ASSERT(ToSupportsIsCorrect(aObject));
920 0 : MOZ_ASSERT_IF(aGivenProto, js::IsObjectInContextCompartment(aGivenProto, aCx));
921 0 : MOZ_ASSERT(!aCache->GetWrapper(),
922 : "You should probably not be using Wrap() directly; use "
923 : "GetOrCreateDOMReflector instead");
924 :
925 0 : MOZ_ASSERT(ToSupportsIsOnPrimaryInheritanceChain(aObject, aCache),
926 : "nsISupports must be on our primary inheritance chain");
927 :
928 0 : JS::Rooted<JSObject*> global(aCx, FindAssociatedGlobal(aCx, aObject->GetParentObject()));
929 0 : if (!global) {
930 0 : return false;
931 : }
932 0 : MOZ_ASSERT(JS_IsGlobalObject(global));
933 0 : MOZ_ASSERT(JS::ObjectIsNotGray(global));
934 :
935 : // That might have ended up wrapping us already, due to the wonders
936 : // of XBL. Check for that, and bail out as needed.
937 0 : aReflector.set(aCache->GetWrapper());
938 0 : if (aReflector) {
939 : #ifdef DEBUG
940 0 : binding_detail::AssertReflectorHasGivenProto(aCx, aReflector, aGivenProto);
941 : #endif // DEBUG
942 0 : return true;
943 : }
944 :
945 0 : JSAutoCompartment ac(aCx, global);
946 0 : JS::Handle<JSObject*> canonicalProto = GetProtoObjectHandle(aCx);
947 0 : if (!canonicalProto) {
948 0 : return false;
949 : }
950 0 : JS::Rooted<JSObject*> proto(aCx);
951 0 : if (aGivenProto) {
952 0 : proto = aGivenProto;
953 : // Unfortunately, while aGivenProto was in the compartment of aCx
954 : // coming in, we changed compartments to that of "parent" so may need
955 : // to wrap the proto here.
956 0 : if (js::GetContextCompartment(aCx) != js::GetObjectCompartment(proto)) {
957 0 : if (!JS_WrapObject(aCx, &proto)) {
958 0 : return false;
959 : }
960 : }
961 : } else {
962 0 : proto = canonicalProto;
963 : }
964 :
965 0 : BindingJSObjectCreator<mozilla::dom::WorkerNavigator> creator(aCx);
966 0 : creator.CreateObject(aCx, sClass.ToJSClass(), proto, aObject, aReflector);
967 0 : if (!aReflector) {
968 0 : return false;
969 : }
970 :
971 0 : aCache->SetWrapper(aReflector);
972 0 : creator.InitializationSucceeded();
973 :
974 0 : MOZ_ASSERT(aCache->GetWrapperPreserveColor() &&
975 : aCache->GetWrapperPreserveColor() == aReflector);
976 : // If proto != canonicalProto, we have to preserve our wrapper;
977 : // otherwise we won't be able to properly recreate it later, since
978 : // we won't know what proto to use. Note that we don't check
979 : // aGivenProto here, since it's entirely possible (and even
980 : // somewhat common) to have a non-null aGivenProto which is the
981 : // same as canonicalProto.
982 0 : if (proto != canonicalProto) {
983 0 : PreserveWrapper(aObject);
984 : }
985 :
986 0 : return true;
987 : }
988 :
989 : void
990 0 : ClearCachedUserAgentValue(mozilla::dom::WorkerNavigator* aObject)
991 : {
992 : JSObject* obj;
993 0 : obj = aObject->GetWrapper();
994 0 : if (!obj) {
995 0 : return;
996 : }
997 0 : js::SetReservedSlot(obj, (DOM_INSTANCE_RESERVED_SLOTS + 4), JS::UndefinedValue());
998 : }
999 :
1000 : void
1001 0 : ClearCachedLanguageValue(mozilla::dom::WorkerNavigator* aObject)
1002 : {
1003 : JSObject* obj;
1004 0 : obj = aObject->GetWrapper();
1005 0 : if (!obj) {
1006 0 : return;
1007 : }
1008 0 : js::SetReservedSlot(obj, (DOM_INSTANCE_RESERVED_SLOTS + 6), JS::UndefinedValue());
1009 : }
1010 :
1011 : void
1012 0 : ClearCachedLanguagesValue(mozilla::dom::WorkerNavigator* aObject)
1013 : {
1014 : JSObject* obj;
1015 0 : obj = aObject->GetWrapper();
1016 0 : if (!obj) {
1017 0 : return;
1018 : }
1019 0 : js::SetReservedSlot(obj, (DOM_INSTANCE_RESERVED_SLOTS + 7), JS::UndefinedValue());
1020 : }
1021 :
1022 : void
1023 1 : CreateInterfaceObjects(JSContext* aCx, JS::Handle<JSObject*> aGlobal, ProtoAndIfaceCache& aProtoAndIfaceCache, bool aDefineOnGlobal)
1024 : {
1025 2 : JS::Rooted<JSObject*> parentProto(aCx, JS::GetRealmObjectPrototype(aCx));
1026 1 : if (!parentProto) {
1027 0 : return;
1028 : }
1029 :
1030 2 : JS::Rooted<JSObject*> constructorProto(aCx, JS::GetRealmFunctionPrototype(aCx));
1031 1 : if (!constructorProto) {
1032 0 : return;
1033 : }
1034 :
1035 1 : JS::Heap<JSObject*>* protoCache = &aProtoAndIfaceCache.EntrySlotOrCreate(prototypes::id::WorkerNavigator);
1036 1 : JS::Heap<JSObject*>* interfaceCache = &aProtoAndIfaceCache.EntrySlotOrCreate(constructors::id::WorkerNavigator);
1037 2 : dom::CreateInterfaceObjects(aCx, aGlobal, parentProto,
1038 : &sPrototypeClass.mBase, protoCache,
1039 : constructorProto, &sInterfaceObjectClass.mBase, 0, nullptr,
1040 : interfaceCache,
1041 : sNativeProperties.Upcast(),
1042 : nullptr,
1043 : "WorkerNavigator", aDefineOnGlobal,
1044 : nullptr,
1045 1 : false);
1046 : }
1047 :
1048 : JS::Handle<JSObject*>
1049 0 : GetProtoObjectHandle(JSContext* aCx)
1050 : {
1051 : /* Get the interface prototype object for this class. This will create the
1052 : object as needed. */
1053 0 : bool aDefineOnGlobal = true;
1054 :
1055 : /* Make sure our global is sane. Hopefully we can remove this sometime */
1056 0 : JSObject* global = JS::CurrentGlobalOrNull(aCx);
1057 0 : if (!(js::GetObjectClass(global)->flags & JSCLASS_DOM_GLOBAL)) {
1058 0 : return nullptr;
1059 : }
1060 :
1061 : /* Check to see whether the interface objects are already installed */
1062 0 : ProtoAndIfaceCache& protoAndIfaceCache = *GetProtoAndIfaceCache(global);
1063 0 : if (!protoAndIfaceCache.HasEntryInSlot(prototypes::id::WorkerNavigator)) {
1064 0 : JS::Rooted<JSObject*> rootedGlobal(aCx, global);
1065 0 : CreateInterfaceObjects(aCx, rootedGlobal, protoAndIfaceCache, aDefineOnGlobal);
1066 : }
1067 :
1068 : /*
1069 : * The object might _still_ be null, but that's OK.
1070 : *
1071 : * Calling fromMarkedLocation() is safe because protoAndIfaceCache is
1072 : * traced by TraceProtoAndIfaceCache() and its contents are never
1073 : * changed after they have been set.
1074 : *
1075 : * Calling address() avoids the read read barrier that does gray
1076 : * unmarking, but it's not possible for the object to be gray here.
1077 : */
1078 :
1079 0 : const JS::Heap<JSObject*>& entrySlot = protoAndIfaceCache.EntrySlotMustExist(prototypes::id::WorkerNavigator);
1080 0 : MOZ_ASSERT(JS::ObjectIsNotGray(entrySlot));
1081 0 : return JS::Handle<JSObject*>::fromMarkedLocation(entrySlot.address());
1082 : }
1083 :
1084 : JS::Handle<JSObject*>
1085 1 : GetConstructorObjectHandle(JSContext* aCx, bool aDefineOnGlobal)
1086 : {
1087 : /* Get the interface object for this class. This will create the object as
1088 : needed. */
1089 :
1090 : /* Make sure our global is sane. Hopefully we can remove this sometime */
1091 1 : JSObject* global = JS::CurrentGlobalOrNull(aCx);
1092 1 : if (!(js::GetObjectClass(global)->flags & JSCLASS_DOM_GLOBAL)) {
1093 0 : return nullptr;
1094 : }
1095 :
1096 : /* Check to see whether the interface objects are already installed */
1097 1 : ProtoAndIfaceCache& protoAndIfaceCache = *GetProtoAndIfaceCache(global);
1098 1 : if (!protoAndIfaceCache.HasEntryInSlot(constructors::id::WorkerNavigator)) {
1099 2 : JS::Rooted<JSObject*> rootedGlobal(aCx, global);
1100 1 : CreateInterfaceObjects(aCx, rootedGlobal, protoAndIfaceCache, aDefineOnGlobal);
1101 : }
1102 :
1103 : /*
1104 : * The object might _still_ be null, but that's OK.
1105 : *
1106 : * Calling fromMarkedLocation() is safe because protoAndIfaceCache is
1107 : * traced by TraceProtoAndIfaceCache() and its contents are never
1108 : * changed after they have been set.
1109 : *
1110 : * Calling address() avoids the read read barrier that does gray
1111 : * unmarking, but it's not possible for the object to be gray here.
1112 : */
1113 :
1114 1 : const JS::Heap<JSObject*>& entrySlot = protoAndIfaceCache.EntrySlotMustExist(constructors::id::WorkerNavigator);
1115 1 : MOZ_ASSERT(JS::ObjectIsNotGray(entrySlot));
1116 1 : return JS::Handle<JSObject*>::fromMarkedLocation(entrySlot.address());
1117 : }
1118 :
1119 : JSObject*
1120 1 : GetConstructorObject(JSContext* aCx)
1121 : {
1122 1 : return GetConstructorObjectHandle(aCx);
1123 : }
1124 :
1125 : } // namespace WorkerNavigatorBinding
1126 :
1127 :
1128 :
1129 : } // namespace dom
1130 : } // namespace mozilla
|