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