/work/obj-fuzz/dom/bindings/PluginArrayBinding.cpp
Line | Count | Source (jump to first uncovered line) |
1 | | /* THIS FILE IS AUTOGENERATED FROM PluginArray.webidl BY Codegen.py - DO NOT EDIT */ |
2 | | |
3 | | #include "PluginArrayBinding.h" |
4 | | #include "WrapperFactory.h" |
5 | | #include "mozilla/OwningNonNull.h" |
6 | | #include "mozilla/dom/BindingUtils.h" |
7 | | #include "mozilla/dom/DOMJSClass.h" |
8 | | #include "mozilla/dom/DOMJSProxyHandler.h" |
9 | | #include "mozilla/dom/NonRefcountedDOMObject.h" |
10 | | #include "mozilla/dom/Nullable.h" |
11 | | #include "mozilla/dom/PrimitiveConversions.h" |
12 | | #include "mozilla/dom/XrayExpandoClass.h" |
13 | | #include "nsContentUtils.h" |
14 | | #include "nsPluginArray.h" |
15 | | |
16 | | namespace mozilla { |
17 | | namespace dom { |
18 | | |
19 | | namespace binding_detail {}; // Just to make sure it's known as a namespace |
20 | | using namespace mozilla::dom::binding_detail; |
21 | | |
22 | | |
23 | | namespace PluginArray_Binding { |
24 | | |
25 | | MOZ_CAN_RUN_SCRIPT static bool |
26 | | get_length(JSContext* cx, JS::Handle<JSObject*> obj, nsPluginArray* self, JSJitGetterCallArgs args) |
27 | 0 | { |
28 | 0 | AUTO_PROFILER_LABEL_FAST("get PluginArray.length", DOM, cx); |
29 | 0 |
|
30 | 0 | uint32_t result(self->Length(nsContentUtils::IsSystemCaller(cx) ? CallerType::System : CallerType::NonSystem)); |
31 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
32 | 0 | args.rval().setNumber(result); |
33 | 0 | return true; |
34 | 0 | } |
35 | | |
36 | | static const JSJitInfo length_getterinfo = { |
37 | | { (JSJitGetterOp)get_length }, |
38 | | { prototypes::id::PluginArray }, |
39 | | { PrototypeTraits<prototypes::id::PluginArray>::Depth }, |
40 | | JSJitInfo::Getter, |
41 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
42 | | JSVAL_TYPE_DOUBLE, /* returnType. Not relevant for setters. */ |
43 | | true, /* isInfallible. False in setters. */ |
44 | | false, /* isMovable. Not relevant for setters. */ |
45 | | false, /* isEliminatable. Not relevant for setters. */ |
46 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
47 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
48 | | false, /* isTypedMethod. Only relevant for methods. */ |
49 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
50 | | }; |
51 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
52 | | static_assert(0 < 1, "There is no slot for us"); |
53 | | |
54 | | MOZ_CAN_RUN_SCRIPT static bool |
55 | | item(JSContext* cx, JS::Handle<JSObject*> obj, nsPluginArray* self, const JSJitMethodCallArgs& args) |
56 | 0 | { |
57 | 0 | AUTO_PROFILER_LABEL_FAST("PluginArray.item", DOM, cx); |
58 | 0 |
|
59 | 0 | if (MOZ_UNLIKELY(args.length() < 1)) { |
60 | 0 | return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "PluginArray.item"); |
61 | 0 | } |
62 | 0 | uint32_t arg0; |
63 | 0 | if (!ValueToPrimitive<uint32_t, eDefault>(cx, args[0], &arg0)) { |
64 | 0 | return false; |
65 | 0 | } |
66 | 0 | auto result(StrongOrRawPtr<nsPluginElement>(self->Item(arg0, nsContentUtils::IsSystemCaller(cx) ? CallerType::System : CallerType::NonSystem))); |
67 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
68 | 0 | if (!result) { |
69 | 0 | args.rval().setNull(); |
70 | 0 | return true; |
71 | 0 | } |
72 | 0 | if (!GetOrCreateDOMReflector(cx, result, args.rval())) { |
73 | 0 | MOZ_ASSERT(JS_IsExceptionPending(cx)); |
74 | 0 | return false; |
75 | 0 | } |
76 | 0 | return true; |
77 | 0 | } |
78 | | |
79 | | static const JSJitInfo item_methodinfo = { |
80 | | { (JSJitGetterOp)item }, |
81 | | { prototypes::id::PluginArray }, |
82 | | { PrototypeTraits<prototypes::id::PluginArray>::Depth }, |
83 | | JSJitInfo::Method, |
84 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
85 | | JSVAL_TYPE_UNKNOWN, /* returnType. Not relevant for setters. */ |
86 | | false, /* isInfallible. False in setters. */ |
87 | | false, /* isMovable. Not relevant for setters. */ |
88 | | false, /* isEliminatable. Not relevant for setters. */ |
89 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
90 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
91 | | false, /* isTypedMethod. Only relevant for methods. */ |
92 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
93 | | }; |
94 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
95 | | static_assert(0 < 1, "There is no slot for us"); |
96 | | |
97 | | MOZ_CAN_RUN_SCRIPT static bool |
98 | | namedItem(JSContext* cx, JS::Handle<JSObject*> obj, nsPluginArray* self, const JSJitMethodCallArgs& args) |
99 | 0 | { |
100 | 0 | AUTO_PROFILER_LABEL_FAST("PluginArray.namedItem", DOM, cx); |
101 | 0 |
|
102 | 0 | if (MOZ_UNLIKELY(args.length() < 1)) { |
103 | 0 | return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "PluginArray.namedItem"); |
104 | 0 | } |
105 | 0 | binding_detail::FakeString arg0; |
106 | 0 | if (!ConvertJSValueToString(cx, args[0], eStringify, eStringify, arg0)) { |
107 | 0 | return false; |
108 | 0 | } |
109 | 0 | auto result(StrongOrRawPtr<nsPluginElement>(self->NamedItem(NonNullHelper(Constify(arg0)), nsContentUtils::IsSystemCaller(cx) ? CallerType::System : CallerType::NonSystem))); |
110 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
111 | 0 | if (!result) { |
112 | 0 | args.rval().setNull(); |
113 | 0 | return true; |
114 | 0 | } |
115 | 0 | if (!GetOrCreateDOMReflector(cx, result, args.rval())) { |
116 | 0 | MOZ_ASSERT(JS_IsExceptionPending(cx)); |
117 | 0 | return false; |
118 | 0 | } |
119 | 0 | return true; |
120 | 0 | } |
121 | | |
122 | | static const JSJitInfo namedItem_methodinfo = { |
123 | | { (JSJitGetterOp)namedItem }, |
124 | | { prototypes::id::PluginArray }, |
125 | | { PrototypeTraits<prototypes::id::PluginArray>::Depth }, |
126 | | JSJitInfo::Method, |
127 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
128 | | JSVAL_TYPE_UNKNOWN, /* returnType. Not relevant for setters. */ |
129 | | false, /* isInfallible. False in setters. */ |
130 | | false, /* isMovable. Not relevant for setters. */ |
131 | | false, /* isEliminatable. Not relevant for setters. */ |
132 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
133 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
134 | | false, /* isTypedMethod. Only relevant for methods. */ |
135 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
136 | | }; |
137 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
138 | | static_assert(0 < 1, "There is no slot for us"); |
139 | | |
140 | | MOZ_CAN_RUN_SCRIPT static bool |
141 | | refresh(JSContext* cx, JS::Handle<JSObject*> obj, nsPluginArray* self, const JSJitMethodCallArgs& args) |
142 | 0 | { |
143 | 0 | AUTO_PROFILER_LABEL_FAST("PluginArray.refresh", DOM, cx); |
144 | 0 |
|
145 | 0 | bool arg0; |
146 | 0 | if (args.hasDefined(0)) { |
147 | 0 | if (!ValueToPrimitive<bool, eDefault>(cx, args[0], &arg0)) { |
148 | 0 | return false; |
149 | 0 | } |
150 | 0 | } else { |
151 | 0 | arg0 = false; |
152 | 0 | } |
153 | 0 | self->Refresh(arg0); |
154 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
155 | 0 | args.rval().setUndefined(); |
156 | 0 | return true; |
157 | 0 | } |
158 | | |
159 | | static const JSJitInfo refresh_methodinfo = { |
160 | | { (JSJitGetterOp)refresh }, |
161 | | { prototypes::id::PluginArray }, |
162 | | { PrototypeTraits<prototypes::id::PluginArray>::Depth }, |
163 | | JSJitInfo::Method, |
164 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
165 | | JSVAL_TYPE_UNDEFINED, /* returnType. Not relevant for setters. */ |
166 | | false, /* isInfallible. False in setters. */ |
167 | | false, /* isMovable. Not relevant for setters. */ |
168 | | false, /* isEliminatable. Not relevant for setters. */ |
169 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
170 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
171 | | false, /* isTypedMethod. Only relevant for methods. */ |
172 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
173 | | }; |
174 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
175 | | static_assert(0 < 1, "There is no slot for us"); |
176 | | |
177 | | // We deliberately use brace-elision to make Visual Studio produce better initalization code. |
178 | | #if defined(__clang__) |
179 | | #pragma clang diagnostic push |
180 | | #pragma clang diagnostic ignored "-Wmissing-braces" |
181 | | #endif |
182 | | static const JSFunctionSpec sMethods_specs[] = { |
183 | | JS_FNSPEC("item", (GenericMethod<NormalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&item_methodinfo), 1, JSPROP_ENUMERATE, nullptr), |
184 | | JS_FNSPEC("namedItem", (GenericMethod<NormalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&namedItem_methodinfo), 1, JSPROP_ENUMERATE, nullptr), |
185 | | JS_FNSPEC("refresh", (GenericMethod<NormalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&refresh_methodinfo), 0, JSPROP_ENUMERATE, nullptr), |
186 | | JS_SYM_FNSPEC(iterator, nullptr, nullptr, 0, 0, "ArrayValues"), |
187 | | JS_FS_END |
188 | | }; |
189 | | #if defined(__clang__) |
190 | | #pragma clang diagnostic pop |
191 | | #endif |
192 | | |
193 | | |
194 | | static const Prefable<const JSFunctionSpec> sMethods[] = { |
195 | | { nullptr, &sMethods_specs[0] }, |
196 | | { nullptr, nullptr } |
197 | | }; |
198 | | |
199 | | static_assert(1 <= 1ull << NUM_BITS_PROPERTY_INFO_PREF_INDEX, |
200 | | "We have a prefable index that is >= (1 << NUM_BITS_PROPERTY_INFO_PREF_INDEX)"); |
201 | | static_assert(4 <= 1ull << NUM_BITS_PROPERTY_INFO_SPEC_INDEX, |
202 | | "We have a spec index that is >= (1 << NUM_BITS_PROPERTY_INFO_SPEC_INDEX)"); |
203 | | |
204 | | // We deliberately use brace-elision to make Visual Studio produce better initalization code. |
205 | | #if defined(__clang__) |
206 | | #pragma clang diagnostic push |
207 | | #pragma clang diagnostic ignored "-Wmissing-braces" |
208 | | #endif |
209 | | static const JSPropertySpec sAttributes_specs[] = { |
210 | | { "length", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &length_getterinfo, nullptr, nullptr }, |
211 | | { nullptr, 0, nullptr, nullptr, nullptr, nullptr } |
212 | | }; |
213 | | #if defined(__clang__) |
214 | | #pragma clang diagnostic pop |
215 | | #endif |
216 | | |
217 | | |
218 | | static const Prefable<const JSPropertySpec> sAttributes[] = { |
219 | | { nullptr, &sAttributes_specs[0] }, |
220 | | { nullptr, nullptr } |
221 | | }; |
222 | | |
223 | | static_assert(1 <= 1ull << NUM_BITS_PROPERTY_INFO_PREF_INDEX, |
224 | | "We have a prefable index that is >= (1 << NUM_BITS_PROPERTY_INFO_PREF_INDEX)"); |
225 | | static_assert(1 <= 1ull << NUM_BITS_PROPERTY_INFO_SPEC_INDEX, |
226 | | "We have a spec index that is >= (1 << NUM_BITS_PROPERTY_INFO_SPEC_INDEX)"); |
227 | | |
228 | | |
229 | | static uint16_t sNativeProperties_sortedPropertyIndices[5]; |
230 | | static PropertyInfo sNativeProperties_propertyInfos[5]; |
231 | | |
232 | | static const NativePropertiesN<2> sNativeProperties = { |
233 | | false, 0, |
234 | | false, 0, |
235 | | true, 0 /* sMethods */, |
236 | | true, 1 /* sAttributes */, |
237 | | false, 0, |
238 | | false, 0, |
239 | | false, 0, |
240 | | -1, |
241 | | 5, |
242 | | sNativeProperties_sortedPropertyIndices, |
243 | | { |
244 | | { sMethods, &sNativeProperties_propertyInfos[0] }, |
245 | | { sAttributes, &sNativeProperties_propertyInfos[4] } |
246 | | } |
247 | | }; |
248 | | static_assert(5 < 1ull << CHAR_BIT * sizeof(sNativeProperties.propertyInfoCount), |
249 | | "We have a property info count that is oversized"); |
250 | | |
251 | | static const DOMIfaceAndProtoJSClass sInterfaceObjectClass = { |
252 | | { |
253 | | "Function", |
254 | | JSCLASS_IS_DOMIFACEANDPROTOJSCLASS | JSCLASS_HAS_RESERVED_SLOTS(DOM_INTERFACE_SLOTS_BASE), |
255 | | &sBoringInterfaceObjectClassClassOps, |
256 | | JS_NULL_CLASS_SPEC, |
257 | | JS_NULL_CLASS_EXT, |
258 | | &sInterfaceObjectClassObjectOps |
259 | | }, |
260 | | eInterface, |
261 | | true, |
262 | | prototypes::id::PluginArray, |
263 | | PrototypeTraits<prototypes::id::PluginArray>::Depth, |
264 | | sNativePropertyHooks, |
265 | | "function PluginArray() {\n [native code]\n}", |
266 | | JS::GetRealmFunctionPrototype |
267 | | }; |
268 | | |
269 | | static const DOMIfaceAndProtoJSClass sPrototypeClass = { |
270 | | { |
271 | | "PluginArrayPrototype", |
272 | | JSCLASS_IS_DOMIFACEANDPROTOJSCLASS | JSCLASS_HAS_RESERVED_SLOTS(DOM_INTERFACE_PROTO_SLOTS_BASE), |
273 | | JS_NULL_CLASS_OPS, |
274 | | JS_NULL_CLASS_SPEC, |
275 | | JS_NULL_CLASS_EXT, |
276 | | JS_NULL_OBJECT_OPS |
277 | | }, |
278 | | eInterfacePrototype, |
279 | | false, |
280 | | prototypes::id::PluginArray, |
281 | | PrototypeTraits<prototypes::id::PluginArray>::Depth, |
282 | | sNativePropertyHooks, |
283 | | "[object PluginArrayPrototype]", |
284 | | JS::GetRealmObjectPrototype |
285 | | }; |
286 | | |
287 | | static_assert(IsBaseOf<nsISupports, nsPluginArray >::value, |
288 | | "We don't support non-nsISupports native classes for " |
289 | | "proxy-based bindings yet"); |
290 | | |
291 | | |
292 | | class DOMProxyHandler : public mozilla::dom::DOMProxyHandler |
293 | | { |
294 | | public: |
295 | | explicit constexpr DOMProxyHandler() |
296 | 0 | { |
297 | 0 | } |
298 | | |
299 | | virtual bool |
300 | | getOwnPropDescriptor(JSContext* cx, JS::Handle<JSObject*> proxy, JS::Handle<jsid> id, bool ignoreNamedProps, JS::MutableHandle<JS::PropertyDescriptor> desc) const override; |
301 | | |
302 | | virtual bool |
303 | | defineProperty(JSContext* cx, JS::Handle<JSObject*> proxy, JS::Handle<jsid> id, JS::Handle<JS::PropertyDescriptor> desc, JS::ObjectOpResult& opresult, bool* defined) const override; |
304 | | |
305 | | using mozilla::dom::DOMProxyHandler::defineProperty; |
306 | | |
307 | | virtual bool |
308 | | ownPropNames(JSContext* cx, JS::Handle<JSObject*> proxy, unsigned flags, JS::AutoIdVector& props) const override; |
309 | | |
310 | | virtual bool |
311 | | hasOwn(JSContext* cx, JS::Handle<JSObject*> proxy, JS::Handle<jsid> id, bool* bp) const override; |
312 | | |
313 | | virtual bool |
314 | | get(JSContext* cx, JS::Handle<JSObject*> proxy, JS::Handle<JS::Value> receiver, JS::Handle<jsid> id, JS::MutableHandle<JS::Value> vp) const override; |
315 | | |
316 | | virtual const char* |
317 | | className(JSContext* cx, JS::Handle<JSObject*> proxy) const override; |
318 | | |
319 | | virtual bool |
320 | | finalizeInBackground(const JS::Value& priv) const override; |
321 | | |
322 | | virtual void |
323 | | finalize(JSFreeOp* fop, JSObject* proxy) const override; |
324 | | |
325 | | static const DOMProxyHandler* |
326 | | getInstance(); |
327 | | |
328 | | virtual bool |
329 | | delete_(JSContext* cx, JS::Handle<JSObject*> proxy, JS::Handle<jsid> id, JS::ObjectOpResult& opresult) const override; |
330 | | |
331 | | virtual bool |
332 | | getElements(JSContext* cx, JS::Handle<JSObject*> proxy, uint32_t begin, uint32_t end, js::ElementAdder* adder) const override; |
333 | | |
334 | | virtual size_t |
335 | | objectMoved(JSObject* obj, JSObject* old) const override; |
336 | | }; |
337 | | |
338 | | MOZ_ALWAYS_INLINE bool |
339 | | IsProxy(JSObject* obj) |
340 | 0 | { |
341 | 0 | return js::IsProxy(obj) && js::GetProxyHandler(obj) == DOMProxyHandler::getInstance(); |
342 | 0 | } |
343 | | |
344 | | MOZ_ALWAYS_INLINE nsPluginArray* |
345 | | UnwrapProxy(JSObject* obj) |
346 | 0 | { |
347 | 0 | MOZ_ASSERT(js::IsProxy(obj)); |
348 | 0 | if (js::GetProxyHandler(obj) != DOMProxyHandler::getInstance()) { |
349 | 0 | MOZ_ASSERT(xpc::WrapperFactory::IsXrayWrapper(obj)); |
350 | 0 | obj = js::UncheckedUnwrap(obj); |
351 | 0 | } |
352 | 0 | MOZ_ASSERT(IsProxy(obj)); |
353 | 0 | return static_cast<nsPluginArray*>(js::GetProxyReservedSlot(obj, DOM_OBJECT_SLOT).toPrivate()); |
354 | 0 | } |
355 | | |
356 | | bool |
357 | | DOMProxyHandler::getOwnPropDescriptor(JSContext* cx, JS::Handle<JSObject*> proxy, JS::Handle<jsid> id, bool ignoreNamedProps, JS::MutableHandle<JS::PropertyDescriptor> desc) const |
358 | 0 | { |
359 | 0 | bool isXray = xpc::WrapperFactory::IsXrayWrapper(proxy); |
360 | 0 | uint32_t index = GetArrayIndexFromId(cx, id); |
361 | 0 | if (IsArrayIndex(index)) { |
362 | 0 | nsPluginArray* self = UnwrapProxy(proxy); |
363 | 0 | bool found = false; |
364 | 0 | auto result(StrongOrRawPtr<nsPluginElement>(self->IndexedGetter(index, found, nsContentUtils::IsSystemCaller(cx) ? CallerType::System : CallerType::NonSystem))); |
365 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
366 | 0 |
|
367 | 0 | if (found) { |
368 | 0 | if (!result) { |
369 | 0 | desc.value().setNull(); |
370 | 0 | FillPropertyDescriptor(desc, proxy, true); |
371 | 0 | return true; |
372 | 0 | } |
373 | 0 | if (!GetOrCreateDOMReflector(cx, result, desc.value())) { |
374 | 0 | MOZ_ASSERT(JS_IsExceptionPending(cx)); |
375 | 0 | return false; |
376 | 0 | } |
377 | 0 | FillPropertyDescriptor(desc, proxy, true); |
378 | 0 | return true; |
379 | 0 | } |
380 | 0 | } |
381 | 0 |
|
382 | 0 | JS::Rooted<JSObject*> expando(cx); |
383 | 0 | if (!isXray && (expando = GetExpandoObject(proxy))) { |
384 | 0 | if (!JS_GetOwnPropertyDescriptorById(cx, expando, id, desc)) { |
385 | 0 | return false; |
386 | 0 | } |
387 | 0 | if (desc.object()) { |
388 | 0 | // Pretend the property lives on the wrapper. |
389 | 0 | desc.object().set(proxy); |
390 | 0 | return true; |
391 | 0 | } |
392 | 0 | } |
393 | 0 | |
394 | 0 | bool callNamedGetter = false; |
395 | 0 | if (!IsArrayIndex(index) && !ignoreNamedProps) { |
396 | 0 | bool hasOnProto; |
397 | 0 | if (!HasPropertyOnPrototype(cx, proxy, id, &hasOnProto)) { |
398 | 0 | return false; |
399 | 0 | } |
400 | 0 | callNamedGetter = !hasOnProto; |
401 | 0 | } |
402 | 0 | if (callNamedGetter) { |
403 | 0 | FakeString name; |
404 | 0 | bool isSymbol; |
405 | 0 | if (!ConvertIdToString(cx, id, name, isSymbol)) { |
406 | 0 | return false; |
407 | 0 | } |
408 | 0 | if (!isSymbol) { |
409 | 0 | nsPluginArray* self = UnwrapProxy(proxy); |
410 | 0 | bool found = false; |
411 | 0 | auto result(StrongOrRawPtr<nsPluginElement>(self->NamedGetter(NonNullHelper(Constify(name)), found, nsContentUtils::IsSystemCaller(cx) ? CallerType::System : CallerType::NonSystem))); |
412 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
413 | 0 |
|
414 | 0 | if (found) { |
415 | 0 | if (!result) { |
416 | 0 | desc.value().setNull(); |
417 | 0 | FillPropertyDescriptor(desc, proxy, true, false); |
418 | 0 | return true; |
419 | 0 | } |
420 | 0 | if (!GetOrCreateDOMReflector(cx, result, desc.value())) { |
421 | 0 | MOZ_ASSERT(JS_IsExceptionPending(cx)); |
422 | 0 | return false; |
423 | 0 | } |
424 | 0 | FillPropertyDescriptor(desc, proxy, true, false); |
425 | 0 | return true; |
426 | 0 | } |
427 | 0 | } |
428 | 0 | } |
429 | 0 |
|
430 | 0 | desc.object().set(nullptr); |
431 | 0 | return true; |
432 | 0 | } |
433 | | |
434 | | bool |
435 | | DOMProxyHandler::defineProperty(JSContext* cx, JS::Handle<JSObject*> proxy, JS::Handle<jsid> id, JS::Handle<JS::PropertyDescriptor> desc, JS::ObjectOpResult& opresult, bool* defined) const |
436 | 0 | { |
437 | 0 | if (IsArrayIndex(GetArrayIndexFromId(cx, id))) { |
438 | 0 | *defined = true; |
439 | 0 | return opresult.failNoIndexedSetter(); |
440 | 0 | } |
441 | 0 | bool found = false; |
442 | 0 | FakeString name; |
443 | 0 | bool isSymbol; |
444 | 0 | if (!ConvertIdToString(cx, id, name, isSymbol)) { |
445 | 0 | return false; |
446 | 0 | } |
447 | 0 | if (!isSymbol) { |
448 | 0 | nsPluginArray* self = UnwrapProxy(proxy); |
449 | 0 | auto result(StrongOrRawPtr<nsPluginElement>(self->NamedGetter(NonNullHelper(Constify(name)), found, nsContentUtils::IsSystemCaller(cx) ? CallerType::System : CallerType::NonSystem))); |
450 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
451 | 0 | (void)result; |
452 | 0 | } |
453 | 0 |
|
454 | 0 | if (found) { |
455 | 0 | *defined = true; |
456 | 0 | return opresult.failNoNamedSetter(); |
457 | 0 | } |
458 | 0 | return mozilla::dom::DOMProxyHandler::defineProperty(cx, proxy, id, desc, opresult, defined); |
459 | 0 | } |
460 | | |
461 | | |
462 | | bool |
463 | | DOMProxyHandler::ownPropNames(JSContext* cx, JS::Handle<JSObject*> proxy, unsigned flags, JS::AutoIdVector& props) const |
464 | 0 | { |
465 | 0 | bool isXray = xpc::WrapperFactory::IsXrayWrapper(proxy); |
466 | 0 |
|
467 | 0 | uint32_t length = UnwrapProxy(proxy)->Length(nsContentUtils::IsSystemCaller(cx) ? CallerType::System : CallerType::NonSystem); |
468 | 0 | MOZ_ASSERT(int32_t(length) >= 0); |
469 | 0 | for (int32_t i = 0; i < int32_t(length); ++i) { |
470 | 0 | if (!props.append(INT_TO_JSID(i))) { |
471 | 0 | return false; |
472 | 0 | } |
473 | 0 | } |
474 | 0 |
|
475 | 0 | if (flags & JSITER_HIDDEN) { |
476 | 0 | nsTArray<nsString> names; |
477 | 0 | UnwrapProxy(proxy)->GetSupportedNames(names, nsContentUtils::IsSystemCaller(cx) ? CallerType::System : CallerType::NonSystem); |
478 | 0 | if (!AppendNamedPropertyIds(cx, proxy, names, false, props)) { |
479 | 0 | return false; |
480 | 0 | } |
481 | 0 | } |
482 | 0 | |
483 | 0 | JS::Rooted<JSObject*> expando(cx); |
484 | 0 | if (!isXray && (expando = DOMProxyHandler::GetExpandoObject(proxy)) && |
485 | 0 | !js::GetPropertyKeys(cx, expando, flags, &props)) { |
486 | 0 | return false; |
487 | 0 | } |
488 | 0 | |
489 | 0 | return true; |
490 | 0 | } |
491 | | |
492 | | bool |
493 | | DOMProxyHandler::hasOwn(JSContext* cx, JS::Handle<JSObject*> proxy, JS::Handle<jsid> id, bool* bp) const |
494 | 0 | { |
495 | 0 | MOZ_ASSERT(!xpc::WrapperFactory::IsXrayWrapper(proxy), |
496 | 0 | "Should not have a XrayWrapper here"); |
497 | 0 |
|
498 | 0 | uint32_t index = GetArrayIndexFromId(cx, id); |
499 | 0 | if (IsArrayIndex(index)) { |
500 | 0 | bool found = false; |
501 | 0 | nsPluginArray* self = UnwrapProxy(proxy); |
502 | 0 | auto result(StrongOrRawPtr<nsPluginElement>(self->IndexedGetter(index, found, nsContentUtils::IsSystemCaller(cx) ? CallerType::System : CallerType::NonSystem))); |
503 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
504 | 0 | (void)result; |
505 | 0 |
|
506 | 0 | *bp = found; |
507 | 0 | return true; |
508 | 0 | } |
509 | 0 |
|
510 | 0 |
|
511 | 0 | JS::Rooted<JSObject*> expando(cx, GetExpandoObject(proxy)); |
512 | 0 | if (expando) { |
513 | 0 | bool b = true; |
514 | 0 | bool ok = JS_HasPropertyById(cx, expando, id, &b); |
515 | 0 | *bp = !!b; |
516 | 0 | if (!ok || *bp) { |
517 | 0 | return ok; |
518 | 0 | } |
519 | 0 | } |
520 | 0 | |
521 | 0 | bool hasOnProto; |
522 | 0 | if (!HasPropertyOnPrototype(cx, proxy, id, &hasOnProto)) { |
523 | 0 | return false; |
524 | 0 | } |
525 | 0 | if (!hasOnProto) { |
526 | 0 | bool found = false; |
527 | 0 | FakeString name; |
528 | 0 | bool isSymbol; |
529 | 0 | if (!ConvertIdToString(cx, id, name, isSymbol)) { |
530 | 0 | return false; |
531 | 0 | } |
532 | 0 | if (!isSymbol) { |
533 | 0 | nsPluginArray* self = UnwrapProxy(proxy); |
534 | 0 | auto result(StrongOrRawPtr<nsPluginElement>(self->NamedGetter(NonNullHelper(Constify(name)), found, nsContentUtils::IsSystemCaller(cx) ? CallerType::System : CallerType::NonSystem))); |
535 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
536 | 0 | (void)result; |
537 | 0 | } |
538 | 0 |
|
539 | 0 | *bp = found; |
540 | 0 | return true; |
541 | 0 | } |
542 | 0 | *bp = false; |
543 | 0 | return true; |
544 | 0 | } |
545 | | |
546 | | bool |
547 | | DOMProxyHandler::get(JSContext* cx, JS::Handle<JSObject*> proxy, JS::Handle<JS::Value> receiver, JS::Handle<jsid> id, JS::MutableHandle<JS::Value> vp) const |
548 | 0 | { |
549 | 0 | MOZ_ASSERT(!xpc::WrapperFactory::IsXrayWrapper(proxy), |
550 | 0 | "Should not have a XrayWrapper here"); |
551 | 0 |
|
552 | 0 | uint32_t index = GetArrayIndexFromId(cx, id); |
553 | 0 | if (IsArrayIndex(index)) { |
554 | 0 | nsPluginArray* self = UnwrapProxy(proxy); |
555 | 0 | bool found = false; |
556 | 0 | auto result(StrongOrRawPtr<nsPluginElement>(self->IndexedGetter(index, found, nsContentUtils::IsSystemCaller(cx) ? CallerType::System : CallerType::NonSystem))); |
557 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
558 | 0 |
|
559 | 0 | if (found) { |
560 | 0 | if (!result) { |
561 | 0 | vp.setNull(); |
562 | 0 | return true; |
563 | 0 | } |
564 | 0 | if (!GetOrCreateDOMReflector(cx, result, vp)) { |
565 | 0 | MOZ_ASSERT(JS_IsExceptionPending(cx)); |
566 | 0 | return false; |
567 | 0 | } |
568 | 0 | return true; |
569 | 0 | } |
570 | 0 | // Even if we don't have this index, we don't forward the |
571 | 0 | // get on to our expando object. |
572 | 0 | } else { |
573 | 0 | { // Scope for expando |
574 | 0 | JS::Rooted<JSObject*> expando(cx, DOMProxyHandler::GetExpandoObject(proxy)); |
575 | 0 | if (expando) { |
576 | 0 | bool hasProp; |
577 | 0 | if (!JS_HasPropertyById(cx, expando, id, &hasProp)) { |
578 | 0 | return false; |
579 | 0 | } |
580 | 0 | |
581 | 0 | if (hasProp) { |
582 | 0 | // Forward the get to the expando object, but our receiver is whatever our |
583 | 0 | // receiver is. |
584 | 0 | return JS_ForwardGetPropertyTo(cx, expando, id, receiver, vp); |
585 | 0 | } |
586 | 0 | } |
587 | 0 | } |
588 | 0 | } |
589 | 0 | |
590 | 0 | bool foundOnPrototype; |
591 | 0 | if (!GetPropertyOnPrototype(cx, proxy, receiver, id, &foundOnPrototype, vp)) { |
592 | 0 | return false; |
593 | 0 | } |
594 | 0 | |
595 | 0 | if (foundOnPrototype) { |
596 | 0 | return true; |
597 | 0 | } |
598 | 0 | |
599 | 0 | if (!IsArrayIndex(index)) { |
600 | 0 | FakeString name; |
601 | 0 | bool isSymbol; |
602 | 0 | if (!ConvertIdToString(cx, id, name, isSymbol)) { |
603 | 0 | return false; |
604 | 0 | } |
605 | 0 | if (!isSymbol) { |
606 | 0 | nsPluginArray* self = UnwrapProxy(proxy); |
607 | 0 | bool found = false; |
608 | 0 | auto result(StrongOrRawPtr<nsPluginElement>(self->NamedGetter(NonNullHelper(Constify(name)), found, nsContentUtils::IsSystemCaller(cx) ? CallerType::System : CallerType::NonSystem))); |
609 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
610 | 0 |
|
611 | 0 | if (found) { |
612 | 0 | if (!result) { |
613 | 0 | vp.setNull(); |
614 | 0 | return true; |
615 | 0 | } |
616 | 0 | if (!GetOrCreateDOMReflector(cx, result, vp)) { |
617 | 0 | MOZ_ASSERT(JS_IsExceptionPending(cx)); |
618 | 0 | return false; |
619 | 0 | } |
620 | 0 | return true; |
621 | 0 | } |
622 | 0 | } |
623 | 0 | } |
624 | 0 |
|
625 | 0 | vp.setUndefined(); |
626 | 0 | return true; |
627 | 0 | } |
628 | | |
629 | | const char* |
630 | | DOMProxyHandler::className(JSContext* cx, JS::Handle<JSObject*> proxy) const |
631 | 0 | { |
632 | 0 | return "PluginArray"; |
633 | 0 | } |
634 | | |
635 | | bool |
636 | | DOMProxyHandler::finalizeInBackground(const JS::Value& priv) const |
637 | 0 | { |
638 | 0 | return false; |
639 | 0 | } |
640 | | |
641 | | void |
642 | | DOMProxyHandler::finalize(JSFreeOp* fop, JSObject* proxy) const |
643 | 0 | { |
644 | 0 | nsPluginArray* self = UnwrapPossiblyNotInitializedDOMObject<nsPluginArray>(proxy); |
645 | 0 | if (self) { |
646 | 0 | ClearWrapper(self, self, proxy); |
647 | 0 | AddForDeferredFinalization<nsPluginArray>(self); |
648 | 0 | } |
649 | 0 | } |
650 | | |
651 | | const DOMProxyHandler* |
652 | | DOMProxyHandler::getInstance() |
653 | 0 | { |
654 | 0 | static const DOMProxyHandler instance; |
655 | 0 | return &instance; |
656 | 0 | } |
657 | | |
658 | | bool |
659 | | DOMProxyHandler::delete_(JSContext* cx, JS::Handle<JSObject*> proxy, JS::Handle<jsid> id, JS::ObjectOpResult& opresult) const |
660 | 0 | { |
661 | 0 | MOZ_ASSERT(!xpc::WrapperFactory::IsXrayWrapper(proxy), |
662 | 0 | "Should not have a XrayWrapper here"); |
663 | 0 |
|
664 | 0 | uint32_t index = GetArrayIndexFromId(cx, id); |
665 | 0 | if (IsArrayIndex(index)) { |
666 | 0 | bool deleteSucceeded; |
667 | 0 | bool found = false; |
668 | 0 | nsPluginArray* self = UnwrapProxy(proxy); |
669 | 0 | auto result(StrongOrRawPtr<nsPluginElement>(self->IndexedGetter(index, found, nsContentUtils::IsSystemCaller(cx) ? CallerType::System : CallerType::NonSystem))); |
670 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
671 | 0 | (void)result; |
672 | 0 | deleteSucceeded = !found; |
673 | 0 | return deleteSucceeded ? opresult.succeed() : opresult.failCantDelete(); |
674 | 0 | } |
675 | 0 | // Try named delete only if the named property visibility |
676 | 0 | // algorithm says the property is visible. |
677 | 0 | bool tryNamedDelete = true; |
678 | 0 | { // Scope for expando |
679 | 0 | JS::Rooted<JSObject*> expando(cx, DOMProxyHandler::GetExpandoObject(proxy)); |
680 | 0 | if (expando) { |
681 | 0 | bool hasProp; |
682 | 0 | if (!JS_HasPropertyById(cx, expando, id, &hasProp)) { |
683 | 0 | return false; |
684 | 0 | } |
685 | 0 | tryNamedDelete = !hasProp; |
686 | 0 | } |
687 | 0 | } |
688 | 0 | if (tryNamedDelete) { |
689 | 0 | bool hasOnProto; |
690 | 0 | if (!HasPropertyOnPrototype(cx, proxy, id, &hasOnProto)) { |
691 | 0 | return false; |
692 | 0 | } |
693 | 0 | tryNamedDelete = !hasOnProto; |
694 | 0 | } |
695 | 0 | if (tryNamedDelete) { |
696 | 0 | bool found = false; |
697 | 0 | bool deleteSucceeded; |
698 | 0 | FakeString name; |
699 | 0 | bool isSymbol; |
700 | 0 | if (!ConvertIdToString(cx, id, name, isSymbol)) { |
701 | 0 | return false; |
702 | 0 | } |
703 | 0 | if (!isSymbol) { |
704 | 0 | nsPluginArray* self = UnwrapProxy(proxy); |
705 | 0 | auto result(StrongOrRawPtr<nsPluginElement>(self->NamedGetter(NonNullHelper(Constify(name)), found, nsContentUtils::IsSystemCaller(cx) ? CallerType::System : CallerType::NonSystem))); |
706 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
707 | 0 | (void)result; |
708 | 0 | } |
709 | 0 | deleteSucceeded = !found; |
710 | 0 | if (found) { |
711 | 0 | return deleteSucceeded ? opresult.succeed() : opresult.failCantDelete(); |
712 | 0 | } |
713 | 0 | } |
714 | 0 |
|
715 | 0 | return dom::DOMProxyHandler::delete_(cx, proxy, id, opresult); |
716 | 0 | } |
717 | | |
718 | | bool |
719 | | DOMProxyHandler::getElements(JSContext* cx, JS::Handle<JSObject*> proxy, uint32_t begin, uint32_t end, js::ElementAdder* adder) const |
720 | 0 | { |
721 | 0 | JS::Rooted<JS::Value> temp(cx); |
722 | 0 | MOZ_ASSERT(!xpc::WrapperFactory::IsXrayWrapper(proxy), |
723 | 0 | "Should not have a XrayWrapper here"); |
724 | 0 |
|
725 | 0 | nsPluginArray* self = UnwrapProxy(proxy); |
726 | 0 | uint32_t length = self->Length(nsContentUtils::IsSystemCaller(cx) ? CallerType::System : CallerType::NonSystem); |
727 | 0 | // Compute the end of the indices we'll get ourselves |
728 | 0 | uint32_t ourEnd = std::max(begin, std::min(end, length)); |
729 | 0 |
|
730 | 0 | for (uint32_t index = begin; index < ourEnd; ++index) { |
731 | 0 | bool found = false; |
732 | 0 | auto result(StrongOrRawPtr<nsPluginElement>(self->IndexedGetter(index, found, nsContentUtils::IsSystemCaller(cx) ? CallerType::System : CallerType::NonSystem))); |
733 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
734 | 0 |
|
735 | 0 | MOZ_ASSERT(found); |
736 | 0 | if (!result) { |
737 | 0 | temp.setNull(); |
738 | 0 | if (!adder->append(cx, temp)) return false; |
739 | 0 | continue; |
740 | 0 | } |
741 | 0 | if (!GetOrCreateDOMReflector(cx, result, &temp)) { |
742 | 0 | MOZ_ASSERT(JS_IsExceptionPending(cx)); |
743 | 0 | return false; |
744 | 0 | } |
745 | 0 | if (!adder->append(cx, temp)) return false; |
746 | 0 | continue; |
747 | 0 | } |
748 | 0 |
|
749 | 0 | if (end > ourEnd) { |
750 | 0 | JS::Rooted<JSObject*> proto(cx); |
751 | 0 | if (!js::GetObjectProto(cx, proxy, &proto)) { |
752 | 0 | return false; |
753 | 0 | } |
754 | 0 | return js::GetElementsWithAdder(cx, proto, proxy, ourEnd, end, adder); |
755 | 0 | } |
756 | 0 | |
757 | 0 | return true; |
758 | 0 | } |
759 | | |
760 | | size_t |
761 | | DOMProxyHandler::objectMoved(JSObject* obj, JSObject* old) const |
762 | 0 | { |
763 | 0 | nsPluginArray* self = UnwrapPossiblyNotInitializedDOMObject<nsPluginArray>(obj); |
764 | 0 | if (self) { |
765 | 0 | UpdateWrapper(self, self, obj, old); |
766 | 0 | } |
767 | 0 |
|
768 | 0 | return 0; |
769 | 0 | } |
770 | | |
771 | | static const DOMJSClass sClass = { |
772 | | PROXY_CLASS_DEF("PluginArray", |
773 | | JSCLASS_IS_DOMJSCLASS | JSCLASS_HAS_RESERVED_SLOTS(1)), |
774 | | { prototypes::id::PluginArray, 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 }, |
775 | | IsBaseOf<nsISupports, nsPluginArray >::value, |
776 | | sNativePropertyHooks, |
777 | | FindAssociatedGlobalForNative<nsPluginArray>::Get, |
778 | | GetProtoObjectHandle, |
779 | | GetCCParticipant<nsPluginArray>::Get() |
780 | | }; |
781 | | |
782 | | bool |
783 | | Wrap(JSContext* aCx, nsPluginArray* aObject, nsWrapperCache* aCache, JS::Handle<JSObject*> aGivenProto, JS::MutableHandle<JSObject*> aReflector) |
784 | 0 | { |
785 | 0 | static_assert(!IsBaseOf<NonRefcountedDOMObject, nsPluginArray>::value, |
786 | 0 | "Shouldn't have wrappercached things that are not refcounted."); |
787 | 0 | MOZ_ASSERT(static_cast<nsPluginArray*>(aObject) == |
788 | 0 | reinterpret_cast<nsPluginArray*>(aObject), |
789 | 0 | "Multiple inheritance for nsPluginArray is broken."); |
790 | 0 | MOZ_ASSERT(ToSupportsIsCorrect(aObject)); |
791 | 0 | MOZ_ASSERT_IF(aGivenProto, js::IsObjectInContextCompartment(aGivenProto, aCx)); |
792 | 0 | MOZ_ASSERT(!aCache->GetWrapper(), |
793 | 0 | "You should probably not be using Wrap() directly; use " |
794 | 0 | "GetOrCreateDOMReflector instead"); |
795 | 0 |
|
796 | 0 | MOZ_ASSERT(ToSupportsIsOnPrimaryInheritanceChain(aObject, aCache), |
797 | 0 | "nsISupports must be on our primary inheritance chain"); |
798 | 0 |
|
799 | 0 | JS::Rooted<JSObject*> global(aCx, FindAssociatedGlobal(aCx, aObject->GetParentObject())); |
800 | 0 | if (!global) { |
801 | 0 | return false; |
802 | 0 | } |
803 | 0 | MOZ_ASSERT(JS_IsGlobalObject(global)); |
804 | 0 | MOZ_ASSERT(JS::ObjectIsNotGray(global)); |
805 | 0 |
|
806 | 0 | // That might have ended up wrapping us already, due to the wonders |
807 | 0 | // of XBL. Check for that, and bail out as needed. |
808 | 0 | aReflector.set(aCache->GetWrapper()); |
809 | 0 | if (aReflector) { |
810 | | #ifdef DEBUG |
811 | | AssertReflectorHasGivenProto(aCx, aReflector, aGivenProto); |
812 | | #endif // DEBUG |
813 | | return true; |
814 | 0 | } |
815 | 0 |
|
816 | 0 | JSAutoRealm ar(aCx, global); |
817 | 0 | JS::Handle<JSObject*> canonicalProto = GetProtoObjectHandle(aCx); |
818 | 0 | if (!canonicalProto) { |
819 | 0 | return false; |
820 | 0 | } |
821 | 0 | JS::Rooted<JSObject*> proto(aCx); |
822 | 0 | if (aGivenProto) { |
823 | 0 | proto = aGivenProto; |
824 | 0 | // Unfortunately, while aGivenProto was in the compartment of aCx |
825 | 0 | // coming in, we changed compartments to that of "parent" so may need |
826 | 0 | // to wrap the proto here. |
827 | 0 | if (js::GetContextCompartment(aCx) != js::GetObjectCompartment(proto)) { |
828 | 0 | if (!JS_WrapObject(aCx, &proto)) { |
829 | 0 | return false; |
830 | 0 | } |
831 | 0 | } |
832 | 0 | } else { |
833 | 0 | proto = canonicalProto; |
834 | 0 | } |
835 | 0 |
|
836 | 0 | BindingJSObjectCreator<nsPluginArray> creator(aCx); |
837 | 0 | creator.CreateProxyObject(aCx, &sClass.mBase, DOMProxyHandler::getInstance(), |
838 | 0 | proto, aObject, JS::UndefinedHandleValue, aReflector); |
839 | 0 | if (!aReflector) { |
840 | 0 | return false; |
841 | 0 | } |
842 | 0 | |
843 | 0 | aCache->SetWrapper(aReflector); |
844 | 0 | creator.InitializationSucceeded(); |
845 | 0 |
|
846 | 0 | MOZ_ASSERT(aCache->GetWrapperPreserveColor() && |
847 | 0 | aCache->GetWrapperPreserveColor() == aReflector); |
848 | 0 | // If proto != canonicalProto, we have to preserve our wrapper; |
849 | 0 | // otherwise we won't be able to properly recreate it later, since |
850 | 0 | // we won't know what proto to use. Note that we don't check |
851 | 0 | // aGivenProto here, since it's entirely possible (and even |
852 | 0 | // somewhat common) to have a non-null aGivenProto which is the |
853 | 0 | // same as canonicalProto. |
854 | 0 | if (proto != canonicalProto) { |
855 | 0 | PreserveWrapper(aObject); |
856 | 0 | } |
857 | 0 |
|
858 | 0 | return true; |
859 | 0 | } |
860 | | |
861 | | static bool |
862 | | ResolveOwnProperty(JSContext* cx, JS::Handle<JSObject*> wrapper, JS::Handle<JSObject*> obj, JS::Handle<jsid> id, JS::MutableHandle<JS::PropertyDescriptor> desc) |
863 | 0 | { |
864 | 0 | return js::GetProxyHandler(obj)->getOwnPropertyDescriptor(cx, wrapper, id, desc); |
865 | 0 | } |
866 | | |
867 | | static bool |
868 | | EnumerateOwnProperties(JSContext* cx, JS::Handle<JSObject*> wrapper, JS::Handle<JSObject*> obj, JS::AutoIdVector& props) |
869 | 0 | { |
870 | 0 | return js::GetProxyHandler(obj)->ownPropertyKeys(cx, wrapper, props); |
871 | 0 | } |
872 | | |
873 | | const NativePropertyHooks sNativePropertyHooks[] = { { |
874 | | ResolveOwnProperty, |
875 | | EnumerateOwnProperties, |
876 | | nullptr, |
877 | | { sNativeProperties.Upcast(), nullptr }, |
878 | | prototypes::id::PluginArray, |
879 | | constructors::id::PluginArray, |
880 | | nullptr, |
881 | | &DefaultXrayExpandoObjectClass |
882 | | } }; |
883 | | |
884 | | void |
885 | | CreateInterfaceObjects(JSContext* aCx, JS::Handle<JSObject*> aGlobal, ProtoAndIfaceCache& aProtoAndIfaceCache, bool aDefineOnGlobal) |
886 | 0 | { |
887 | 0 | JS::Rooted<JSObject*> parentProto(aCx, JS::GetRealmObjectPrototype(aCx)); |
888 | 0 | if (!parentProto) { |
889 | 0 | return; |
890 | 0 | } |
891 | 0 | |
892 | 0 | JS::Rooted<JSObject*> constructorProto(aCx, JS::GetRealmFunctionPrototype(aCx)); |
893 | 0 | if (!constructorProto) { |
894 | 0 | return; |
895 | 0 | } |
896 | 0 | |
897 | 0 | static bool sIdsInited = false; |
898 | 0 | if (!sIdsInited && NS_IsMainThread()) { |
899 | 0 | if (!InitIds(aCx, sNativeProperties.Upcast())) { |
900 | 0 | return; |
901 | 0 | } |
902 | 0 | sIdsInited = true; |
903 | 0 | } |
904 | 0 |
|
905 | 0 | JS::Heap<JSObject*>* protoCache = &aProtoAndIfaceCache.EntrySlotOrCreate(prototypes::id::PluginArray); |
906 | 0 | JS::Heap<JSObject*>* interfaceCache = &aProtoAndIfaceCache.EntrySlotOrCreate(constructors::id::PluginArray); |
907 | 0 | dom::CreateInterfaceObjects(aCx, aGlobal, parentProto, |
908 | 0 | &sPrototypeClass.mBase, protoCache, |
909 | 0 | nullptr, |
910 | 0 | constructorProto, &sInterfaceObjectClass.mBase, 0, nullptr, |
911 | 0 | interfaceCache, |
912 | 0 | sNativeProperties.Upcast(), |
913 | 0 | nullptr, |
914 | 0 | "PluginArray", aDefineOnGlobal, |
915 | 0 | nullptr, |
916 | 0 | false); |
917 | 0 | } |
918 | | |
919 | | JSObject* |
920 | | GetConstructorObject(JSContext* aCx) |
921 | 0 | { |
922 | 0 | return GetConstructorObjectHandle(aCx); |
923 | 0 | } |
924 | | |
925 | | } // namespace PluginArray_Binding |
926 | | |
927 | | |
928 | | |
929 | | } // namespace dom |
930 | | } // namespace mozilla |