/work/obj-fuzz/dom/bindings/SharedWorkerGlobalScopeBinding.cpp
Line | Count | Source (jump to first uncovered line) |
1 | | /* THIS FILE IS AUTOGENERATED FROM SharedWorkerGlobalScope.webidl BY Codegen.py - DO NOT EDIT */ |
2 | | |
3 | | #include "EventHandlerBinding.h" |
4 | | #include "SharedWorkerGlobalScopeBinding.h" |
5 | | #include "WorkerGlobalScopeBinding.h" |
6 | | #include "WrapperFactory.h" |
7 | | #include "mozilla/OwningNonNull.h" |
8 | | #include "mozilla/dom/BindingUtils.h" |
9 | | #include "mozilla/dom/DOMJSClass.h" |
10 | | #include "mozilla/dom/NonRefcountedDOMObject.h" |
11 | | #include "mozilla/dom/Nullable.h" |
12 | | #include "mozilla/dom/WorkerScope.h" |
13 | | #include "nsThreadUtils.h" |
14 | | |
15 | | namespace mozilla { |
16 | | namespace dom { |
17 | | |
18 | | namespace binding_detail {}; // Just to make sure it's known as a namespace |
19 | | using namespace mozilla::dom::binding_detail; |
20 | | |
21 | | |
22 | | namespace SharedWorkerGlobalScope_Binding { |
23 | | |
24 | | static_assert(IsRefcounted<NativeType>::value == IsRefcounted<WorkerGlobalScope_Binding::NativeType>::value, |
25 | | "Can't inherit from an interface with a different ownership model."); |
26 | | |
27 | | MOZ_CAN_RUN_SCRIPT static bool |
28 | | get_name(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::SharedWorkerGlobalScope* self, JSJitGetterCallArgs args) |
29 | 0 | { |
30 | 0 | AUTO_PROFILER_LABEL_FAST("get SharedWorkerGlobalScope.name", DOM, cx); |
31 | 0 |
|
32 | 0 | DOMString result; |
33 | 0 | self->GetName(result); |
34 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
35 | 0 | if (!xpc::NonVoidStringToJsval(cx, result, args.rval())) { |
36 | 0 | return false; |
37 | 0 | } |
38 | 0 | return true; |
39 | 0 | } |
40 | | |
41 | | MOZ_CAN_RUN_SCRIPT static bool |
42 | | set_name(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::SharedWorkerGlobalScope* self, JSJitSetterCallArgs args) |
43 | 0 | { |
44 | 0 | AUTO_PROFILER_LABEL_FAST("set SharedWorkerGlobalScope.name", DOM, cx); |
45 | 0 |
|
46 | 0 | return JS_DefineProperty(cx, obj, "name", args[0], JSPROP_ENUMERATE); |
47 | 0 | } |
48 | | |
49 | | static const JSJitInfo name_getterinfo = { |
50 | | { (JSJitGetterOp)get_name }, |
51 | | { prototypes::id::SharedWorkerGlobalScope }, |
52 | | { PrototypeTraits<prototypes::id::SharedWorkerGlobalScope>::Depth }, |
53 | | JSJitInfo::Getter, |
54 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
55 | | JSVAL_TYPE_STRING, /* returnType. Not relevant for setters. */ |
56 | | false, /* isInfallible. False in setters. */ |
57 | | false, /* isMovable. Not relevant for setters. */ |
58 | | false, /* isEliminatable. Not relevant for setters. */ |
59 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
60 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
61 | | false, /* isTypedMethod. Only relevant for methods. */ |
62 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
63 | | }; |
64 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
65 | | static_assert(0 < 3, "There is no slot for us"); |
66 | | static const JSJitInfo name_setterinfo = { |
67 | | { (JSJitGetterOp)set_name }, |
68 | | { prototypes::id::SharedWorkerGlobalScope }, |
69 | | { PrototypeTraits<prototypes::id::SharedWorkerGlobalScope>::Depth }, |
70 | | JSJitInfo::Setter, |
71 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
72 | | JSVAL_TYPE_UNDEFINED, /* returnType. Not relevant for setters. */ |
73 | | false, /* isInfallible. False in setters. */ |
74 | | false, /* isMovable. Not relevant for setters. */ |
75 | | false, /* isEliminatable. Not relevant for setters. */ |
76 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
77 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
78 | | false, /* isTypedMethod. Only relevant for methods. */ |
79 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
80 | | }; |
81 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
82 | | static_assert(0 < 3, "There is no slot for us"); |
83 | | |
84 | | MOZ_CAN_RUN_SCRIPT static bool |
85 | | close(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::SharedWorkerGlobalScope* self, const JSJitMethodCallArgs& args) |
86 | 0 | { |
87 | 0 | AUTO_PROFILER_LABEL_FAST("SharedWorkerGlobalScope.close", DOM, cx); |
88 | 0 |
|
89 | 0 | self->Close(); |
90 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
91 | 0 | args.rval().setUndefined(); |
92 | 0 | return true; |
93 | 0 | } |
94 | | |
95 | | static const JSJitInfo close_methodinfo = { |
96 | | { (JSJitGetterOp)close }, |
97 | | { prototypes::id::SharedWorkerGlobalScope }, |
98 | | { PrototypeTraits<prototypes::id::SharedWorkerGlobalScope>::Depth }, |
99 | | JSJitInfo::Method, |
100 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
101 | | JSVAL_TYPE_UNDEFINED, /* returnType. Not relevant for setters. */ |
102 | | true, /* isInfallible. False in setters. */ |
103 | | false, /* isMovable. Not relevant for setters. */ |
104 | | false, /* isEliminatable. Not relevant for setters. */ |
105 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
106 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
107 | | false, /* isTypedMethod. Only relevant for methods. */ |
108 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
109 | | }; |
110 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
111 | | static_assert(0 < 3, "There is no slot for us"); |
112 | | |
113 | | MOZ_CAN_RUN_SCRIPT static bool |
114 | | get_onconnect(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::SharedWorkerGlobalScope* self, JSJitGetterCallArgs args) |
115 | 0 | { |
116 | 0 | AUTO_PROFILER_LABEL_FAST("get SharedWorkerGlobalScope.onconnect", DOM, cx); |
117 | 0 |
|
118 | 0 | RefPtr<EventHandlerNonNull> result(self->GetOnconnect()); |
119 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
120 | 0 | if (result) { |
121 | 0 | args.rval().setObjectOrNull(GetCallbackFromCallbackObject(cx, result)); |
122 | 0 | if (!MaybeWrapObjectOrNullValue(cx, args.rval())) { |
123 | 0 | return false; |
124 | 0 | } |
125 | 0 | return true; |
126 | 0 | } else { |
127 | 0 | args.rval().setNull(); |
128 | 0 | return true; |
129 | 0 | } |
130 | 0 | } |
131 | | |
132 | | MOZ_CAN_RUN_SCRIPT static bool |
133 | | set_onconnect(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::SharedWorkerGlobalScope* self, JSJitSetterCallArgs args) |
134 | 0 | { |
135 | 0 | AUTO_PROFILER_LABEL_FAST("set SharedWorkerGlobalScope.onconnect", DOM, cx); |
136 | 0 |
|
137 | 0 | RootedCallback<RefPtr<binding_detail::FastEventHandlerNonNull>> arg0(cx); |
138 | 0 | if (args[0].isObject()) { |
139 | 0 | { // scope for tempRoot and tempGlobalRoot if needed |
140 | 0 | arg0 = new binding_detail::FastEventHandlerNonNull(&args[0].toObject(), JS::CurrentGlobalOrNull(cx)); |
141 | 0 | } |
142 | 0 | } else { |
143 | 0 | arg0 = nullptr; |
144 | 0 | } |
145 | 0 | self->SetOnconnect(Constify(arg0)); |
146 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
147 | 0 |
|
148 | 0 | return true; |
149 | 0 | } |
150 | | |
151 | | static const JSJitInfo onconnect_getterinfo = { |
152 | | { (JSJitGetterOp)get_onconnect }, |
153 | | { prototypes::id::SharedWorkerGlobalScope }, |
154 | | { PrototypeTraits<prototypes::id::SharedWorkerGlobalScope>::Depth }, |
155 | | JSJitInfo::Getter, |
156 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
157 | | JSVAL_TYPE_UNKNOWN, /* returnType. Not relevant for setters. */ |
158 | | false, /* isInfallible. False in setters. */ |
159 | | false, /* isMovable. Not relevant for setters. */ |
160 | | false, /* isEliminatable. Not relevant for setters. */ |
161 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
162 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
163 | | false, /* isTypedMethod. Only relevant for methods. */ |
164 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
165 | | }; |
166 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
167 | | static_assert(0 < 3, "There is no slot for us"); |
168 | | static const JSJitInfo onconnect_setterinfo = { |
169 | | { (JSJitGetterOp)set_onconnect }, |
170 | | { prototypes::id::SharedWorkerGlobalScope }, |
171 | | { PrototypeTraits<prototypes::id::SharedWorkerGlobalScope>::Depth }, |
172 | | JSJitInfo::Setter, |
173 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
174 | | JSVAL_TYPE_UNDEFINED, /* returnType. Not relevant for setters. */ |
175 | | false, /* isInfallible. False in setters. */ |
176 | | false, /* isMovable. Not relevant for setters. */ |
177 | | false, /* isEliminatable. Not relevant for setters. */ |
178 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
179 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
180 | | false, /* isTypedMethod. Only relevant for methods. */ |
181 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
182 | | }; |
183 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
184 | | static_assert(0 < 3, "There is no slot for us"); |
185 | | |
186 | | static void |
187 | | _finalize(js::FreeOp* fop, JSObject* obj) |
188 | 0 | { |
189 | 0 | mozilla::dom::SharedWorkerGlobalScope* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::SharedWorkerGlobalScope>(obj); |
190 | 0 | if (self) { |
191 | 0 | ClearWrapper(self, self, obj); |
192 | 0 | mozilla::dom::FinalizeGlobal(CastToJSFreeOp(fop), obj); |
193 | 0 | AddForDeferredFinalization<mozilla::dom::SharedWorkerGlobalScope>(self); |
194 | 0 | } |
195 | 0 | } |
196 | | |
197 | | static size_t |
198 | | _objectMoved(JSObject* obj, JSObject* old) |
199 | 0 | { |
200 | 0 | mozilla::dom::SharedWorkerGlobalScope* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::SharedWorkerGlobalScope>(obj); |
201 | 0 | if (self) { |
202 | 0 | UpdateWrapper(self, self, obj, old); |
203 | 0 | } |
204 | 0 |
|
205 | 0 | return 0; |
206 | 0 | } |
207 | | |
208 | | // We deliberately use brace-elision to make Visual Studio produce better initalization code. |
209 | | #if defined(__clang__) |
210 | | #pragma clang diagnostic push |
211 | | #pragma clang diagnostic ignored "-Wmissing-braces" |
212 | | #endif |
213 | | static const JSFunctionSpec sMethods_specs[] = { |
214 | | JS_FNSPEC("close", (GenericMethod<MaybeGlobalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&close_methodinfo), 0, JSPROP_ENUMERATE, nullptr), |
215 | | JS_FS_END |
216 | | }; |
217 | | #if defined(__clang__) |
218 | | #pragma clang diagnostic pop |
219 | | #endif |
220 | | |
221 | | |
222 | | static const Prefable<const JSFunctionSpec> sMethods[] = { |
223 | | { nullptr, &sMethods_specs[0] }, |
224 | | { nullptr, nullptr } |
225 | | }; |
226 | | |
227 | | // We deliberately use brace-elision to make Visual Studio produce better initalization code. |
228 | | #if defined(__clang__) |
229 | | #pragma clang diagnostic push |
230 | | #pragma clang diagnostic ignored "-Wmissing-braces" |
231 | | #endif |
232 | | static const JSPropertySpec sAttributes_specs[] = { |
233 | | { "name", JSPROP_ENUMERATE, GenericGetter<MaybeGlobalThisPolicy, ThrowExceptions>, &name_getterinfo, GenericSetter<MaybeGlobalThisPolicy>, &name_setterinfo }, |
234 | | { "onconnect", JSPROP_ENUMERATE, GenericGetter<MaybeGlobalThisPolicy, ThrowExceptions>, &onconnect_getterinfo, GenericSetter<MaybeGlobalThisPolicy>, &onconnect_setterinfo }, |
235 | | { nullptr, 0, nullptr, nullptr, nullptr, nullptr } |
236 | | }; |
237 | | #if defined(__clang__) |
238 | | #pragma clang diagnostic pop |
239 | | #endif |
240 | | |
241 | | |
242 | | static const Prefable<const JSPropertySpec> sAttributes[] = { |
243 | | { nullptr, &sAttributes_specs[0] }, |
244 | | { nullptr, nullptr } |
245 | | }; |
246 | | |
247 | | |
248 | | static const NativePropertiesN<2> sNativeProperties = { |
249 | | false, 0, |
250 | | false, 0, |
251 | | true, 0 /* sMethods */, |
252 | | true, 1 /* sAttributes */, |
253 | | false, 0, |
254 | | false, 0, |
255 | | false, 0, |
256 | | -1, |
257 | | 0, |
258 | | nullptr, |
259 | | { |
260 | | { sMethods, nullptr }, |
261 | | { sAttributes, nullptr } |
262 | | } |
263 | | }; |
264 | | |
265 | | static const DOMIfaceAndProtoJSClass sInterfaceObjectClass = { |
266 | | { |
267 | | "Function", |
268 | | JSCLASS_IS_DOMIFACEANDPROTOJSCLASS | JSCLASS_HAS_RESERVED_SLOTS(DOM_INTERFACE_SLOTS_BASE), |
269 | | &sBoringInterfaceObjectClassClassOps, |
270 | | JS_NULL_CLASS_SPEC, |
271 | | JS_NULL_CLASS_EXT, |
272 | | &sInterfaceObjectClassObjectOps |
273 | | }, |
274 | | eInterface, |
275 | | true, |
276 | | prototypes::id::SharedWorkerGlobalScope, |
277 | | PrototypeTraits<prototypes::id::SharedWorkerGlobalScope>::Depth, |
278 | | &sEmptyNativePropertyHooks, |
279 | | "function SharedWorkerGlobalScope() {\n [native code]\n}", |
280 | | WorkerGlobalScope_Binding::GetConstructorObject |
281 | | }; |
282 | | |
283 | | static const DOMIfaceAndProtoJSClass sPrototypeClass = { |
284 | | { |
285 | | "SharedWorkerGlobalScopePrototype", |
286 | | JSCLASS_IS_DOMIFACEANDPROTOJSCLASS | JSCLASS_HAS_RESERVED_SLOTS(DOM_INTERFACE_PROTO_SLOTS_BASE), |
287 | | JS_NULL_CLASS_OPS, |
288 | | JS_NULL_CLASS_SPEC, |
289 | | JS_NULL_CLASS_EXT, |
290 | | JS_NULL_OBJECT_OPS |
291 | | }, |
292 | | eGlobalInterfacePrototype, |
293 | | false, |
294 | | prototypes::id::SharedWorkerGlobalScope, |
295 | | PrototypeTraits<prototypes::id::SharedWorkerGlobalScope>::Depth, |
296 | | &sEmptyNativePropertyHooks, |
297 | | "[object SharedWorkerGlobalScopePrototype]", |
298 | | WorkerGlobalScope_Binding::GetProtoObject |
299 | | }; |
300 | | |
301 | | bool |
302 | | ConstructorEnabled(JSContext* aCx, JS::Handle<JSObject*> aObj) |
303 | 0 | { |
304 | 0 | MOZ_ASSERT(!NS_IsMainThread(), "Why did we even get called?"); |
305 | 0 |
|
306 | 0 | const char* name = js::GetObjectClass(aObj)->name; |
307 | 0 | if (strcmp(name, "SharedWorkerGlobalScope")) { |
308 | 0 | return false; |
309 | 0 | } |
310 | 0 | |
311 | 0 | return true; |
312 | 0 | } |
313 | | |
314 | | static const js::ClassOps sClassOps = { |
315 | | nullptr, /* addProperty */ |
316 | | nullptr, /* delProperty */ |
317 | | nullptr, /* enumerate */ |
318 | | mozilla::dom::EnumerateGlobal, /* newEnumerate */ |
319 | | mozilla::dom::ResolveGlobal, /* resolve */ |
320 | | mozilla::dom::MayResolveGlobal, /* mayResolve */ |
321 | | _finalize, /* finalize */ |
322 | | nullptr, /* call */ |
323 | | nullptr, /* hasInstance */ |
324 | | nullptr, /* construct */ |
325 | | JS_GlobalObjectTraceHook, /* trace */ |
326 | | }; |
327 | | |
328 | | static const js::ClassExtension sClassExtension = { |
329 | | nullptr, /* weakmapKeyDelegateOp */ |
330 | | _objectMoved /* objectMovedOp */ |
331 | | }; |
332 | | |
333 | | static const DOMJSClass sClass = { |
334 | | { "SharedWorkerGlobalScope", |
335 | | JSCLASS_IS_DOMJSCLASS | JSCLASS_FOREGROUND_FINALIZE | JSCLASS_DOM_GLOBAL | JSCLASS_GLOBAL_FLAGS_WITH_SLOTS(DOM_GLOBAL_SLOTS), |
336 | | &sClassOps, |
337 | | JS_NULL_CLASS_SPEC, |
338 | | &sClassExtension, |
339 | | JS_NULL_OBJECT_OPS |
340 | | }, |
341 | | { prototypes::id::EventTarget, prototypes::id::WorkerGlobalScope, prototypes::id::SharedWorkerGlobalScope, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count }, |
342 | | IsBaseOf<nsISupports, mozilla::dom::SharedWorkerGlobalScope >::value, |
343 | | &sEmptyNativePropertyHooks, |
344 | | FindAssociatedGlobalForNative<mozilla::dom::SharedWorkerGlobalScope>::Get, |
345 | | GetProtoObjectHandle, |
346 | | GetCCParticipant<mozilla::dom::SharedWorkerGlobalScope>::Get() |
347 | | }; |
348 | | static_assert(1 == DOM_INSTANCE_RESERVED_SLOTS, |
349 | | "Must have the right minimal number of reserved slots."); |
350 | | static_assert(JSCLASS_GLOBAL_APPLICATION_SLOTS >= 3, |
351 | | "Must have enough reserved slots."); |
352 | | |
353 | | const JSClass* |
354 | | GetJSClass() |
355 | 0 | { |
356 | 0 | return sClass.ToJSClass(); |
357 | 0 | } |
358 | | |
359 | | bool |
360 | | Wrap(JSContext* aCx, mozilla::dom::SharedWorkerGlobalScope* aObject, nsWrapperCache* aCache, JS::RealmOptions& aOptions, JSPrincipals* aPrincipal, bool aInitStandardClasses, JS::MutableHandle<JSObject*> aReflector) |
361 | 0 | { |
362 | 0 | MOZ_ASSERT(static_cast<mozilla::dom::SharedWorkerGlobalScope*>(aObject) == |
363 | 0 | reinterpret_cast<mozilla::dom::SharedWorkerGlobalScope*>(aObject), |
364 | 0 | "Multiple inheritance for mozilla::dom::SharedWorkerGlobalScope is broken."); |
365 | 0 | MOZ_ASSERT(static_cast<mozilla::dom::WorkerGlobalScope*>(aObject) == |
366 | 0 | reinterpret_cast<mozilla::dom::WorkerGlobalScope*>(aObject), |
367 | 0 | "Multiple inheritance for mozilla::dom::WorkerGlobalScope is broken."); |
368 | 0 | MOZ_ASSERT(static_cast<mozilla::dom::EventTarget*>(aObject) == |
369 | 0 | reinterpret_cast<mozilla::dom::EventTarget*>(aObject), |
370 | 0 | "Multiple inheritance for mozilla::dom::EventTarget is broken."); |
371 | 0 | MOZ_ASSERT(ToSupportsIsCorrect(aObject)); |
372 | 0 | MOZ_ASSERT(ToSupportsIsOnPrimaryInheritanceChain(aObject, aCache), |
373 | 0 | "nsISupports must be on our primary inheritance chain"); |
374 | 0 |
|
375 | 0 | if (!CreateGlobal<mozilla::dom::SharedWorkerGlobalScope, GetProtoObjectHandle>(aCx, |
376 | 0 | aObject, |
377 | 0 | aCache, |
378 | 0 | sClass.ToJSClass(), |
379 | 0 | aOptions, |
380 | 0 | aPrincipal, |
381 | 0 | aInitStandardClasses, |
382 | 0 | aReflector)) { |
383 | 0 | aCache->ReleaseWrapper(aObject); |
384 | 0 | aCache->ClearWrapper(); |
385 | 0 | return false; |
386 | 0 | } |
387 | 0 | |
388 | 0 | // aReflector is a new global, so has a new realm. Enter it |
389 | 0 | // before doing anything with it. |
390 | 0 | JSAutoRealm ar(aCx, aReflector); |
391 | 0 |
|
392 | 0 | if (!DefineProperties(aCx, aReflector, sNativeProperties.Upcast(), nullptr)) { |
393 | 0 | aCache->ReleaseWrapper(aObject); |
394 | 0 | aCache->ClearWrapper(); |
395 | 0 | return false; |
396 | 0 | } |
397 | 0 | |
398 | 0 | |
399 | 0 | return true; |
400 | 0 | } |
401 | | |
402 | | void |
403 | | CreateInterfaceObjects(JSContext* aCx, JS::Handle<JSObject*> aGlobal, ProtoAndIfaceCache& aProtoAndIfaceCache, bool aDefineOnGlobal) |
404 | 0 | { |
405 | 0 | JS::Handle<JSObject*> parentProto(WorkerGlobalScope_Binding::GetProtoObjectHandle(aCx)); |
406 | 0 | if (!parentProto) { |
407 | 0 | return; |
408 | 0 | } |
409 | 0 | |
410 | 0 | JS::Handle<JSObject*> constructorProto(WorkerGlobalScope_Binding::GetConstructorObjectHandle(aCx)); |
411 | 0 | if (!constructorProto) { |
412 | 0 | return; |
413 | 0 | } |
414 | 0 | |
415 | 0 | JS::Heap<JSObject*>* protoCache = &aProtoAndIfaceCache.EntrySlotOrCreate(prototypes::id::SharedWorkerGlobalScope); |
416 | 0 | JS::Heap<JSObject*>* interfaceCache = &aProtoAndIfaceCache.EntrySlotOrCreate(constructors::id::SharedWorkerGlobalScope); |
417 | 0 | dom::CreateInterfaceObjects(aCx, aGlobal, parentProto, |
418 | 0 | &sPrototypeClass.mBase, protoCache, |
419 | 0 | nullptr, |
420 | 0 | constructorProto, &sInterfaceObjectClass.mBase, 0, nullptr, |
421 | 0 | interfaceCache, |
422 | 0 | sNativeProperties.Upcast(), |
423 | 0 | nullptr, |
424 | 0 | "SharedWorkerGlobalScope", aDefineOnGlobal, |
425 | 0 | nullptr, |
426 | 0 | true); |
427 | 0 |
|
428 | 0 | if (*&aProtoAndIfaceCache.EntrySlotOrCreate(prototypes::id::SharedWorkerGlobalScope)) { |
429 | 0 | bool succeeded; |
430 | 0 | JS::Handle<JSObject*> prot = GetProtoObjectHandle(aCx); |
431 | 0 | if (!JS_SetImmutablePrototype(aCx, prot, &succeeded)) { |
432 | 0 | *protoCache = nullptr; |
433 | 0 | if (interfaceCache) { |
434 | 0 | *interfaceCache = nullptr; |
435 | 0 | } |
436 | 0 | return; |
437 | 0 | } |
438 | 0 |
|
439 | 0 | MOZ_ASSERT(succeeded, |
440 | 0 | "making a fresh prototype object's [[Prototype]] " |
441 | 0 | "immutable can internally fail, but it should " |
442 | 0 | "never be unsuccessful"); |
443 | 0 | } |
444 | 0 | } |
445 | | |
446 | | JSObject* |
447 | | GetConstructorObject(JSContext* aCx) |
448 | 0 | { |
449 | 0 | return GetConstructorObjectHandle(aCx); |
450 | 0 | } |
451 | | |
452 | | } // namespace SharedWorkerGlobalScope_Binding |
453 | | |
454 | | |
455 | | |
456 | | } // namespace dom |
457 | | } // namespace mozilla |