/work/obj-fuzz/dom/bindings/WebComponentsBinding.cpp
Line | Count | Source (jump to first uncovered line) |
1 | | /* THIS FILE IS AUTOGENERATED FROM WebComponents.webidl BY Codegen.py - DO NOT EDIT */ |
2 | | |
3 | | #include "AtomList.h" |
4 | | #include "WebComponentsBinding.h" |
5 | | #include "mozilla/OwningNonNull.h" |
6 | | #include "mozilla/dom/BindingUtils.h" |
7 | | #include "mozilla/dom/NonRefcountedDOMObject.h" |
8 | | #include "mozilla/dom/Nullable.h" |
9 | | #include "mozilla/dom/ScriptSettings.h" |
10 | | #include "nsContentUtils.h" |
11 | | #include "nsIDocument.h" |
12 | | #include "xpcjsid.h" |
13 | | |
14 | | namespace mozilla { |
15 | | namespace dom { |
16 | | |
17 | | namespace binding_detail {}; // Just to make sure it's known as a namespace |
18 | | using namespace mozilla::dom::binding_detail; |
19 | | |
20 | | |
21 | | |
22 | | LifecycleCallbacks::LifecycleCallbacks() |
23 | 0 | { |
24 | 0 | // Safe to pass a null context if we pass a null value |
25 | 0 | Init(nullptr, JS::NullHandleValue); |
26 | 0 | } |
27 | | |
28 | | |
29 | | bool |
30 | | LifecycleCallbacks::InitIds(JSContext* cx, LifecycleCallbacksAtoms* atomsCache) |
31 | 0 | { |
32 | 0 | MOZ_ASSERT(!*reinterpret_cast<jsid**>(atomsCache)); |
33 | 0 |
|
34 | 0 | // Initialize these in reverse order so that any failure leaves the first one |
35 | 0 | // uninitialized. |
36 | 0 | if (!atomsCache->getCustomInterfaceCallback_id.init(cx, "getCustomInterfaceCallback") || |
37 | 0 | !atomsCache->disconnectedCallback_id.init(cx, "disconnectedCallback") || |
38 | 0 | !atomsCache->connectedCallback_id.init(cx, "connectedCallback") || |
39 | 0 | !atomsCache->attributeChangedCallback_id.init(cx, "attributeChangedCallback") || |
40 | 0 | !atomsCache->adoptedCallback_id.init(cx, "adoptedCallback")) { |
41 | 0 | return false; |
42 | 0 | } |
43 | 0 | return true; |
44 | 0 | } |
45 | | |
46 | | bool |
47 | | LifecycleCallbacks::Init(JSContext* cx, JS::Handle<JS::Value> val, const char* sourceDescription, bool passedToJSImpl) |
48 | 0 | { |
49 | 0 | // Passing a null JSContext is OK only if we're initing from null, |
50 | 0 | // Since in that case we will not have to do any property gets |
51 | 0 | // Also evaluate isNullOrUndefined in order to avoid false-positive |
52 | 0 | // checkers by static analysis tools |
53 | 0 | MOZ_ASSERT_IF(!cx, val.isNull() && val.isNullOrUndefined()); |
54 | 0 | LifecycleCallbacksAtoms* atomsCache = nullptr; |
55 | 0 | if (cx) { |
56 | 0 | atomsCache = GetAtomCache<LifecycleCallbacksAtoms>(cx); |
57 | 0 | if (!*reinterpret_cast<jsid**>(atomsCache) && !InitIds(cx, atomsCache)) { |
58 | 0 | return false; |
59 | 0 | } |
60 | 0 | } |
61 | 0 | |
62 | 0 | if (!IsConvertibleToDictionary(val)) { |
63 | 0 | return ThrowErrorMessage(cx, MSG_NOT_DICTIONARY, sourceDescription); |
64 | 0 | } |
65 | 0 | |
66 | 0 | bool isNull = val.isNullOrUndefined(); |
67 | 0 | // We only need these if !isNull, in which case we have |cx|. |
68 | 0 | Maybe<JS::Rooted<JSObject *> > object; |
69 | 0 | Maybe<JS::Rooted<JS::Value> > temp; |
70 | 0 | if (!isNull) { |
71 | 0 | MOZ_ASSERT(cx); |
72 | 0 | object.emplace(cx, &val.toObject()); |
73 | 0 | temp.emplace(cx); |
74 | 0 | } |
75 | 0 | if (!isNull) { |
76 | 0 | if (!JS_GetPropertyById(cx, *object, atomsCache->adoptedCallback_id, temp.ptr())) { |
77 | 0 | return false; |
78 | 0 | } |
79 | 0 | } |
80 | 0 | if (!isNull && !temp->isUndefined()) { |
81 | 0 | mAdoptedCallback.Construct(); |
82 | 0 | if (temp.ref().isObject()) { |
83 | 0 | if (JS::IsCallable(&temp.ref().toObject())) { |
84 | 0 | { // scope for tempRoot and tempGlobalRoot if needed |
85 | 0 | JS::Rooted<JSObject*> tempRoot(cx, &temp.ref().toObject()); |
86 | 0 | JS::Rooted<JSObject*> tempGlobalRoot(cx, JS::CurrentGlobalOrNull(cx)); |
87 | 0 | (mAdoptedCallback.Value()) = new LifecycleAdoptedCallback(cx, tempRoot, tempGlobalRoot, GetIncumbentGlobal()); |
88 | 0 | } |
89 | 0 | } else { |
90 | 0 | ThrowErrorMessage(cx, MSG_NOT_CALLABLE, "'adoptedCallback' member of LifecycleCallbacks"); |
91 | 0 | return false; |
92 | 0 | } |
93 | 0 | } else { |
94 | 0 | ThrowErrorMessage(cx, MSG_NOT_OBJECT, "'adoptedCallback' member of LifecycleCallbacks"); |
95 | 0 | return false; |
96 | 0 | } |
97 | 0 | mIsAnyMemberPresent = true; |
98 | 0 | } |
99 | 0 |
|
100 | 0 | if (!isNull) { |
101 | 0 | if (!JS_GetPropertyById(cx, *object, atomsCache->attributeChangedCallback_id, temp.ptr())) { |
102 | 0 | return false; |
103 | 0 | } |
104 | 0 | } |
105 | 0 | if (!isNull && !temp->isUndefined()) { |
106 | 0 | mAttributeChangedCallback.Construct(); |
107 | 0 | if (temp.ref().isObject()) { |
108 | 0 | if (JS::IsCallable(&temp.ref().toObject())) { |
109 | 0 | { // scope for tempRoot and tempGlobalRoot if needed |
110 | 0 | JS::Rooted<JSObject*> tempRoot(cx, &temp.ref().toObject()); |
111 | 0 | JS::Rooted<JSObject*> tempGlobalRoot(cx, JS::CurrentGlobalOrNull(cx)); |
112 | 0 | (mAttributeChangedCallback.Value()) = new LifecycleAttributeChangedCallback(cx, tempRoot, tempGlobalRoot, GetIncumbentGlobal()); |
113 | 0 | } |
114 | 0 | } else { |
115 | 0 | ThrowErrorMessage(cx, MSG_NOT_CALLABLE, "'attributeChangedCallback' member of LifecycleCallbacks"); |
116 | 0 | return false; |
117 | 0 | } |
118 | 0 | } else { |
119 | 0 | ThrowErrorMessage(cx, MSG_NOT_OBJECT, "'attributeChangedCallback' member of LifecycleCallbacks"); |
120 | 0 | return false; |
121 | 0 | } |
122 | 0 | mIsAnyMemberPresent = true; |
123 | 0 | } |
124 | 0 |
|
125 | 0 | if (!isNull) { |
126 | 0 | if (!JS_GetPropertyById(cx, *object, atomsCache->connectedCallback_id, temp.ptr())) { |
127 | 0 | return false; |
128 | 0 | } |
129 | 0 | } |
130 | 0 | if (!isNull && !temp->isUndefined()) { |
131 | 0 | mConnectedCallback.Construct(); |
132 | 0 | if (temp.ref().isObject()) { |
133 | 0 | if (JS::IsCallable(&temp.ref().toObject())) { |
134 | 0 | { // scope for tempRoot and tempGlobalRoot if needed |
135 | 0 | JS::Rooted<JSObject*> tempRoot(cx, &temp.ref().toObject()); |
136 | 0 | JS::Rooted<JSObject*> tempGlobalRoot(cx, JS::CurrentGlobalOrNull(cx)); |
137 | 0 | (mConnectedCallback.Value()) = new LifecycleConnectedCallback(cx, tempRoot, tempGlobalRoot, GetIncumbentGlobal()); |
138 | 0 | } |
139 | 0 | } else { |
140 | 0 | ThrowErrorMessage(cx, MSG_NOT_CALLABLE, "'connectedCallback' member of LifecycleCallbacks"); |
141 | 0 | return false; |
142 | 0 | } |
143 | 0 | } else { |
144 | 0 | ThrowErrorMessage(cx, MSG_NOT_OBJECT, "'connectedCallback' member of LifecycleCallbacks"); |
145 | 0 | return false; |
146 | 0 | } |
147 | 0 | mIsAnyMemberPresent = true; |
148 | 0 | } |
149 | 0 |
|
150 | 0 | if (!isNull) { |
151 | 0 | if (!JS_GetPropertyById(cx, *object, atomsCache->disconnectedCallback_id, temp.ptr())) { |
152 | 0 | return false; |
153 | 0 | } |
154 | 0 | } |
155 | 0 | if (!isNull && !temp->isUndefined()) { |
156 | 0 | mDisconnectedCallback.Construct(); |
157 | 0 | if (temp.ref().isObject()) { |
158 | 0 | if (JS::IsCallable(&temp.ref().toObject())) { |
159 | 0 | { // scope for tempRoot and tempGlobalRoot if needed |
160 | 0 | JS::Rooted<JSObject*> tempRoot(cx, &temp.ref().toObject()); |
161 | 0 | JS::Rooted<JSObject*> tempGlobalRoot(cx, JS::CurrentGlobalOrNull(cx)); |
162 | 0 | (mDisconnectedCallback.Value()) = new LifecycleDisconnectedCallback(cx, tempRoot, tempGlobalRoot, GetIncumbentGlobal()); |
163 | 0 | } |
164 | 0 | } else { |
165 | 0 | ThrowErrorMessage(cx, MSG_NOT_CALLABLE, "'disconnectedCallback' member of LifecycleCallbacks"); |
166 | 0 | return false; |
167 | 0 | } |
168 | 0 | } else { |
169 | 0 | ThrowErrorMessage(cx, MSG_NOT_OBJECT, "'disconnectedCallback' member of LifecycleCallbacks"); |
170 | 0 | return false; |
171 | 0 | } |
172 | 0 | mIsAnyMemberPresent = true; |
173 | 0 | } |
174 | 0 |
|
175 | 0 | if (!isNull) { |
176 | 0 | if (nsContentUtils::ThreadsafeIsSystemCaller(cx)) { |
177 | 0 | if (!JS_GetPropertyById(cx, *object, atomsCache->getCustomInterfaceCallback_id, temp.ptr())) { |
178 | 0 | return false; |
179 | 0 | } |
180 | 0 | } else { |
181 | 0 | temp->setUndefined(); |
182 | 0 | } |
183 | 0 | } |
184 | 0 | if (!isNull && !temp->isUndefined()) { |
185 | 0 | mGetCustomInterfaceCallback.Construct(); |
186 | 0 | if (temp.ref().isObject()) { |
187 | 0 | if (JS::IsCallable(&temp.ref().toObject())) { |
188 | 0 | { // scope for tempRoot and tempGlobalRoot if needed |
189 | 0 | JS::Rooted<JSObject*> tempRoot(cx, &temp.ref().toObject()); |
190 | 0 | JS::Rooted<JSObject*> tempGlobalRoot(cx, JS::CurrentGlobalOrNull(cx)); |
191 | 0 | (mGetCustomInterfaceCallback.Value()) = new LifecycleGetCustomInterfaceCallback(cx, tempRoot, tempGlobalRoot, GetIncumbentGlobal()); |
192 | 0 | } |
193 | 0 | } else { |
194 | 0 | ThrowErrorMessage(cx, MSG_NOT_CALLABLE, "'getCustomInterfaceCallback' member of LifecycleCallbacks"); |
195 | 0 | return false; |
196 | 0 | } |
197 | 0 | } else { |
198 | 0 | ThrowErrorMessage(cx, MSG_NOT_OBJECT, "'getCustomInterfaceCallback' member of LifecycleCallbacks"); |
199 | 0 | return false; |
200 | 0 | } |
201 | 0 | mIsAnyMemberPresent = true; |
202 | 0 | } |
203 | 0 | return true; |
204 | 0 | } |
205 | | |
206 | | bool |
207 | | LifecycleCallbacks::ToObjectInternal(JSContext* cx, JS::MutableHandle<JS::Value> rval) const |
208 | 0 | { |
209 | 0 | LifecycleCallbacksAtoms* atomsCache = GetAtomCache<LifecycleCallbacksAtoms>(cx); |
210 | 0 | if (!*reinterpret_cast<jsid**>(atomsCache) && !InitIds(cx, atomsCache)) { |
211 | 0 | return false; |
212 | 0 | } |
213 | 0 | |
214 | 0 | JS::Rooted<JSObject*> obj(cx, JS_NewPlainObject(cx)); |
215 | 0 | if (!obj) { |
216 | 0 | return false; |
217 | 0 | } |
218 | 0 | rval.set(JS::ObjectValue(*obj)); |
219 | 0 |
|
220 | 0 | if (mAdoptedCallback.WasPassed()) { |
221 | 0 | do { |
222 | 0 | // block for our 'break' successCode and scope for 'temp' and 'currentValue' |
223 | 0 | JS::Rooted<JS::Value> temp(cx); |
224 | 0 | OwningNonNull<LifecycleAdoptedCallback> const & currentValue = mAdoptedCallback.InternalValue(); |
225 | 0 | temp.setObjectOrNull(GetCallbackFromCallbackObject(cx, currentValue)); |
226 | 0 | if (!MaybeWrapObjectValue(cx, &temp)) { |
227 | 0 | return false; |
228 | 0 | } |
229 | 0 | if (!JS_DefinePropertyById(cx, obj, atomsCache->adoptedCallback_id, temp, JSPROP_ENUMERATE)) { |
230 | 0 | return false; |
231 | 0 | } |
232 | 0 | break; |
233 | 0 | } while(false); |
234 | 0 | } |
235 | 0 |
|
236 | 0 | if (mAttributeChangedCallback.WasPassed()) { |
237 | 0 | do { |
238 | 0 | // block for our 'break' successCode and scope for 'temp' and 'currentValue' |
239 | 0 | JS::Rooted<JS::Value> temp(cx); |
240 | 0 | OwningNonNull<LifecycleAttributeChangedCallback> const & currentValue = mAttributeChangedCallback.InternalValue(); |
241 | 0 | temp.setObjectOrNull(GetCallbackFromCallbackObject(cx, currentValue)); |
242 | 0 | if (!MaybeWrapObjectValue(cx, &temp)) { |
243 | 0 | return false; |
244 | 0 | } |
245 | 0 | if (!JS_DefinePropertyById(cx, obj, atomsCache->attributeChangedCallback_id, temp, JSPROP_ENUMERATE)) { |
246 | 0 | return false; |
247 | 0 | } |
248 | 0 | break; |
249 | 0 | } while(false); |
250 | 0 | } |
251 | 0 |
|
252 | 0 | if (mConnectedCallback.WasPassed()) { |
253 | 0 | do { |
254 | 0 | // block for our 'break' successCode and scope for 'temp' and 'currentValue' |
255 | 0 | JS::Rooted<JS::Value> temp(cx); |
256 | 0 | OwningNonNull<LifecycleConnectedCallback> const & currentValue = mConnectedCallback.InternalValue(); |
257 | 0 | temp.setObjectOrNull(GetCallbackFromCallbackObject(cx, currentValue)); |
258 | 0 | if (!MaybeWrapObjectValue(cx, &temp)) { |
259 | 0 | return false; |
260 | 0 | } |
261 | 0 | if (!JS_DefinePropertyById(cx, obj, atomsCache->connectedCallback_id, temp, JSPROP_ENUMERATE)) { |
262 | 0 | return false; |
263 | 0 | } |
264 | 0 | break; |
265 | 0 | } while(false); |
266 | 0 | } |
267 | 0 |
|
268 | 0 | if (mDisconnectedCallback.WasPassed()) { |
269 | 0 | do { |
270 | 0 | // block for our 'break' successCode and scope for 'temp' and 'currentValue' |
271 | 0 | JS::Rooted<JS::Value> temp(cx); |
272 | 0 | OwningNonNull<LifecycleDisconnectedCallback> const & currentValue = mDisconnectedCallback.InternalValue(); |
273 | 0 | temp.setObjectOrNull(GetCallbackFromCallbackObject(cx, currentValue)); |
274 | 0 | if (!MaybeWrapObjectValue(cx, &temp)) { |
275 | 0 | return false; |
276 | 0 | } |
277 | 0 | if (!JS_DefinePropertyById(cx, obj, atomsCache->disconnectedCallback_id, temp, JSPROP_ENUMERATE)) { |
278 | 0 | return false; |
279 | 0 | } |
280 | 0 | break; |
281 | 0 | } while(false); |
282 | 0 | } |
283 | 0 |
|
284 | 0 | if (nsContentUtils::ThreadsafeIsSystemCaller(cx)) { |
285 | 0 | if (mGetCustomInterfaceCallback.WasPassed()) { |
286 | 0 | do { |
287 | 0 | // block for our 'break' successCode and scope for 'temp' and 'currentValue' |
288 | 0 | JS::Rooted<JS::Value> temp(cx); |
289 | 0 | OwningNonNull<LifecycleGetCustomInterfaceCallback> const & currentValue = mGetCustomInterfaceCallback.InternalValue(); |
290 | 0 | temp.setObjectOrNull(GetCallbackFromCallbackObject(cx, currentValue)); |
291 | 0 | if (!MaybeWrapObjectValue(cx, &temp)) { |
292 | 0 | return false; |
293 | 0 | } |
294 | 0 | if (!JS_DefinePropertyById(cx, obj, atomsCache->getCustomInterfaceCallback_id, temp, JSPROP_ENUMERATE)) { |
295 | 0 | return false; |
296 | 0 | } |
297 | 0 | break; |
298 | 0 | } while(false); |
299 | 0 | } |
300 | 0 | } |
301 | 0 |
|
302 | 0 | return true; |
303 | 0 | } |
304 | | |
305 | | void |
306 | | LifecycleCallbacks::TraceDictionary(JSTracer* trc) |
307 | 0 | { |
308 | 0 | } |
309 | | |
310 | | |
311 | | |
312 | | namespace binding_detail { |
313 | | } // namespace binding_detail |
314 | | |
315 | | |
316 | | void |
317 | | LifecycleConnectedCallback::Call(JSContext* cx, JS::Handle<JS::Value> aThisVal, ErrorResult& aRv) |
318 | 0 | { |
319 | 0 | JS::Rooted<JS::Value> rval(cx, JS::UndefinedValue()); |
320 | 0 |
|
321 | 0 | JS::Rooted<JS::Value> callable(cx, JS::ObjectValue(*mCallback)); |
322 | 0 | if (!JS::Call(cx, aThisVal, callable, |
323 | 0 | JS::HandleValueArray::empty(), &rval)) { |
324 | 0 | aRv.NoteJSContextException(cx); |
325 | 0 | return; |
326 | 0 | } |
327 | 0 | } |
328 | | |
329 | | |
330 | | |
331 | | void |
332 | | LifecycleDisconnectedCallback::Call(JSContext* cx, JS::Handle<JS::Value> aThisVal, ErrorResult& aRv) |
333 | 0 | { |
334 | 0 | JS::Rooted<JS::Value> rval(cx, JS::UndefinedValue()); |
335 | 0 |
|
336 | 0 | JS::Rooted<JS::Value> callable(cx, JS::ObjectValue(*mCallback)); |
337 | 0 | if (!JS::Call(cx, aThisVal, callable, |
338 | 0 | JS::HandleValueArray::empty(), &rval)) { |
339 | 0 | aRv.NoteJSContextException(cx); |
340 | 0 | return; |
341 | 0 | } |
342 | 0 | } |
343 | | |
344 | | |
345 | | |
346 | | void |
347 | | LifecycleAdoptedCallback::Call(JSContext* cx, JS::Handle<JS::Value> aThisVal, nsIDocument* oldDocument, nsIDocument* newDocment, ErrorResult& aRv) |
348 | 0 | { |
349 | 0 | JS::Rooted<JS::Value> rval(cx, JS::UndefinedValue()); |
350 | 0 | JS::AutoValueVector argv(cx); |
351 | 0 | if (!argv.resize(2)) { |
352 | 0 | aRv.Throw(NS_ERROR_OUT_OF_MEMORY); |
353 | 0 | return; |
354 | 0 | } |
355 | 0 | unsigned argc = 2; |
356 | 0 |
|
357 | 0 | do { |
358 | 0 | if (!newDocment) { |
359 | 0 | argv[1].setNull(); |
360 | 0 | break; |
361 | 0 | } |
362 | 0 | if (!GetOrCreateDOMReflector(cx, newDocment, argv[1])) { |
363 | 0 | MOZ_CRASH("Looks like bug 1488480/1405521, with getting the reflector failing"); |
364 | 0 | MOZ_ASSERT(JS_IsExceptionPending(cx)); |
365 | 0 | aRv.Throw(NS_ERROR_UNEXPECTED); |
366 | 0 | return; |
367 | 0 | } |
368 | 0 | break; |
369 | 0 | } while (false); |
370 | 0 |
|
371 | 0 | do { |
372 | 0 | if (!oldDocument) { |
373 | 0 | argv[0].setNull(); |
374 | 0 | break; |
375 | 0 | } |
376 | 0 | if (!GetOrCreateDOMReflector(cx, oldDocument, argv[0])) { |
377 | 0 | MOZ_CRASH("Looks like bug 1488480/1405521, with getting the reflector failing"); |
378 | 0 | MOZ_ASSERT(JS_IsExceptionPending(cx)); |
379 | 0 | aRv.Throw(NS_ERROR_UNEXPECTED); |
380 | 0 | return; |
381 | 0 | } |
382 | 0 | break; |
383 | 0 | } while (false); |
384 | 0 |
|
385 | 0 | JS::Rooted<JS::Value> callable(cx, JS::ObjectValue(*mCallback)); |
386 | 0 | if (!JS::Call(cx, aThisVal, callable, |
387 | 0 | JS::HandleValueArray::subarray(argv, 0, argc), &rval)) { |
388 | 0 | aRv.NoteJSContextException(cx); |
389 | 0 | return; |
390 | 0 | } |
391 | 0 | } |
392 | | |
393 | | |
394 | | |
395 | | void |
396 | | LifecycleAttributeChangedCallback::Call(JSContext* cx, JS::Handle<JS::Value> aThisVal, const nsAString& attrName, const nsAString& oldValue, const nsAString& newValue, const nsAString& namespaceURI, ErrorResult& aRv) |
397 | 0 | { |
398 | 0 | JS::Rooted<JS::Value> rval(cx, JS::UndefinedValue()); |
399 | 0 | JS::AutoValueVector argv(cx); |
400 | 0 | if (!argv.resize(4)) { |
401 | 0 | aRv.Throw(NS_ERROR_OUT_OF_MEMORY); |
402 | 0 | return; |
403 | 0 | } |
404 | 0 | unsigned argc = 4; |
405 | 0 |
|
406 | 0 | do { |
407 | 0 | nsString mutableStr(namespaceURI); |
408 | 0 | if (!xpc::StringToJsval(cx, mutableStr, argv[3])) { |
409 | 0 | aRv.Throw(NS_ERROR_UNEXPECTED); |
410 | 0 | return; |
411 | 0 | } |
412 | 0 | break; |
413 | 0 | } while (false); |
414 | 0 |
|
415 | 0 | do { |
416 | 0 | nsString mutableStr(newValue); |
417 | 0 | if (!xpc::StringToJsval(cx, mutableStr, argv[2])) { |
418 | 0 | aRv.Throw(NS_ERROR_UNEXPECTED); |
419 | 0 | return; |
420 | 0 | } |
421 | 0 | break; |
422 | 0 | } while (false); |
423 | 0 |
|
424 | 0 | do { |
425 | 0 | nsString mutableStr(oldValue); |
426 | 0 | if (!xpc::StringToJsval(cx, mutableStr, argv[1])) { |
427 | 0 | aRv.Throw(NS_ERROR_UNEXPECTED); |
428 | 0 | return; |
429 | 0 | } |
430 | 0 | break; |
431 | 0 | } while (false); |
432 | 0 |
|
433 | 0 | do { |
434 | 0 | nsString mutableStr(attrName); |
435 | 0 | if (!xpc::NonVoidStringToJsval(cx, mutableStr, argv[0])) { |
436 | 0 | aRv.Throw(NS_ERROR_UNEXPECTED); |
437 | 0 | return; |
438 | 0 | } |
439 | 0 | break; |
440 | 0 | } while (false); |
441 | 0 |
|
442 | 0 | JS::Rooted<JS::Value> callable(cx, JS::ObjectValue(*mCallback)); |
443 | 0 | if (!JS::Call(cx, aThisVal, callable, |
444 | 0 | JS::HandleValueArray::subarray(argv, 0, argc), &rval)) { |
445 | 0 | aRv.NoteJSContextException(cx); |
446 | 0 | return; |
447 | 0 | } |
448 | 0 | } |
449 | | |
450 | | |
451 | | |
452 | | void |
453 | | LifecycleGetCustomInterfaceCallback::Call(JSContext* cx, JS::Handle<JS::Value> aThisVal, nsIJSID* iid, JS::MutableHandle<JSObject*> aRetVal, ErrorResult& aRv) |
454 | 0 | { |
455 | 0 | JS::Rooted<JS::Value> rval(cx, JS::UndefinedValue()); |
456 | 0 | JS::AutoValueVector argv(cx); |
457 | 0 | if (!argv.resize(1)) { |
458 | 0 | aRv.Throw(NS_ERROR_OUT_OF_MEMORY); |
459 | 0 | return; |
460 | 0 | } |
461 | 0 | unsigned argc = 1; |
462 | 0 |
|
463 | 0 | do { |
464 | 0 | if (!WrapObject(cx, iid, argv[0])) { |
465 | 0 | aRv.Throw(NS_ERROR_UNEXPECTED); |
466 | 0 | return; |
467 | 0 | } |
468 | 0 | break; |
469 | 0 | } while (false); |
470 | 0 |
|
471 | 0 | JS::Rooted<JS::Value> callable(cx, JS::ObjectValue(*mCallback)); |
472 | 0 | if (!JS::Call(cx, aThisVal, callable, |
473 | 0 | JS::HandleValueArray::subarray(argv, 0, argc), &rval)) { |
474 | 0 | aRv.NoteJSContextException(cx); |
475 | 0 | return; |
476 | 0 | } |
477 | 0 | JS::Rooted<JSObject*> rvalDecl(cx); |
478 | 0 | if (rval.isObject()) { |
479 | 0 | #ifdef __clang__ |
480 | 0 | #pragma clang diagnostic push |
481 | 0 | #pragma clang diagnostic ignored "-Wunreachable-code" |
482 | 0 | #pragma clang diagnostic ignored "-Wunreachable-code-return" |
483 | 0 | #endif // __clang__ |
484 | 0 | if ((false) && !CallerSubsumes(rval)) { |
485 | 0 | ThrowErrorMessage(cx, MSG_PERMISSION_DENIED_TO_PASS_ARG, "return value of LifecycleGetCustomInterfaceCallback"); |
486 | 0 | aRv.Throw(NS_ERROR_UNEXPECTED); |
487 | 0 | return; |
488 | 0 | } |
489 | 0 | #ifdef __clang__ |
490 | 0 | #pragma clang diagnostic pop |
491 | 0 | #endif // __clang__ |
492 | 0 | rvalDecl = &rval.toObject(); |
493 | 0 | } else if (rval.isNullOrUndefined()) { |
494 | 0 | rvalDecl = nullptr; |
495 | 0 | } else { |
496 | 0 | ThrowErrorMessage(cx, MSG_NOT_OBJECT, "Return value of LifecycleGetCustomInterfaceCallback"); |
497 | 0 | aRv.Throw(NS_ERROR_UNEXPECTED); |
498 | 0 | return; |
499 | 0 | } |
500 | 0 | aRetVal.set(rvalDecl); |
501 | 0 | } |
502 | | |
503 | | |
504 | | |
505 | | namespace binding_detail { |
506 | | } // namespace binding_detail |
507 | | |
508 | | |
509 | | namespace binding_detail { |
510 | | } // namespace binding_detail |
511 | | |
512 | | |
513 | | namespace binding_detail { |
514 | | } // namespace binding_detail |
515 | | |
516 | | |
517 | | namespace binding_detail { |
518 | | } // namespace binding_detail |
519 | | |
520 | | |
521 | | namespace binding_detail { |
522 | | } // namespace binding_detail |
523 | | |
524 | | |
525 | | } // namespace dom |
526 | | } // namespace mozilla |