/work/obj-fuzz/dom/bindings/IDBIndexBinding.cpp
Line | Count | Source (jump to first uncovered line) |
1 | | /* THIS FILE IS AUTOGENERATED FROM IDBIndex.webidl BY Codegen.py - DO NOT EDIT */ |
2 | | |
3 | | #include "AtomList.h" |
4 | | #include "IDBIndexBinding.h" |
5 | | #include "WrapperFactory.h" |
6 | | #include "mozilla/OwningNonNull.h" |
7 | | #include "mozilla/dom/BindingUtils.h" |
8 | | #include "mozilla/dom/DOMJSClass.h" |
9 | | #include "mozilla/dom/IDBIndex.h" |
10 | | #include "mozilla/dom/IDBObjectStore.h" |
11 | | #include "mozilla/dom/IDBRequest.h" |
12 | | #include "mozilla/dom/IndexedDatabaseManager.h" |
13 | | #include "mozilla/dom/NonRefcountedDOMObject.h" |
14 | | #include "mozilla/dom/Nullable.h" |
15 | | #include "mozilla/dom/PrimitiveConversions.h" |
16 | | #include "mozilla/dom/ScriptSettings.h" |
17 | | #include "mozilla/dom/SimpleGlobalObject.h" |
18 | | #include "mozilla/dom/XrayExpandoClass.h" |
19 | | |
20 | | namespace mozilla { |
21 | | namespace dom { |
22 | | |
23 | | namespace binding_detail {}; // Just to make sure it's known as a namespace |
24 | | using namespace mozilla::dom::binding_detail; |
25 | | |
26 | | |
27 | | |
28 | | IDBIndexParameters::IDBIndexParameters() |
29 | 0 | { |
30 | 0 | // Safe to pass a null context if we pass a null value |
31 | 0 | Init(nullptr, JS::NullHandleValue); |
32 | 0 | } |
33 | | |
34 | | |
35 | | |
36 | | bool |
37 | | IDBIndexParameters::InitIds(JSContext* cx, IDBIndexParametersAtoms* atomsCache) |
38 | 0 | { |
39 | 0 | MOZ_ASSERT(!*reinterpret_cast<jsid**>(atomsCache)); |
40 | 0 |
|
41 | 0 | // Initialize these in reverse order so that any failure leaves the first one |
42 | 0 | // uninitialized. |
43 | 0 | if (!atomsCache->unique_id.init(cx, "unique") || |
44 | 0 | !atomsCache->multiEntry_id.init(cx, "multiEntry") || |
45 | 0 | !atomsCache->locale_id.init(cx, "locale")) { |
46 | 0 | return false; |
47 | 0 | } |
48 | 0 | return true; |
49 | 0 | } |
50 | | |
51 | | bool |
52 | | IDBIndexParameters::Init(JSContext* cx, JS::Handle<JS::Value> val, const char* sourceDescription, bool passedToJSImpl) |
53 | 0 | { |
54 | 0 | // Passing a null JSContext is OK only if we're initing from null, |
55 | 0 | // Since in that case we will not have to do any property gets |
56 | 0 | // Also evaluate isNullOrUndefined in order to avoid false-positive |
57 | 0 | // checkers by static analysis tools |
58 | 0 | MOZ_ASSERT_IF(!cx, val.isNull() && val.isNullOrUndefined()); |
59 | 0 | IDBIndexParametersAtoms* atomsCache = nullptr; |
60 | 0 | if (cx) { |
61 | 0 | atomsCache = GetAtomCache<IDBIndexParametersAtoms>(cx); |
62 | 0 | if (!*reinterpret_cast<jsid**>(atomsCache) && !InitIds(cx, atomsCache)) { |
63 | 0 | return false; |
64 | 0 | } |
65 | 0 | } |
66 | 0 | |
67 | 0 | if (!IsConvertibleToDictionary(val)) { |
68 | 0 | return ThrowErrorMessage(cx, MSG_NOT_DICTIONARY, sourceDescription); |
69 | 0 | } |
70 | 0 | |
71 | 0 | bool isNull = val.isNullOrUndefined(); |
72 | 0 | // We only need these if !isNull, in which case we have |cx|. |
73 | 0 | Maybe<JS::Rooted<JSObject *> > object; |
74 | 0 | Maybe<JS::Rooted<JS::Value> > temp; |
75 | 0 | if (!isNull) { |
76 | 0 | MOZ_ASSERT(cx); |
77 | 0 | object.emplace(cx, &val.toObject()); |
78 | 0 | temp.emplace(cx); |
79 | 0 | } |
80 | 0 | if (!isNull) { |
81 | 0 | if (!JS_GetPropertyById(cx, *object, atomsCache->locale_id, temp.ptr())) { |
82 | 0 | return false; |
83 | 0 | } |
84 | 0 | } |
85 | 0 | if (!isNull && !temp->isUndefined()) { |
86 | 0 | if (!ConvertJSValueToString(cx, temp.ref(), eNull, eNull, mLocale)) { |
87 | 0 | return false; |
88 | 0 | } |
89 | 0 | } else { |
90 | 0 | mLocale.SetIsVoid(true); |
91 | 0 | } |
92 | 0 | mIsAnyMemberPresent = true; |
93 | 0 |
|
94 | 0 | if (!isNull) { |
95 | 0 | if (!JS_GetPropertyById(cx, *object, atomsCache->multiEntry_id, temp.ptr())) { |
96 | 0 | return false; |
97 | 0 | } |
98 | 0 | } |
99 | 0 | if (!isNull && !temp->isUndefined()) { |
100 | 0 | if (!ValueToPrimitive<bool, eDefault>(cx, temp.ref(), &mMultiEntry)) { |
101 | 0 | return false; |
102 | 0 | } |
103 | 0 | } else { |
104 | 0 | mMultiEntry = false; |
105 | 0 | } |
106 | 0 | mIsAnyMemberPresent = true; |
107 | 0 |
|
108 | 0 | if (!isNull) { |
109 | 0 | if (!JS_GetPropertyById(cx, *object, atomsCache->unique_id, temp.ptr())) { |
110 | 0 | return false; |
111 | 0 | } |
112 | 0 | } |
113 | 0 | if (!isNull && !temp->isUndefined()) { |
114 | 0 | if (!ValueToPrimitive<bool, eDefault>(cx, temp.ref(), &mUnique)) { |
115 | 0 | return false; |
116 | 0 | } |
117 | 0 | } else { |
118 | 0 | mUnique = false; |
119 | 0 | } |
120 | 0 | mIsAnyMemberPresent = true; |
121 | 0 | return true; |
122 | 0 | } |
123 | | |
124 | | bool |
125 | | IDBIndexParameters::Init(const nsAString& aJSON) |
126 | 0 | { |
127 | 0 | AutoJSAPI jsapi; |
128 | 0 | JSObject* cleanGlobal = SimpleGlobalObject::Create(SimpleGlobalObject::GlobalType::BindingDetail); |
129 | 0 | if (!cleanGlobal) { |
130 | 0 | return false; |
131 | 0 | } |
132 | 0 | if (!jsapi.Init(cleanGlobal)) { |
133 | 0 | return false; |
134 | 0 | } |
135 | 0 | JSContext* cx = jsapi.cx(); |
136 | 0 | JS::Rooted<JS::Value> json(cx); |
137 | 0 | bool ok = ParseJSON(cx, aJSON, &json); |
138 | 0 | NS_ENSURE_TRUE(ok, false); |
139 | 0 | return Init(cx, json); |
140 | 0 | } |
141 | | |
142 | | bool |
143 | | IDBIndexParameters::ToObjectInternal(JSContext* cx, JS::MutableHandle<JS::Value> rval) const |
144 | 0 | { |
145 | 0 | IDBIndexParametersAtoms* atomsCache = GetAtomCache<IDBIndexParametersAtoms>(cx); |
146 | 0 | if (!*reinterpret_cast<jsid**>(atomsCache) && !InitIds(cx, atomsCache)) { |
147 | 0 | return false; |
148 | 0 | } |
149 | 0 | |
150 | 0 | JS::Rooted<JSObject*> obj(cx, JS_NewPlainObject(cx)); |
151 | 0 | if (!obj) { |
152 | 0 | return false; |
153 | 0 | } |
154 | 0 | rval.set(JS::ObjectValue(*obj)); |
155 | 0 |
|
156 | 0 | do { |
157 | 0 | // block for our 'break' successCode and scope for 'temp' and 'currentValue' |
158 | 0 | JS::Rooted<JS::Value> temp(cx); |
159 | 0 | nsString const & currentValue = mLocale; |
160 | 0 | if (!xpc::StringToJsval(cx, currentValue, &temp)) { |
161 | 0 | return false; |
162 | 0 | } |
163 | 0 | if (!JS_DefinePropertyById(cx, obj, atomsCache->locale_id, temp, JSPROP_ENUMERATE)) { |
164 | 0 | return false; |
165 | 0 | } |
166 | 0 | break; |
167 | 0 | } while(false); |
168 | 0 |
|
169 | 0 | do { |
170 | 0 | // block for our 'break' successCode and scope for 'temp' and 'currentValue' |
171 | 0 | JS::Rooted<JS::Value> temp(cx); |
172 | 0 | bool const & currentValue = mMultiEntry; |
173 | 0 | temp.setBoolean(currentValue); |
174 | 0 | if (!JS_DefinePropertyById(cx, obj, atomsCache->multiEntry_id, temp, JSPROP_ENUMERATE)) { |
175 | 0 | return false; |
176 | 0 | } |
177 | 0 | break; |
178 | 0 | } while(false); |
179 | 0 |
|
180 | 0 | do { |
181 | 0 | // block for our 'break' successCode and scope for 'temp' and 'currentValue' |
182 | 0 | JS::Rooted<JS::Value> temp(cx); |
183 | 0 | bool const & currentValue = mUnique; |
184 | 0 | temp.setBoolean(currentValue); |
185 | 0 | if (!JS_DefinePropertyById(cx, obj, atomsCache->unique_id, temp, JSPROP_ENUMERATE)) { |
186 | 0 | return false; |
187 | 0 | } |
188 | 0 | break; |
189 | 0 | } while(false); |
190 | 0 |
|
191 | 0 | return true; |
192 | 0 | } |
193 | | |
194 | | bool |
195 | | IDBIndexParameters::ToJSON(nsAString& aJSON) const |
196 | 0 | { |
197 | 0 | AutoJSAPI jsapi; |
198 | 0 | jsapi.Init(); |
199 | 0 | JSContext *cx = jsapi.cx(); |
200 | 0 | // It's safe to use UnprivilegedJunkScopeOrWorkerGlobal here |
201 | 0 | // because we'll only be creating objects, in ways that have no |
202 | 0 | // side-effects, followed by a call to JS::ToJSONMaybeSafely, |
203 | 0 | // which likewise guarantees no side-effects for the sorts of |
204 | 0 | // things we will pass it. |
205 | 0 | JSAutoRealm ar(cx, UnprivilegedJunkScopeOrWorkerGlobal()); |
206 | 0 | JS::Rooted<JS::Value> val(cx); |
207 | 0 | if (!ToObjectInternal(cx, &val)) { |
208 | 0 | return false; |
209 | 0 | } |
210 | 0 | JS::Rooted<JSObject*> obj(cx, &val.toObject()); |
211 | 0 | return StringifyToJSON(cx, obj, aJSON); |
212 | 0 | } |
213 | | |
214 | | void |
215 | | IDBIndexParameters::TraceDictionary(JSTracer* trc) |
216 | 0 | { |
217 | 0 | } |
218 | | |
219 | | IDBIndexParameters& |
220 | | IDBIndexParameters::operator=(const IDBIndexParameters& aOther) |
221 | 0 | { |
222 | 0 | DictionaryBase::operator=(aOther); |
223 | 0 | mLocale = aOther.mLocale; |
224 | 0 | mMultiEntry = aOther.mMultiEntry; |
225 | 0 | mUnique = aOther.mUnique; |
226 | 0 | return *this; |
227 | 0 | } |
228 | | |
229 | | namespace binding_detail { |
230 | | } // namespace binding_detail |
231 | | |
232 | | |
233 | | namespace IDBIndex_Binding { |
234 | | |
235 | | MOZ_CAN_RUN_SCRIPT static bool |
236 | | get_name(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::IDBIndex* self, JSJitGetterCallArgs args) |
237 | 0 | { |
238 | 0 | AUTO_PROFILER_LABEL_FAST("get IDBIndex.name", DOM, cx); |
239 | 0 |
|
240 | 0 | DOMString result; |
241 | 0 | self->GetName(result); |
242 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
243 | 0 | if (!xpc::NonVoidStringToJsval(cx, result, args.rval())) { |
244 | 0 | return false; |
245 | 0 | } |
246 | 0 | return true; |
247 | 0 | } |
248 | | |
249 | | MOZ_CAN_RUN_SCRIPT static bool |
250 | | set_name(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::IDBIndex* self, JSJitSetterCallArgs args) |
251 | 0 | { |
252 | 0 | AUTO_PROFILER_LABEL_FAST("set IDBIndex.name", DOM, cx); |
253 | 0 |
|
254 | 0 | binding_detail::FakeString arg0; |
255 | 0 | if (!ConvertJSValueToString(cx, args[0], eStringify, eStringify, arg0)) { |
256 | 0 | return false; |
257 | 0 | } |
258 | 0 | FastErrorResult rv; |
259 | 0 | self->SetName(NonNullHelper(Constify(arg0)), rv); |
260 | 0 | if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) { |
261 | 0 | return false; |
262 | 0 | } |
263 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
264 | 0 |
|
265 | 0 | return true; |
266 | 0 | } |
267 | | |
268 | | static const JSJitInfo name_getterinfo = { |
269 | | { (JSJitGetterOp)get_name }, |
270 | | { prototypes::id::IDBIndex }, |
271 | | { PrototypeTraits<prototypes::id::IDBIndex>::Depth }, |
272 | | JSJitInfo::Getter, |
273 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
274 | | JSVAL_TYPE_STRING, /* returnType. Not relevant for setters. */ |
275 | | false, /* isInfallible. False in setters. */ |
276 | | false, /* isMovable. Not relevant for setters. */ |
277 | | false, /* isEliminatable. Not relevant for setters. */ |
278 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
279 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
280 | | false, /* isTypedMethod. Only relevant for methods. */ |
281 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
282 | | }; |
283 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
284 | | static_assert(0 < 1, "There is no slot for us"); |
285 | | static const JSJitInfo name_setterinfo = { |
286 | | { (JSJitGetterOp)set_name }, |
287 | | { prototypes::id::IDBIndex }, |
288 | | { PrototypeTraits<prototypes::id::IDBIndex>::Depth }, |
289 | | JSJitInfo::Setter, |
290 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
291 | | JSVAL_TYPE_UNDEFINED, /* returnType. Not relevant for setters. */ |
292 | | false, /* isInfallible. False in setters. */ |
293 | | false, /* isMovable. Not relevant for setters. */ |
294 | | false, /* isEliminatable. Not relevant for setters. */ |
295 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
296 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
297 | | false, /* isTypedMethod. Only relevant for methods. */ |
298 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
299 | | }; |
300 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
301 | | static_assert(0 < 1, "There is no slot for us"); |
302 | | |
303 | | MOZ_CAN_RUN_SCRIPT static bool |
304 | | get_objectStore(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::IDBIndex* self, JSJitGetterCallArgs args) |
305 | 0 | { |
306 | 0 | AUTO_PROFILER_LABEL_FAST("get IDBIndex.objectStore", DOM, cx); |
307 | 0 |
|
308 | 0 | auto result(StrongOrRawPtr<mozilla::dom::IDBObjectStore>(self->ObjectStore())); |
309 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
310 | 0 | if (!GetOrCreateDOMReflector(cx, result, args.rval())) { |
311 | 0 | MOZ_ASSERT(JS_IsExceptionPending(cx)); |
312 | 0 | return false; |
313 | 0 | } |
314 | 0 | return true; |
315 | 0 | } |
316 | | |
317 | | static const JSJitInfo objectStore_getterinfo = { |
318 | | { (JSJitGetterOp)get_objectStore }, |
319 | | { prototypes::id::IDBIndex }, |
320 | | { PrototypeTraits<prototypes::id::IDBIndex>::Depth }, |
321 | | JSJitInfo::Getter, |
322 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
323 | | JSVAL_TYPE_OBJECT, /* returnType. Not relevant for setters. */ |
324 | | false, /* isInfallible. False in setters. */ |
325 | | false, /* isMovable. Not relevant for setters. */ |
326 | | false, /* isEliminatable. Not relevant for setters. */ |
327 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
328 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
329 | | false, /* isTypedMethod. Only relevant for methods. */ |
330 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
331 | | }; |
332 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
333 | | static_assert(0 < 1, "There is no slot for us"); |
334 | | |
335 | | MOZ_CAN_RUN_SCRIPT static bool |
336 | | get_keyPath(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::IDBIndex* self, JSJitGetterCallArgs args) |
337 | 0 | { |
338 | 0 | AUTO_PROFILER_LABEL_FAST("get IDBIndex.keyPath", DOM, cx); |
339 | 0 |
|
340 | 0 | FastErrorResult rv; |
341 | 0 | JS::Rooted<JS::Value> result(cx); |
342 | 0 | self->GetKeyPath(cx, &result, rv); |
343 | 0 | if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) { |
344 | 0 | return false; |
345 | 0 | } |
346 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
347 | 0 | JS::ExposeValueToActiveJS(result); |
348 | 0 | args.rval().set(result); |
349 | 0 | if (!MaybeWrapValue(cx, args.rval())) { |
350 | 0 | return false; |
351 | 0 | } |
352 | 0 | return true; |
353 | 0 | } |
354 | | |
355 | | static const JSJitInfo keyPath_getterinfo = { |
356 | | { (JSJitGetterOp)get_keyPath }, |
357 | | { prototypes::id::IDBIndex }, |
358 | | { PrototypeTraits<prototypes::id::IDBIndex>::Depth }, |
359 | | JSJitInfo::Getter, |
360 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
361 | | JSVAL_TYPE_UNKNOWN, /* returnType. Not relevant for setters. */ |
362 | | false, /* isInfallible. False in setters. */ |
363 | | false, /* isMovable. Not relevant for setters. */ |
364 | | false, /* isEliminatable. Not relevant for setters. */ |
365 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
366 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
367 | | false, /* isTypedMethod. Only relevant for methods. */ |
368 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
369 | | }; |
370 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
371 | | static_assert(0 < 1, "There is no slot for us"); |
372 | | |
373 | | MOZ_CAN_RUN_SCRIPT static bool |
374 | | get_multiEntry(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::IDBIndex* self, JSJitGetterCallArgs args) |
375 | 0 | { |
376 | 0 | AUTO_PROFILER_LABEL_FAST("get IDBIndex.multiEntry", DOM, cx); |
377 | 0 |
|
378 | 0 | bool result(self->MultiEntry()); |
379 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
380 | 0 | args.rval().setBoolean(result); |
381 | 0 | return true; |
382 | 0 | } |
383 | | |
384 | | static const JSJitInfo multiEntry_getterinfo = { |
385 | | { (JSJitGetterOp)get_multiEntry }, |
386 | | { prototypes::id::IDBIndex }, |
387 | | { PrototypeTraits<prototypes::id::IDBIndex>::Depth }, |
388 | | JSJitInfo::Getter, |
389 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
390 | | JSVAL_TYPE_BOOLEAN, /* returnType. Not relevant for setters. */ |
391 | | true, /* isInfallible. False in setters. */ |
392 | | false, /* isMovable. Not relevant for setters. */ |
393 | | false, /* isEliminatable. Not relevant for setters. */ |
394 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
395 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
396 | | false, /* isTypedMethod. Only relevant for methods. */ |
397 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
398 | | }; |
399 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
400 | | static_assert(0 < 1, "There is no slot for us"); |
401 | | |
402 | | MOZ_CAN_RUN_SCRIPT static bool |
403 | | get_unique(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::IDBIndex* self, JSJitGetterCallArgs args) |
404 | 0 | { |
405 | 0 | AUTO_PROFILER_LABEL_FAST("get IDBIndex.unique", DOM, cx); |
406 | 0 |
|
407 | 0 | bool result(self->Unique()); |
408 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
409 | 0 | args.rval().setBoolean(result); |
410 | 0 | return true; |
411 | 0 | } |
412 | | |
413 | | static const JSJitInfo unique_getterinfo = { |
414 | | { (JSJitGetterOp)get_unique }, |
415 | | { prototypes::id::IDBIndex }, |
416 | | { PrototypeTraits<prototypes::id::IDBIndex>::Depth }, |
417 | | JSJitInfo::Getter, |
418 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
419 | | JSVAL_TYPE_BOOLEAN, /* returnType. Not relevant for setters. */ |
420 | | true, /* isInfallible. False in setters. */ |
421 | | false, /* isMovable. Not relevant for setters. */ |
422 | | false, /* isEliminatable. Not relevant for setters. */ |
423 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
424 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
425 | | false, /* isTypedMethod. Only relevant for methods. */ |
426 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
427 | | }; |
428 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
429 | | static_assert(0 < 1, "There is no slot for us"); |
430 | | |
431 | | MOZ_CAN_RUN_SCRIPT static bool |
432 | | get_locale(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::IDBIndex* self, JSJitGetterCallArgs args) |
433 | 0 | { |
434 | 0 | AUTO_PROFILER_LABEL_FAST("get IDBIndex.locale", DOM, cx); |
435 | 0 |
|
436 | 0 | DOMString result; |
437 | 0 | self->GetLocale(result); |
438 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
439 | 0 | if (!xpc::StringToJsval(cx, result, args.rval())) { |
440 | 0 | return false; |
441 | 0 | } |
442 | 0 | return true; |
443 | 0 | } |
444 | | |
445 | | static const JSJitInfo locale_getterinfo = { |
446 | | { (JSJitGetterOp)get_locale }, |
447 | | { prototypes::id::IDBIndex }, |
448 | | { PrototypeTraits<prototypes::id::IDBIndex>::Depth }, |
449 | | JSJitInfo::Getter, |
450 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
451 | | JSVAL_TYPE_UNKNOWN, /* returnType. Not relevant for setters. */ |
452 | | false, /* isInfallible. False in setters. */ |
453 | | false, /* isMovable. Not relevant for setters. */ |
454 | | false, /* isEliminatable. Not relevant for setters. */ |
455 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
456 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
457 | | false, /* isTypedMethod. Only relevant for methods. */ |
458 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
459 | | }; |
460 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
461 | | static_assert(0 < 1, "There is no slot for us"); |
462 | | |
463 | | MOZ_CAN_RUN_SCRIPT static bool |
464 | | get_isAutoLocale(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::IDBIndex* self, JSJitGetterCallArgs args) |
465 | 0 | { |
466 | 0 | AUTO_PROFILER_LABEL_FAST("get IDBIndex.isAutoLocale", DOM, cx); |
467 | 0 |
|
468 | 0 | bool result(self->IsAutoLocale()); |
469 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
470 | 0 | args.rval().setBoolean(result); |
471 | 0 | return true; |
472 | 0 | } |
473 | | |
474 | | static const JSJitInfo isAutoLocale_getterinfo = { |
475 | | { (JSJitGetterOp)get_isAutoLocale }, |
476 | | { prototypes::id::IDBIndex }, |
477 | | { PrototypeTraits<prototypes::id::IDBIndex>::Depth }, |
478 | | JSJitInfo::Getter, |
479 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
480 | | JSVAL_TYPE_BOOLEAN, /* returnType. Not relevant for setters. */ |
481 | | true, /* isInfallible. False in setters. */ |
482 | | false, /* isMovable. Not relevant for setters. */ |
483 | | false, /* isEliminatable. Not relevant for setters. */ |
484 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
485 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
486 | | false, /* isTypedMethod. Only relevant for methods. */ |
487 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
488 | | }; |
489 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
490 | | static_assert(0 < 1, "There is no slot for us"); |
491 | | |
492 | | MOZ_CAN_RUN_SCRIPT static bool |
493 | | openCursor(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::IDBIndex* self, const JSJitMethodCallArgs& args) |
494 | 0 | { |
495 | 0 | AUTO_PROFILER_LABEL_FAST("IDBIndex.openCursor", DOM, cx); |
496 | 0 |
|
497 | 0 | JS::Rooted<JS::Value> arg0(cx); |
498 | 0 | if (args.hasDefined(0)) { |
499 | 0 | arg0 = args[0]; |
500 | 0 | } else { |
501 | 0 | arg0 = JS::UndefinedValue(); |
502 | 0 | } |
503 | 0 | IDBCursorDirection arg1; |
504 | 0 | if (args.hasDefined(1)) { |
505 | 0 | { |
506 | 0 | int index; |
507 | 0 | if (!FindEnumStringIndex<true>(cx, args[1], IDBCursorDirectionValues::strings, "IDBCursorDirection", "Argument 2 of IDBIndex.openCursor", &index)) { |
508 | 0 | return false; |
509 | 0 | } |
510 | 0 | MOZ_ASSERT(index >= 0); |
511 | 0 | arg1 = static_cast<IDBCursorDirection>(index); |
512 | 0 | } |
513 | 0 | } else { |
514 | 0 | arg1 = IDBCursorDirection::Next; |
515 | 0 | } |
516 | 0 | FastErrorResult rv; |
517 | 0 | auto result(StrongOrRawPtr<mozilla::dom::IDBRequest>(self->OpenCursor(cx, arg0, arg1, rv))); |
518 | 0 | if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) { |
519 | 0 | return false; |
520 | 0 | } |
521 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
522 | 0 | if (!GetOrCreateDOMReflector(cx, result, args.rval())) { |
523 | 0 | MOZ_ASSERT(JS_IsExceptionPending(cx)); |
524 | 0 | return false; |
525 | 0 | } |
526 | 0 | return true; |
527 | 0 | } |
528 | | |
529 | | static const JSJitInfo openCursor_methodinfo = { |
530 | | { (JSJitGetterOp)openCursor }, |
531 | | { prototypes::id::IDBIndex }, |
532 | | { PrototypeTraits<prototypes::id::IDBIndex>::Depth }, |
533 | | JSJitInfo::Method, |
534 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
535 | | JSVAL_TYPE_OBJECT, /* returnType. Not relevant for setters. */ |
536 | | false, /* isInfallible. False in setters. */ |
537 | | false, /* isMovable. Not relevant for setters. */ |
538 | | false, /* isEliminatable. Not relevant for setters. */ |
539 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
540 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
541 | | false, /* isTypedMethod. Only relevant for methods. */ |
542 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
543 | | }; |
544 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
545 | | static_assert(0 < 1, "There is no slot for us"); |
546 | | |
547 | | MOZ_CAN_RUN_SCRIPT static bool |
548 | | openKeyCursor(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::IDBIndex* self, const JSJitMethodCallArgs& args) |
549 | 0 | { |
550 | 0 | AUTO_PROFILER_LABEL_FAST("IDBIndex.openKeyCursor", DOM, cx); |
551 | 0 |
|
552 | 0 | JS::Rooted<JS::Value> arg0(cx); |
553 | 0 | if (args.hasDefined(0)) { |
554 | 0 | arg0 = args[0]; |
555 | 0 | } else { |
556 | 0 | arg0 = JS::UndefinedValue(); |
557 | 0 | } |
558 | 0 | IDBCursorDirection arg1; |
559 | 0 | if (args.hasDefined(1)) { |
560 | 0 | { |
561 | 0 | int index; |
562 | 0 | if (!FindEnumStringIndex<true>(cx, args[1], IDBCursorDirectionValues::strings, "IDBCursorDirection", "Argument 2 of IDBIndex.openKeyCursor", &index)) { |
563 | 0 | return false; |
564 | 0 | } |
565 | 0 | MOZ_ASSERT(index >= 0); |
566 | 0 | arg1 = static_cast<IDBCursorDirection>(index); |
567 | 0 | } |
568 | 0 | } else { |
569 | 0 | arg1 = IDBCursorDirection::Next; |
570 | 0 | } |
571 | 0 | FastErrorResult rv; |
572 | 0 | auto result(StrongOrRawPtr<mozilla::dom::IDBRequest>(self->OpenKeyCursor(cx, arg0, arg1, rv))); |
573 | 0 | if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) { |
574 | 0 | return false; |
575 | 0 | } |
576 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
577 | 0 | if (!GetOrCreateDOMReflector(cx, result, args.rval())) { |
578 | 0 | MOZ_ASSERT(JS_IsExceptionPending(cx)); |
579 | 0 | return false; |
580 | 0 | } |
581 | 0 | return true; |
582 | 0 | } |
583 | | |
584 | | static const JSJitInfo openKeyCursor_methodinfo = { |
585 | | { (JSJitGetterOp)openKeyCursor }, |
586 | | { prototypes::id::IDBIndex }, |
587 | | { PrototypeTraits<prototypes::id::IDBIndex>::Depth }, |
588 | | JSJitInfo::Method, |
589 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
590 | | JSVAL_TYPE_OBJECT, /* returnType. Not relevant for setters. */ |
591 | | false, /* isInfallible. False in setters. */ |
592 | | false, /* isMovable. Not relevant for setters. */ |
593 | | false, /* isEliminatable. Not relevant for setters. */ |
594 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
595 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
596 | | false, /* isTypedMethod. Only relevant for methods. */ |
597 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
598 | | }; |
599 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
600 | | static_assert(0 < 1, "There is no slot for us"); |
601 | | |
602 | | MOZ_CAN_RUN_SCRIPT static bool |
603 | | get(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::IDBIndex* self, const JSJitMethodCallArgs& args) |
604 | 0 | { |
605 | 0 | AUTO_PROFILER_LABEL_FAST("IDBIndex.get", DOM, cx); |
606 | 0 |
|
607 | 0 | if (MOZ_UNLIKELY(args.length() < 1)) { |
608 | 0 | return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "IDBIndex.get"); |
609 | 0 | } |
610 | 0 | JS::Rooted<JS::Value> arg0(cx); |
611 | 0 | arg0 = args[0]; |
612 | 0 | FastErrorResult rv; |
613 | 0 | auto result(StrongOrRawPtr<mozilla::dom::IDBRequest>(self->Get(cx, arg0, rv))); |
614 | 0 | if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) { |
615 | 0 | return false; |
616 | 0 | } |
617 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
618 | 0 | if (!GetOrCreateDOMReflector(cx, result, args.rval())) { |
619 | 0 | MOZ_ASSERT(JS_IsExceptionPending(cx)); |
620 | 0 | return false; |
621 | 0 | } |
622 | 0 | return true; |
623 | 0 | } |
624 | | |
625 | | static const JSJitInfo get_methodinfo = { |
626 | | { (JSJitGetterOp)get }, |
627 | | { prototypes::id::IDBIndex }, |
628 | | { PrototypeTraits<prototypes::id::IDBIndex>::Depth }, |
629 | | JSJitInfo::Method, |
630 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
631 | | JSVAL_TYPE_OBJECT, /* returnType. Not relevant for setters. */ |
632 | | false, /* isInfallible. False in setters. */ |
633 | | false, /* isMovable. Not relevant for setters. */ |
634 | | false, /* isEliminatable. Not relevant for setters. */ |
635 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
636 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
637 | | false, /* isTypedMethod. Only relevant for methods. */ |
638 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
639 | | }; |
640 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
641 | | static_assert(0 < 1, "There is no slot for us"); |
642 | | |
643 | | MOZ_CAN_RUN_SCRIPT static bool |
644 | | getKey(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::IDBIndex* self, const JSJitMethodCallArgs& args) |
645 | 0 | { |
646 | 0 | AUTO_PROFILER_LABEL_FAST("IDBIndex.getKey", DOM, cx); |
647 | 0 |
|
648 | 0 | if (MOZ_UNLIKELY(args.length() < 1)) { |
649 | 0 | return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "IDBIndex.getKey"); |
650 | 0 | } |
651 | 0 | JS::Rooted<JS::Value> arg0(cx); |
652 | 0 | arg0 = args[0]; |
653 | 0 | FastErrorResult rv; |
654 | 0 | auto result(StrongOrRawPtr<mozilla::dom::IDBRequest>(self->GetKey(cx, arg0, rv))); |
655 | 0 | if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) { |
656 | 0 | return false; |
657 | 0 | } |
658 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
659 | 0 | if (!GetOrCreateDOMReflector(cx, result, args.rval())) { |
660 | 0 | MOZ_ASSERT(JS_IsExceptionPending(cx)); |
661 | 0 | return false; |
662 | 0 | } |
663 | 0 | return true; |
664 | 0 | } |
665 | | |
666 | | static const JSJitInfo getKey_methodinfo = { |
667 | | { (JSJitGetterOp)getKey }, |
668 | | { prototypes::id::IDBIndex }, |
669 | | { PrototypeTraits<prototypes::id::IDBIndex>::Depth }, |
670 | | JSJitInfo::Method, |
671 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
672 | | JSVAL_TYPE_OBJECT, /* returnType. Not relevant for setters. */ |
673 | | false, /* isInfallible. False in setters. */ |
674 | | false, /* isMovable. Not relevant for setters. */ |
675 | | false, /* isEliminatable. Not relevant for setters. */ |
676 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
677 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
678 | | false, /* isTypedMethod. Only relevant for methods. */ |
679 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
680 | | }; |
681 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
682 | | static_assert(0 < 1, "There is no slot for us"); |
683 | | |
684 | | MOZ_CAN_RUN_SCRIPT static bool |
685 | | count(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::IDBIndex* self, const JSJitMethodCallArgs& args) |
686 | 0 | { |
687 | 0 | AUTO_PROFILER_LABEL_FAST("IDBIndex.count", DOM, cx); |
688 | 0 |
|
689 | 0 | JS::Rooted<JS::Value> arg0(cx); |
690 | 0 | if (args.hasDefined(0)) { |
691 | 0 | arg0 = args[0]; |
692 | 0 | } else { |
693 | 0 | arg0 = JS::UndefinedValue(); |
694 | 0 | } |
695 | 0 | FastErrorResult rv; |
696 | 0 | auto result(StrongOrRawPtr<mozilla::dom::IDBRequest>(self->Count(cx, arg0, rv))); |
697 | 0 | if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) { |
698 | 0 | return false; |
699 | 0 | } |
700 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
701 | 0 | if (!GetOrCreateDOMReflector(cx, result, args.rval())) { |
702 | 0 | MOZ_ASSERT(JS_IsExceptionPending(cx)); |
703 | 0 | return false; |
704 | 0 | } |
705 | 0 | return true; |
706 | 0 | } |
707 | | |
708 | | static const JSJitInfo count_methodinfo = { |
709 | | { (JSJitGetterOp)count }, |
710 | | { prototypes::id::IDBIndex }, |
711 | | { PrototypeTraits<prototypes::id::IDBIndex>::Depth }, |
712 | | JSJitInfo::Method, |
713 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
714 | | JSVAL_TYPE_OBJECT, /* returnType. Not relevant for setters. */ |
715 | | false, /* isInfallible. False in setters. */ |
716 | | false, /* isMovable. Not relevant for setters. */ |
717 | | false, /* isEliminatable. Not relevant for setters. */ |
718 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
719 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
720 | | false, /* isTypedMethod. Only relevant for methods. */ |
721 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
722 | | }; |
723 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
724 | | static_assert(0 < 1, "There is no slot for us"); |
725 | | |
726 | | MOZ_CAN_RUN_SCRIPT static bool |
727 | | mozGetAll(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::IDBIndex* self, const JSJitMethodCallArgs& args) |
728 | 0 | { |
729 | 0 | AUTO_PROFILER_LABEL_FAST("IDBIndex.mozGetAll", DOM, cx); |
730 | 0 |
|
731 | 0 | JS::Rooted<JS::Value> arg0(cx); |
732 | 0 | if (args.hasDefined(0)) { |
733 | 0 | arg0 = args[0]; |
734 | 0 | } else { |
735 | 0 | arg0 = JS::UndefinedValue(); |
736 | 0 | } |
737 | 0 | Optional<uint32_t> arg1; |
738 | 0 | if (args.hasDefined(1)) { |
739 | 0 | arg1.Construct(); |
740 | 0 | if (!ValueToPrimitive<uint32_t, eEnforceRange>(cx, args[1], &arg1.Value())) { |
741 | 0 | return false; |
742 | 0 | } |
743 | 0 | } |
744 | 0 | FastErrorResult rv; |
745 | 0 | auto result(StrongOrRawPtr<mozilla::dom::IDBRequest>(self->GetAll(cx, arg0, Constify(arg1), rv))); |
746 | 0 | if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) { |
747 | 0 | return false; |
748 | 0 | } |
749 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
750 | 0 | if (!GetOrCreateDOMReflector(cx, result, args.rval())) { |
751 | 0 | MOZ_ASSERT(JS_IsExceptionPending(cx)); |
752 | 0 | return false; |
753 | 0 | } |
754 | 0 | return true; |
755 | 0 | } |
756 | | |
757 | | static const JSJitInfo mozGetAll_methodinfo = { |
758 | | { (JSJitGetterOp)mozGetAll }, |
759 | | { prototypes::id::IDBIndex }, |
760 | | { PrototypeTraits<prototypes::id::IDBIndex>::Depth }, |
761 | | JSJitInfo::Method, |
762 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
763 | | JSVAL_TYPE_OBJECT, /* returnType. Not relevant for setters. */ |
764 | | false, /* isInfallible. False in setters. */ |
765 | | false, /* isMovable. Not relevant for setters. */ |
766 | | false, /* isEliminatable. Not relevant for setters. */ |
767 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
768 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
769 | | false, /* isTypedMethod. Only relevant for methods. */ |
770 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
771 | | }; |
772 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
773 | | static_assert(0 < 1, "There is no slot for us"); |
774 | | |
775 | | MOZ_CAN_RUN_SCRIPT static bool |
776 | | mozGetAllKeys(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::IDBIndex* self, const JSJitMethodCallArgs& args) |
777 | 0 | { |
778 | 0 | AUTO_PROFILER_LABEL_FAST("IDBIndex.mozGetAllKeys", DOM, cx); |
779 | 0 |
|
780 | 0 | JS::Rooted<JS::Value> arg0(cx); |
781 | 0 | if (args.hasDefined(0)) { |
782 | 0 | arg0 = args[0]; |
783 | 0 | } else { |
784 | 0 | arg0 = JS::UndefinedValue(); |
785 | 0 | } |
786 | 0 | Optional<uint32_t> arg1; |
787 | 0 | if (args.hasDefined(1)) { |
788 | 0 | arg1.Construct(); |
789 | 0 | if (!ValueToPrimitive<uint32_t, eEnforceRange>(cx, args[1], &arg1.Value())) { |
790 | 0 | return false; |
791 | 0 | } |
792 | 0 | } |
793 | 0 | FastErrorResult rv; |
794 | 0 | auto result(StrongOrRawPtr<mozilla::dom::IDBRequest>(self->GetAllKeys(cx, arg0, Constify(arg1), rv))); |
795 | 0 | if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) { |
796 | 0 | return false; |
797 | 0 | } |
798 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
799 | 0 | if (!GetOrCreateDOMReflector(cx, result, args.rval())) { |
800 | 0 | MOZ_ASSERT(JS_IsExceptionPending(cx)); |
801 | 0 | return false; |
802 | 0 | } |
803 | 0 | return true; |
804 | 0 | } |
805 | | |
806 | | static const JSJitInfo mozGetAllKeys_methodinfo = { |
807 | | { (JSJitGetterOp)mozGetAllKeys }, |
808 | | { prototypes::id::IDBIndex }, |
809 | | { PrototypeTraits<prototypes::id::IDBIndex>::Depth }, |
810 | | JSJitInfo::Method, |
811 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
812 | | JSVAL_TYPE_OBJECT, /* returnType. Not relevant for setters. */ |
813 | | false, /* isInfallible. False in setters. */ |
814 | | false, /* isMovable. Not relevant for setters. */ |
815 | | false, /* isEliminatable. Not relevant for setters. */ |
816 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
817 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
818 | | false, /* isTypedMethod. Only relevant for methods. */ |
819 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
820 | | }; |
821 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
822 | | static_assert(0 < 1, "There is no slot for us"); |
823 | | |
824 | | MOZ_CAN_RUN_SCRIPT static bool |
825 | | getAll(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::IDBIndex* self, const JSJitMethodCallArgs& args) |
826 | 0 | { |
827 | 0 | AUTO_PROFILER_LABEL_FAST("IDBIndex.getAll", DOM, cx); |
828 | 0 |
|
829 | 0 | JS::Rooted<JS::Value> arg0(cx); |
830 | 0 | if (args.hasDefined(0)) { |
831 | 0 | arg0 = args[0]; |
832 | 0 | } else { |
833 | 0 | arg0 = JS::UndefinedValue(); |
834 | 0 | } |
835 | 0 | Optional<uint32_t> arg1; |
836 | 0 | if (args.hasDefined(1)) { |
837 | 0 | arg1.Construct(); |
838 | 0 | if (!ValueToPrimitive<uint32_t, eEnforceRange>(cx, args[1], &arg1.Value())) { |
839 | 0 | return false; |
840 | 0 | } |
841 | 0 | } |
842 | 0 | FastErrorResult rv; |
843 | 0 | auto result(StrongOrRawPtr<mozilla::dom::IDBRequest>(self->GetAll(cx, arg0, Constify(arg1), rv))); |
844 | 0 | if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) { |
845 | 0 | return false; |
846 | 0 | } |
847 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
848 | 0 | if (!GetOrCreateDOMReflector(cx, result, args.rval())) { |
849 | 0 | MOZ_ASSERT(JS_IsExceptionPending(cx)); |
850 | 0 | return false; |
851 | 0 | } |
852 | 0 | return true; |
853 | 0 | } |
854 | | |
855 | | static const JSJitInfo getAll_methodinfo = { |
856 | | { (JSJitGetterOp)getAll }, |
857 | | { prototypes::id::IDBIndex }, |
858 | | { PrototypeTraits<prototypes::id::IDBIndex>::Depth }, |
859 | | JSJitInfo::Method, |
860 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
861 | | JSVAL_TYPE_OBJECT, /* returnType. Not relevant for setters. */ |
862 | | false, /* isInfallible. False in setters. */ |
863 | | false, /* isMovable. Not relevant for setters. */ |
864 | | false, /* isEliminatable. Not relevant for setters. */ |
865 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
866 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
867 | | false, /* isTypedMethod. Only relevant for methods. */ |
868 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
869 | | }; |
870 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
871 | | static_assert(0 < 1, "There is no slot for us"); |
872 | | |
873 | | MOZ_CAN_RUN_SCRIPT static bool |
874 | | getAllKeys(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::IDBIndex* self, const JSJitMethodCallArgs& args) |
875 | 0 | { |
876 | 0 | AUTO_PROFILER_LABEL_FAST("IDBIndex.getAllKeys", DOM, cx); |
877 | 0 |
|
878 | 0 | JS::Rooted<JS::Value> arg0(cx); |
879 | 0 | if (args.hasDefined(0)) { |
880 | 0 | arg0 = args[0]; |
881 | 0 | } else { |
882 | 0 | arg0 = JS::UndefinedValue(); |
883 | 0 | } |
884 | 0 | Optional<uint32_t> arg1; |
885 | 0 | if (args.hasDefined(1)) { |
886 | 0 | arg1.Construct(); |
887 | 0 | if (!ValueToPrimitive<uint32_t, eEnforceRange>(cx, args[1], &arg1.Value())) { |
888 | 0 | return false; |
889 | 0 | } |
890 | 0 | } |
891 | 0 | FastErrorResult rv; |
892 | 0 | auto result(StrongOrRawPtr<mozilla::dom::IDBRequest>(self->GetAllKeys(cx, arg0, Constify(arg1), rv))); |
893 | 0 | if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) { |
894 | 0 | return false; |
895 | 0 | } |
896 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
897 | 0 | if (!GetOrCreateDOMReflector(cx, result, args.rval())) { |
898 | 0 | MOZ_ASSERT(JS_IsExceptionPending(cx)); |
899 | 0 | return false; |
900 | 0 | } |
901 | 0 | return true; |
902 | 0 | } |
903 | | |
904 | | static const JSJitInfo getAllKeys_methodinfo = { |
905 | | { (JSJitGetterOp)getAllKeys }, |
906 | | { prototypes::id::IDBIndex }, |
907 | | { PrototypeTraits<prototypes::id::IDBIndex>::Depth }, |
908 | | JSJitInfo::Method, |
909 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
910 | | JSVAL_TYPE_OBJECT, /* returnType. Not relevant for setters. */ |
911 | | false, /* isInfallible. False in setters. */ |
912 | | false, /* isMovable. Not relevant for setters. */ |
913 | | false, /* isEliminatable. Not relevant for setters. */ |
914 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
915 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
916 | | false, /* isTypedMethod. Only relevant for methods. */ |
917 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
918 | | }; |
919 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
920 | | static_assert(0 < 1, "There is no slot for us"); |
921 | | |
922 | | static bool |
923 | | _addProperty(JSContext* cx, JS::Handle<JSObject*> obj, JS::Handle<jsid> id, JS::Handle<JS::Value> val) |
924 | 0 | { |
925 | 0 | mozilla::dom::IDBIndex* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::IDBIndex>(obj); |
926 | 0 | // We don't want to preserve if we don't have a wrapper, and we |
927 | 0 | // obviously can't preserve if we're not initialized. |
928 | 0 | if (self && self->GetWrapperPreserveColor()) { |
929 | 0 | PreserveWrapper(self); |
930 | 0 | } |
931 | 0 | return true; |
932 | 0 | } |
933 | | |
934 | | static void |
935 | | _finalize(js::FreeOp* fop, JSObject* obj) |
936 | 0 | { |
937 | 0 | mozilla::dom::IDBIndex* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::IDBIndex>(obj); |
938 | 0 | if (self) { |
939 | 0 | ClearWrapper(self, self, obj); |
940 | 0 | AddForDeferredFinalization<mozilla::dom::IDBIndex>(self); |
941 | 0 | } |
942 | 0 | } |
943 | | |
944 | | static size_t |
945 | | _objectMoved(JSObject* obj, JSObject* old) |
946 | 0 | { |
947 | 0 | mozilla::dom::IDBIndex* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::IDBIndex>(obj); |
948 | 0 | if (self) { |
949 | 0 | UpdateWrapper(self, self, obj, old); |
950 | 0 | } |
951 | 0 |
|
952 | 0 | return 0; |
953 | 0 | } |
954 | | |
955 | | // We deliberately use brace-elision to make Visual Studio produce better initalization code. |
956 | | #if defined(__clang__) |
957 | | #pragma clang diagnostic push |
958 | | #pragma clang diagnostic ignored "-Wmissing-braces" |
959 | | #endif |
960 | | static const JSFunctionSpec sMethods_specs[] = { |
961 | | JS_FNSPEC("openCursor", (GenericMethod<NormalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&openCursor_methodinfo), 0, JSPROP_ENUMERATE, nullptr), |
962 | | JS_FNSPEC("openKeyCursor", (GenericMethod<NormalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&openKeyCursor_methodinfo), 0, JSPROP_ENUMERATE, nullptr), |
963 | | JS_FNSPEC("get", (GenericMethod<NormalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&get_methodinfo), 1, JSPROP_ENUMERATE, nullptr), |
964 | | JS_FNSPEC("getKey", (GenericMethod<NormalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&getKey_methodinfo), 1, JSPROP_ENUMERATE, nullptr), |
965 | | JS_FNSPEC("count", (GenericMethod<NormalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&count_methodinfo), 0, JSPROP_ENUMERATE, nullptr), |
966 | | JS_FNSPEC("mozGetAll", (GenericMethod<NormalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&mozGetAll_methodinfo), 0, JSPROP_ENUMERATE, nullptr), |
967 | | JS_FNSPEC("mozGetAllKeys", (GenericMethod<NormalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&mozGetAllKeys_methodinfo), 0, JSPROP_ENUMERATE, nullptr), |
968 | | JS_FNSPEC("getAll", (GenericMethod<NormalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&getAll_methodinfo), 0, JSPROP_ENUMERATE, nullptr), |
969 | | JS_FNSPEC("getAllKeys", (GenericMethod<NormalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&getAllKeys_methodinfo), 0, JSPROP_ENUMERATE, nullptr), |
970 | | JS_FS_END |
971 | | }; |
972 | | #if defined(__clang__) |
973 | | #pragma clang diagnostic pop |
974 | | #endif |
975 | | |
976 | | |
977 | | static const Prefable<const JSFunctionSpec> sMethods[] = { |
978 | | { nullptr, &sMethods_specs[0] }, |
979 | | { nullptr, nullptr } |
980 | | }; |
981 | | |
982 | | static_assert(1 <= 1ull << NUM_BITS_PROPERTY_INFO_PREF_INDEX, |
983 | | "We have a prefable index that is >= (1 << NUM_BITS_PROPERTY_INFO_PREF_INDEX)"); |
984 | | static_assert(9 <= 1ull << NUM_BITS_PROPERTY_INFO_SPEC_INDEX, |
985 | | "We have a spec index that is >= (1 << NUM_BITS_PROPERTY_INFO_SPEC_INDEX)"); |
986 | | |
987 | | // We deliberately use brace-elision to make Visual Studio produce better initalization code. |
988 | | #if defined(__clang__) |
989 | | #pragma clang diagnostic push |
990 | | #pragma clang diagnostic ignored "-Wmissing-braces" |
991 | | #endif |
992 | | static const JSPropertySpec sAttributes_specs[] = { |
993 | | { "name", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &name_getterinfo, GenericSetter<NormalThisPolicy>, &name_setterinfo }, |
994 | | { "objectStore", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &objectStore_getterinfo, nullptr, nullptr }, |
995 | | { "keyPath", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &keyPath_getterinfo, nullptr, nullptr }, |
996 | | { "multiEntry", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &multiEntry_getterinfo, nullptr, nullptr }, |
997 | | { "unique", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &unique_getterinfo, nullptr, nullptr }, |
998 | | { nullptr, 0, nullptr, nullptr, nullptr, nullptr }, |
999 | | { "locale", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &locale_getterinfo, nullptr, nullptr }, |
1000 | | { "isAutoLocale", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &isAutoLocale_getterinfo, nullptr, nullptr }, |
1001 | | { nullptr, 0, nullptr, nullptr, nullptr, nullptr } |
1002 | | }; |
1003 | | #if defined(__clang__) |
1004 | | #pragma clang diagnostic pop |
1005 | | #endif |
1006 | | |
1007 | | // Can't be const because the pref-enabled boolean needs to be writable |
1008 | | static PrefableDisablers sAttributes_disablers6 = { |
1009 | | true, false, 0, &mozilla::dom::IndexedDatabaseManager::ExperimentalFeaturesEnabled |
1010 | | }; |
1011 | | |
1012 | | static const Prefable<const JSPropertySpec> sAttributes[] = { |
1013 | | { nullptr, &sAttributes_specs[0] }, |
1014 | | { &sAttributes_disablers6, &sAttributes_specs[6] }, |
1015 | | { nullptr, nullptr } |
1016 | | }; |
1017 | | |
1018 | | static_assert(2 <= 1ull << NUM_BITS_PROPERTY_INFO_PREF_INDEX, |
1019 | | "We have a prefable index that is >= (1 << NUM_BITS_PROPERTY_INFO_PREF_INDEX)"); |
1020 | | static_assert(5 <= 1ull << NUM_BITS_PROPERTY_INFO_SPEC_INDEX, |
1021 | | "We have a spec index that is >= (1 << NUM_BITS_PROPERTY_INFO_SPEC_INDEX)"); |
1022 | | |
1023 | | |
1024 | | static uint16_t sNativeProperties_sortedPropertyIndices[16]; |
1025 | | static PropertyInfo sNativeProperties_propertyInfos[16]; |
1026 | | |
1027 | | static const NativePropertiesN<2> sNativeProperties = { |
1028 | | false, 0, |
1029 | | false, 0, |
1030 | | true, 0 /* sMethods */, |
1031 | | true, 1 /* sAttributes */, |
1032 | | false, 0, |
1033 | | false, 0, |
1034 | | false, 0, |
1035 | | -1, |
1036 | | 16, |
1037 | | sNativeProperties_sortedPropertyIndices, |
1038 | | { |
1039 | | { sMethods, &sNativeProperties_propertyInfos[0] }, |
1040 | | { sAttributes, &sNativeProperties_propertyInfos[9] } |
1041 | | } |
1042 | | }; |
1043 | | static_assert(16 < 1ull << CHAR_BIT * sizeof(sNativeProperties.propertyInfoCount), |
1044 | | "We have a property info count that is oversized"); |
1045 | | |
1046 | | static const DOMIfaceAndProtoJSClass sInterfaceObjectClass = { |
1047 | | { |
1048 | | "Function", |
1049 | | JSCLASS_IS_DOMIFACEANDPROTOJSCLASS | JSCLASS_HAS_RESERVED_SLOTS(DOM_INTERFACE_SLOTS_BASE), |
1050 | | &sBoringInterfaceObjectClassClassOps, |
1051 | | JS_NULL_CLASS_SPEC, |
1052 | | JS_NULL_CLASS_EXT, |
1053 | | &sInterfaceObjectClassObjectOps |
1054 | | }, |
1055 | | eInterface, |
1056 | | true, |
1057 | | prototypes::id::IDBIndex, |
1058 | | PrototypeTraits<prototypes::id::IDBIndex>::Depth, |
1059 | | sNativePropertyHooks, |
1060 | | "function IDBIndex() {\n [native code]\n}", |
1061 | | JS::GetRealmFunctionPrototype |
1062 | | }; |
1063 | | |
1064 | | static const DOMIfaceAndProtoJSClass sPrototypeClass = { |
1065 | | { |
1066 | | "IDBIndexPrototype", |
1067 | | JSCLASS_IS_DOMIFACEANDPROTOJSCLASS | JSCLASS_HAS_RESERVED_SLOTS(DOM_INTERFACE_PROTO_SLOTS_BASE), |
1068 | | JS_NULL_CLASS_OPS, |
1069 | | JS_NULL_CLASS_SPEC, |
1070 | | JS_NULL_CLASS_EXT, |
1071 | | JS_NULL_OBJECT_OPS |
1072 | | }, |
1073 | | eInterfacePrototype, |
1074 | | false, |
1075 | | prototypes::id::IDBIndex, |
1076 | | PrototypeTraits<prototypes::id::IDBIndex>::Depth, |
1077 | | sNativePropertyHooks, |
1078 | | "[object IDBIndexPrototype]", |
1079 | | JS::GetRealmObjectPrototype |
1080 | | }; |
1081 | | |
1082 | | static const js::ClassOps sClassOps = { |
1083 | | _addProperty, /* addProperty */ |
1084 | | nullptr, /* delProperty */ |
1085 | | nullptr, /* enumerate */ |
1086 | | nullptr, /* newEnumerate */ |
1087 | | nullptr, /* resolve */ |
1088 | | nullptr, /* mayResolve */ |
1089 | | _finalize, /* finalize */ |
1090 | | nullptr, /* call */ |
1091 | | nullptr, /* hasInstance */ |
1092 | | nullptr, /* construct */ |
1093 | | nullptr, /* trace */ |
1094 | | }; |
1095 | | |
1096 | | static const js::ClassExtension sClassExtension = { |
1097 | | nullptr, /* weakmapKeyDelegateOp */ |
1098 | | _objectMoved /* objectMovedOp */ |
1099 | | }; |
1100 | | |
1101 | | static const DOMJSClass sClass = { |
1102 | | { "IDBIndex", |
1103 | | JSCLASS_IS_DOMJSCLASS | JSCLASS_FOREGROUND_FINALIZE | JSCLASS_HAS_RESERVED_SLOTS(1), |
1104 | | &sClassOps, |
1105 | | JS_NULL_CLASS_SPEC, |
1106 | | &sClassExtension, |
1107 | | JS_NULL_OBJECT_OPS |
1108 | | }, |
1109 | | { prototypes::id::IDBIndex, 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 }, |
1110 | | IsBaseOf<nsISupports, mozilla::dom::IDBIndex >::value, |
1111 | | sNativePropertyHooks, |
1112 | | FindAssociatedGlobalForNative<mozilla::dom::IDBIndex>::Get, |
1113 | | GetProtoObjectHandle, |
1114 | | GetCCParticipant<mozilla::dom::IDBIndex>::Get() |
1115 | | }; |
1116 | | static_assert(1 == DOM_INSTANCE_RESERVED_SLOTS, |
1117 | | "Must have the right minimal number of reserved slots."); |
1118 | | static_assert(1 >= 1, |
1119 | | "Must have enough reserved slots."); |
1120 | | |
1121 | | const JSClass* |
1122 | | GetJSClass() |
1123 | 0 | { |
1124 | 0 | return sClass.ToJSClass(); |
1125 | 0 | } |
1126 | | |
1127 | | bool |
1128 | | Wrap(JSContext* aCx, mozilla::dom::IDBIndex* aObject, nsWrapperCache* aCache, JS::Handle<JSObject*> aGivenProto, JS::MutableHandle<JSObject*> aReflector) |
1129 | 0 | { |
1130 | 0 | static_assert(!IsBaseOf<NonRefcountedDOMObject, mozilla::dom::IDBIndex>::value, |
1131 | 0 | "Shouldn't have wrappercached things that are not refcounted."); |
1132 | 0 | MOZ_ASSERT(static_cast<mozilla::dom::IDBIndex*>(aObject) == |
1133 | 0 | reinterpret_cast<mozilla::dom::IDBIndex*>(aObject), |
1134 | 0 | "Multiple inheritance for mozilla::dom::IDBIndex is broken."); |
1135 | 0 | MOZ_ASSERT(ToSupportsIsCorrect(aObject)); |
1136 | 0 | MOZ_ASSERT_IF(aGivenProto, js::IsObjectInContextCompartment(aGivenProto, aCx)); |
1137 | 0 | MOZ_ASSERT(!aCache->GetWrapper(), |
1138 | 0 | "You should probably not be using Wrap() directly; use " |
1139 | 0 | "GetOrCreateDOMReflector instead"); |
1140 | 0 |
|
1141 | 0 | MOZ_ASSERT(ToSupportsIsOnPrimaryInheritanceChain(aObject, aCache), |
1142 | 0 | "nsISupports must be on our primary inheritance chain"); |
1143 | 0 |
|
1144 | 0 | JS::Rooted<JSObject*> global(aCx, FindAssociatedGlobal(aCx, aObject->GetParentObject())); |
1145 | 0 | if (!global) { |
1146 | 0 | return false; |
1147 | 0 | } |
1148 | 0 | MOZ_ASSERT(JS_IsGlobalObject(global)); |
1149 | 0 | MOZ_ASSERT(JS::ObjectIsNotGray(global)); |
1150 | 0 |
|
1151 | 0 | // That might have ended up wrapping us already, due to the wonders |
1152 | 0 | // of XBL. Check for that, and bail out as needed. |
1153 | 0 | aReflector.set(aCache->GetWrapper()); |
1154 | 0 | if (aReflector) { |
1155 | | #ifdef DEBUG |
1156 | | AssertReflectorHasGivenProto(aCx, aReflector, aGivenProto); |
1157 | | #endif // DEBUG |
1158 | | return true; |
1159 | 0 | } |
1160 | 0 |
|
1161 | 0 | JSAutoRealm ar(aCx, global); |
1162 | 0 | JS::Handle<JSObject*> canonicalProto = GetProtoObjectHandle(aCx); |
1163 | 0 | if (!canonicalProto) { |
1164 | 0 | return false; |
1165 | 0 | } |
1166 | 0 | JS::Rooted<JSObject*> proto(aCx); |
1167 | 0 | if (aGivenProto) { |
1168 | 0 | proto = aGivenProto; |
1169 | 0 | // Unfortunately, while aGivenProto was in the compartment of aCx |
1170 | 0 | // coming in, we changed compartments to that of "parent" so may need |
1171 | 0 | // to wrap the proto here. |
1172 | 0 | if (js::GetContextCompartment(aCx) != js::GetObjectCompartment(proto)) { |
1173 | 0 | if (!JS_WrapObject(aCx, &proto)) { |
1174 | 0 | return false; |
1175 | 0 | } |
1176 | 0 | } |
1177 | 0 | } else { |
1178 | 0 | proto = canonicalProto; |
1179 | 0 | } |
1180 | 0 |
|
1181 | 0 | BindingJSObjectCreator<mozilla::dom::IDBIndex> creator(aCx); |
1182 | 0 | creator.CreateObject(aCx, sClass.ToJSClass(), proto, aObject, aReflector); |
1183 | 0 | if (!aReflector) { |
1184 | 0 | return false; |
1185 | 0 | } |
1186 | 0 | |
1187 | 0 | aCache->SetWrapper(aReflector); |
1188 | 0 | creator.InitializationSucceeded(); |
1189 | 0 |
|
1190 | 0 | MOZ_ASSERT(aCache->GetWrapperPreserveColor() && |
1191 | 0 | aCache->GetWrapperPreserveColor() == aReflector); |
1192 | 0 | // If proto != canonicalProto, we have to preserve our wrapper; |
1193 | 0 | // otherwise we won't be able to properly recreate it later, since |
1194 | 0 | // we won't know what proto to use. Note that we don't check |
1195 | 0 | // aGivenProto here, since it's entirely possible (and even |
1196 | 0 | // somewhat common) to have a non-null aGivenProto which is the |
1197 | 0 | // same as canonicalProto. |
1198 | 0 | if (proto != canonicalProto) { |
1199 | 0 | PreserveWrapper(aObject); |
1200 | 0 | } |
1201 | 0 |
|
1202 | 0 | return true; |
1203 | 0 | } |
1204 | | |
1205 | | const NativePropertyHooks sNativePropertyHooks[] = { { |
1206 | | nullptr, |
1207 | | nullptr, |
1208 | | nullptr, |
1209 | | { sNativeProperties.Upcast(), nullptr }, |
1210 | | prototypes::id::IDBIndex, |
1211 | | constructors::id::IDBIndex, |
1212 | | nullptr, |
1213 | | &DefaultXrayExpandoObjectClass |
1214 | | } }; |
1215 | | |
1216 | | void |
1217 | | CreateInterfaceObjects(JSContext* aCx, JS::Handle<JSObject*> aGlobal, ProtoAndIfaceCache& aProtoAndIfaceCache, bool aDefineOnGlobal) |
1218 | 0 | { |
1219 | 0 | JS::Rooted<JSObject*> parentProto(aCx, JS::GetRealmObjectPrototype(aCx)); |
1220 | 0 | if (!parentProto) { |
1221 | 0 | return; |
1222 | 0 | } |
1223 | 0 | |
1224 | 0 | JS::Rooted<JSObject*> constructorProto(aCx, JS::GetRealmFunctionPrototype(aCx)); |
1225 | 0 | if (!constructorProto) { |
1226 | 0 | return; |
1227 | 0 | } |
1228 | 0 | |
1229 | 0 | static bool sIdsInited = false; |
1230 | 0 | if (!sIdsInited && NS_IsMainThread()) { |
1231 | 0 | if (!InitIds(aCx, sNativeProperties.Upcast())) { |
1232 | 0 | return; |
1233 | 0 | } |
1234 | 0 | sIdsInited = true; |
1235 | 0 | } |
1236 | 0 |
|
1237 | 0 | JS::Heap<JSObject*>* protoCache = &aProtoAndIfaceCache.EntrySlotOrCreate(prototypes::id::IDBIndex); |
1238 | 0 | JS::Heap<JSObject*>* interfaceCache = &aProtoAndIfaceCache.EntrySlotOrCreate(constructors::id::IDBIndex); |
1239 | 0 | dom::CreateInterfaceObjects(aCx, aGlobal, parentProto, |
1240 | 0 | &sPrototypeClass.mBase, protoCache, |
1241 | 0 | nullptr, |
1242 | 0 | constructorProto, &sInterfaceObjectClass.mBase, 0, nullptr, |
1243 | 0 | interfaceCache, |
1244 | 0 | sNativeProperties.Upcast(), |
1245 | 0 | nullptr, |
1246 | 0 | "IDBIndex", aDefineOnGlobal, |
1247 | 0 | nullptr, |
1248 | 0 | false); |
1249 | 0 | } |
1250 | | |
1251 | | JSObject* |
1252 | | GetConstructorObject(JSContext* aCx) |
1253 | 0 | { |
1254 | 0 | return GetConstructorObjectHandle(aCx); |
1255 | 0 | } |
1256 | | |
1257 | | } // namespace IDBIndex_Binding |
1258 | | |
1259 | | |
1260 | | |
1261 | | } // namespace dom |
1262 | | } // namespace mozilla |