/work/obj-fuzz/dom/bindings/RTCRtpTransceiverBinding.cpp
Line | Count | Source (jump to first uncovered line) |
1 | | /* THIS FILE IS AUTOGENERATED FROM RTCRtpTransceiver.webidl BY Codegen.py - DO NOT EDIT */ |
2 | | |
3 | | #include "AtomList.h" |
4 | | #include "RTCRtpReceiverBinding.h" |
5 | | #include "RTCRtpSenderBinding.h" |
6 | | #include "RTCRtpTransceiverBinding.h" |
7 | | #include "WrapperFactory.h" |
8 | | #include "jsapi.h" |
9 | | #include "mozilla/OwningNonNull.h" |
10 | | #include "mozilla/Preferences.h" |
11 | | #include "mozilla/dom/BindingUtils.h" |
12 | | #include "mozilla/dom/DOMJSClass.h" |
13 | | #include "mozilla/dom/NonRefcountedDOMObject.h" |
14 | | #include "mozilla/dom/Nullable.h" |
15 | | #include "mozilla/dom/PrimitiveConversions.h" |
16 | | #include "mozilla/dom/ScriptSettings.h" |
17 | | #include "mozilla/dom/XrayExpandoClass.h" |
18 | | #include "nsContentUtils.h" |
19 | | #include "nsIGlobalObject.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 RTCRtpTransceiverDirectionValues { |
29 | | extern const EnumEntry strings[5] = { |
30 | | {"sendrecv", 8}, |
31 | | {"sendonly", 8}, |
32 | | {"recvonly", 8}, |
33 | | {"inactive", 8}, |
34 | | { nullptr, 0 } |
35 | | }; |
36 | | } // namespace RTCRtpTransceiverDirectionValues |
37 | | |
38 | | bool |
39 | | ToJSValue(JSContext* aCx, RTCRtpTransceiverDirection aArgument, JS::MutableHandle<JS::Value> aValue) |
40 | 0 | { |
41 | 0 | MOZ_ASSERT(uint32_t(aArgument) < ArrayLength(RTCRtpTransceiverDirectionValues::strings)); |
42 | 0 | JSString* resultStr = |
43 | 0 | JS_NewStringCopyN(aCx, RTCRtpTransceiverDirectionValues::strings[uint32_t(aArgument)].value, |
44 | 0 | RTCRtpTransceiverDirectionValues::strings[uint32_t(aArgument)].length); |
45 | 0 | if (!resultStr) { |
46 | 0 | return false; |
47 | 0 | } |
48 | 0 | aValue.setString(resultStr); |
49 | 0 | return true; |
50 | 0 | } |
51 | | |
52 | | |
53 | | |
54 | | RTCRtpTransceiverInit::RTCRtpTransceiverInit() |
55 | 0 | { |
56 | 0 | // Safe to pass a null context if we pass a null value |
57 | 0 | Init(nullptr, JS::NullHandleValue); |
58 | 0 | } |
59 | | |
60 | | |
61 | | |
62 | | bool |
63 | | RTCRtpTransceiverInit::InitIds(JSContext* cx, RTCRtpTransceiverInitAtoms* atomsCache) |
64 | 0 | { |
65 | 0 | MOZ_ASSERT(!*reinterpret_cast<jsid**>(atomsCache)); |
66 | 0 |
|
67 | 0 | // Initialize these in reverse order so that any failure leaves the first one |
68 | 0 | // uninitialized. |
69 | 0 | if (!atomsCache->streams_id.init(cx, "streams") || |
70 | 0 | !atomsCache->direction_id.init(cx, "direction")) { |
71 | 0 | return false; |
72 | 0 | } |
73 | 0 | return true; |
74 | 0 | } |
75 | | |
76 | | bool |
77 | | RTCRtpTransceiverInit::Init(JSContext* cx, JS::Handle<JS::Value> val, const char* sourceDescription, bool passedToJSImpl) |
78 | 0 | { |
79 | 0 | // Passing a null JSContext is OK only if we're initing from null, |
80 | 0 | // Since in that case we will not have to do any property gets |
81 | 0 | // Also evaluate isNullOrUndefined in order to avoid false-positive |
82 | 0 | // checkers by static analysis tools |
83 | 0 | MOZ_ASSERT_IF(!cx, val.isNull() && val.isNullOrUndefined()); |
84 | 0 | RTCRtpTransceiverInitAtoms* atomsCache = nullptr; |
85 | 0 | if (cx) { |
86 | 0 | atomsCache = GetAtomCache<RTCRtpTransceiverInitAtoms>(cx); |
87 | 0 | if (!*reinterpret_cast<jsid**>(atomsCache) && !InitIds(cx, atomsCache)) { |
88 | 0 | return false; |
89 | 0 | } |
90 | 0 | } |
91 | 0 | |
92 | 0 | if (!IsConvertibleToDictionary(val)) { |
93 | 0 | return ThrowErrorMessage(cx, MSG_NOT_DICTIONARY, sourceDescription); |
94 | 0 | } |
95 | 0 | |
96 | 0 | bool isNull = val.isNullOrUndefined(); |
97 | 0 | // We only need these if !isNull, in which case we have |cx|. |
98 | 0 | Maybe<JS::Rooted<JSObject *> > object; |
99 | 0 | Maybe<JS::Rooted<JS::Value> > temp; |
100 | 0 | if (!isNull) { |
101 | 0 | MOZ_ASSERT(cx); |
102 | 0 | object.emplace(cx, &val.toObject()); |
103 | 0 | temp.emplace(cx); |
104 | 0 | } |
105 | 0 | if (!isNull) { |
106 | 0 | if (!JS_GetPropertyById(cx, *object, atomsCache->direction_id, temp.ptr())) { |
107 | 0 | return false; |
108 | 0 | } |
109 | 0 | } |
110 | 0 | if (!isNull && !temp->isUndefined()) { |
111 | 0 | { |
112 | 0 | int index; |
113 | 0 | if (!FindEnumStringIndex<true>(cx, temp.ref(), RTCRtpTransceiverDirectionValues::strings, "RTCRtpTransceiverDirection", "'direction' member of RTCRtpTransceiverInit", &index)) { |
114 | 0 | return false; |
115 | 0 | } |
116 | 0 | MOZ_ASSERT(index >= 0); |
117 | 0 | mDirection = static_cast<RTCRtpTransceiverDirection>(index); |
118 | 0 | } |
119 | 0 | } else { |
120 | 0 | mDirection = RTCRtpTransceiverDirection::Sendrecv; |
121 | 0 | } |
122 | 0 | mIsAnyMemberPresent = true; |
123 | 0 |
|
124 | 0 | if (!isNull) { |
125 | 0 | if (!JS_GetPropertyById(cx, *object, atomsCache->streams_id, temp.ptr())) { |
126 | 0 | return false; |
127 | 0 | } |
128 | 0 | } |
129 | 0 | if (!isNull && !temp->isUndefined()) { |
130 | 0 | if (temp.ref().isObject()) { |
131 | 0 | JS::ForOfIterator iter(cx); |
132 | 0 | if (!iter.init(temp.ref(), JS::ForOfIterator::AllowNonIterable)) { |
133 | 0 | return false; |
134 | 0 | } |
135 | 0 | if (!iter.valueIsIterable()) { |
136 | 0 | ThrowErrorMessage(cx, MSG_NOT_SEQUENCE, "'streams' member of RTCRtpTransceiverInit"); |
137 | 0 | return false; |
138 | 0 | } |
139 | 0 | Sequence<OwningNonNull<mozilla::DOMMediaStream>> &arr = mStreams; |
140 | 0 | JS::Rooted<JS::Value> temp(cx); |
141 | 0 | while (true) { |
142 | 0 | bool done; |
143 | 0 | if (!iter.next(&temp, &done)) { |
144 | 0 | return false; |
145 | 0 | } |
146 | 0 | if (done) { |
147 | 0 | break; |
148 | 0 | } |
149 | 0 | OwningNonNull<mozilla::DOMMediaStream>* slotPtr = arr.AppendElement(mozilla::fallible); |
150 | 0 | if (!slotPtr) { |
151 | 0 | JS_ReportOutOfMemory(cx); |
152 | 0 | return false; |
153 | 0 | } |
154 | 0 | OwningNonNull<mozilla::DOMMediaStream>& slot = *slotPtr; |
155 | 0 | if (temp.isObject()) { |
156 | 0 | static_assert(IsRefcounted<mozilla::DOMMediaStream>::value, "We can only store refcounted classes.");{ |
157 | 0 | nsresult rv = UnwrapObject<prototypes::id::MediaStream, mozilla::DOMMediaStream>(&temp, slot); |
158 | 0 | if (NS_FAILED(rv)) { |
159 | 0 | ThrowErrorMessage(cx, MSG_DOES_NOT_IMPLEMENT_INTERFACE, "Element of 'streams' member of RTCRtpTransceiverInit", "MediaStream"); |
160 | 0 | return false; |
161 | 0 | } |
162 | 0 | } |
163 | 0 | } else { |
164 | 0 | ThrowErrorMessage(cx, MSG_NOT_OBJECT, "Element of 'streams' member of RTCRtpTransceiverInit"); |
165 | 0 | return false; |
166 | 0 | } |
167 | 0 | } |
168 | 0 | } else { |
169 | 0 | ThrowErrorMessage(cx, MSG_NOT_SEQUENCE, "'streams' member of RTCRtpTransceiverInit"); |
170 | 0 | return false; |
171 | 0 | } |
172 | 0 | } else { |
173 | 0 | /* Array is already empty; nothing to do */ |
174 | 0 | } |
175 | 0 | mIsAnyMemberPresent = true; |
176 | 0 | return true; |
177 | 0 | } |
178 | | |
179 | | bool |
180 | | RTCRtpTransceiverInit::ToObjectInternal(JSContext* cx, JS::MutableHandle<JS::Value> rval) const |
181 | 0 | { |
182 | 0 | RTCRtpTransceiverInitAtoms* atomsCache = GetAtomCache<RTCRtpTransceiverInitAtoms>(cx); |
183 | 0 | if (!*reinterpret_cast<jsid**>(atomsCache) && !InitIds(cx, atomsCache)) { |
184 | 0 | return false; |
185 | 0 | } |
186 | 0 | |
187 | 0 | JS::Rooted<JSObject*> obj(cx, JS_NewPlainObject(cx)); |
188 | 0 | if (!obj) { |
189 | 0 | return false; |
190 | 0 | } |
191 | 0 | rval.set(JS::ObjectValue(*obj)); |
192 | 0 |
|
193 | 0 | do { |
194 | 0 | // block for our 'break' successCode and scope for 'temp' and 'currentValue' |
195 | 0 | JS::Rooted<JS::Value> temp(cx); |
196 | 0 | RTCRtpTransceiverDirection const & currentValue = mDirection; |
197 | 0 | if (!ToJSValue(cx, currentValue, &temp)) { |
198 | 0 | return false; |
199 | 0 | } |
200 | 0 | if (!JS_DefinePropertyById(cx, obj, atomsCache->direction_id, temp, JSPROP_ENUMERATE)) { |
201 | 0 | return false; |
202 | 0 | } |
203 | 0 | break; |
204 | 0 | } while(false); |
205 | 0 |
|
206 | 0 | do { |
207 | 0 | // block for our 'break' successCode and scope for 'temp' and 'currentValue' |
208 | 0 | JS::Rooted<JS::Value> temp(cx); |
209 | 0 | Sequence<OwningNonNull<mozilla::DOMMediaStream>> const & currentValue = mStreams; |
210 | 0 |
|
211 | 0 | uint32_t length = currentValue.Length(); |
212 | 0 | JS::Rooted<JSObject*> returnArray(cx, JS_NewArrayObject(cx, length)); |
213 | 0 | if (!returnArray) { |
214 | 0 | return false; |
215 | 0 | } |
216 | 0 | // Scope for 'tmp' |
217 | 0 | { |
218 | 0 | JS::Rooted<JS::Value> tmp(cx); |
219 | 0 | for (uint32_t sequenceIdx0 = 0; sequenceIdx0 < length; ++sequenceIdx0) { |
220 | 0 | // Control block to let us common up the JS_DefineElement calls when there |
221 | 0 | // are different ways to succeed at wrapping the object. |
222 | 0 | do { |
223 | 0 | if (!GetOrCreateDOMReflector(cx, currentValue[sequenceIdx0], &tmp)) { |
224 | 0 | MOZ_ASSERT(JS_IsExceptionPending(cx)); |
225 | 0 | return false; |
226 | 0 | } |
227 | 0 | break; |
228 | 0 | } while (false); |
229 | 0 | if (!JS_DefineElement(cx, returnArray, sequenceIdx0, tmp, |
230 | 0 | JSPROP_ENUMERATE)) { |
231 | 0 | return false; |
232 | 0 | } |
233 | 0 | } |
234 | 0 | } |
235 | 0 | temp.setObject(*returnArray); |
236 | 0 | if (!JS_DefinePropertyById(cx, obj, atomsCache->streams_id, temp, JSPROP_ENUMERATE)) { |
237 | 0 | return false; |
238 | 0 | } |
239 | 0 | break; |
240 | 0 | } while(false); |
241 | 0 |
|
242 | 0 | return true; |
243 | 0 | } |
244 | | |
245 | | void |
246 | | RTCRtpTransceiverInit::TraceDictionary(JSTracer* trc) |
247 | 0 | { |
248 | 0 | } |
249 | | |
250 | | |
251 | | |
252 | | RTCRtpTransceiverInit& |
253 | | RTCRtpTransceiverInit::operator=(const RTCRtpTransceiverInit& aOther) |
254 | 0 | { |
255 | 0 | DictionaryBase::operator=(aOther); |
256 | 0 | mDirection = aOther.mDirection; |
257 | 0 | mStreams = aOther.mStreams; |
258 | 0 | return *this; |
259 | 0 | } |
260 | | |
261 | | namespace binding_detail { |
262 | | } // namespace binding_detail |
263 | | |
264 | | |
265 | | namespace RTCRtpTransceiver_Binding { |
266 | | |
267 | | MOZ_CAN_RUN_SCRIPT static bool |
268 | | get_mid(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::RTCRtpTransceiver* self, JSJitGetterCallArgs args) |
269 | 0 | { |
270 | 0 | AUTO_PROFILER_LABEL_FAST("get RTCRtpTransceiver.mid", DOM, cx); |
271 | 0 |
|
272 | 0 | Maybe<JS::Rooted<JSObject*> > unwrappedObj; |
273 | 0 | bool objIsXray = xpc::WrapperFactory::IsXrayWrapper(obj); |
274 | 0 | if (objIsXray) { |
275 | 0 | unwrappedObj.emplace(cx, obj); |
276 | 0 | } |
277 | 0 | if (objIsXray) { |
278 | 0 | unwrappedObj.ref() = js::CheckedUnwrap(unwrappedObj.ref()); |
279 | 0 | if (!unwrappedObj.ref()) { |
280 | 0 | return false; |
281 | 0 | } |
282 | 0 | } |
283 | 0 | FastErrorResult rv; |
284 | 0 | DOMString result; |
285 | 0 | self->GetMid(result, rv, (unwrappedObj ? js::GetNonCCWObjectRealm(*unwrappedObj) : js::GetContextRealm(cx))); |
286 | 0 | if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) { |
287 | 0 | return false; |
288 | 0 | } |
289 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
290 | 0 | if (!xpc::StringToJsval(cx, result, args.rval())) { |
291 | 0 | return false; |
292 | 0 | } |
293 | 0 | return true; |
294 | 0 | } |
295 | | |
296 | | static const JSJitInfo mid_getterinfo = { |
297 | | { (JSJitGetterOp)get_mid }, |
298 | | { prototypes::id::RTCRtpTransceiver }, |
299 | | { PrototypeTraits<prototypes::id::RTCRtpTransceiver>::Depth }, |
300 | | JSJitInfo::Getter, |
301 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
302 | | JSVAL_TYPE_UNKNOWN, /* returnType. Not relevant for setters. */ |
303 | | false, /* isInfallible. False in setters. */ |
304 | | false, /* isMovable. Not relevant for setters. */ |
305 | | false, /* isEliminatable. Not relevant for setters. */ |
306 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
307 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
308 | | false, /* isTypedMethod. Only relevant for methods. */ |
309 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
310 | | }; |
311 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
312 | | static_assert(0 < 1, "There is no slot for us"); |
313 | | |
314 | | MOZ_CAN_RUN_SCRIPT static bool |
315 | | get_sender(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::RTCRtpTransceiver* self, JSJitGetterCallArgs args) |
316 | 0 | { |
317 | 0 | AUTO_PROFILER_LABEL_FAST("get RTCRtpTransceiver.sender", DOM, cx); |
318 | 0 |
|
319 | 0 | Maybe<JS::Rooted<JSObject*> > unwrappedObj; |
320 | 0 | bool objIsXray = xpc::WrapperFactory::IsXrayWrapper(obj); |
321 | 0 | if (objIsXray) { |
322 | 0 | unwrappedObj.emplace(cx, obj); |
323 | 0 | } |
324 | 0 | if (objIsXray) { |
325 | 0 | unwrappedObj.ref() = js::CheckedUnwrap(unwrappedObj.ref()); |
326 | 0 | if (!unwrappedObj.ref()) { |
327 | 0 | return false; |
328 | 0 | } |
329 | 0 | } |
330 | 0 | FastErrorResult rv; |
331 | 0 | auto result(StrongOrRawPtr<mozilla::dom::RTCRtpSender>(self->GetSender(rv, (unwrappedObj ? js::GetNonCCWObjectRealm(*unwrappedObj) : js::GetContextRealm(cx))))); |
332 | 0 | if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) { |
333 | 0 | return false; |
334 | 0 | } |
335 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
336 | 0 | if (!GetOrCreateDOMReflector(cx, result, args.rval())) { |
337 | 0 | MOZ_ASSERT(JS_IsExceptionPending(cx)); |
338 | 0 | return false; |
339 | 0 | } |
340 | 0 | return true; |
341 | 0 | } |
342 | | |
343 | | static const JSJitInfo sender_getterinfo = { |
344 | | { (JSJitGetterOp)get_sender }, |
345 | | { prototypes::id::RTCRtpTransceiver }, |
346 | | { PrototypeTraits<prototypes::id::RTCRtpTransceiver>::Depth }, |
347 | | JSJitInfo::Getter, |
348 | | JSJitInfo::AliasNone, /* aliasSet. Not relevant for setters. */ |
349 | | JSVAL_TYPE_OBJECT, /* returnType. Not relevant for setters. */ |
350 | | false, /* isInfallible. False in setters. */ |
351 | | false, /* isMovable. Not relevant for setters. */ |
352 | | false, /* isEliminatable. Not relevant for setters. */ |
353 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
354 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
355 | | false, /* isTypedMethod. Only relevant for methods. */ |
356 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
357 | | }; |
358 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
359 | | static_assert(0 < 1, "There is no slot for us"); |
360 | | |
361 | | MOZ_CAN_RUN_SCRIPT static bool |
362 | | get_receiver(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::RTCRtpTransceiver* self, JSJitGetterCallArgs args) |
363 | 0 | { |
364 | 0 | AUTO_PROFILER_LABEL_FAST("get RTCRtpTransceiver.receiver", DOM, cx); |
365 | 0 |
|
366 | 0 | Maybe<JS::Rooted<JSObject*> > unwrappedObj; |
367 | 0 | bool objIsXray = xpc::WrapperFactory::IsXrayWrapper(obj); |
368 | 0 | if (objIsXray) { |
369 | 0 | unwrappedObj.emplace(cx, obj); |
370 | 0 | } |
371 | 0 | if (objIsXray) { |
372 | 0 | unwrappedObj.ref() = js::CheckedUnwrap(unwrappedObj.ref()); |
373 | 0 | if (!unwrappedObj.ref()) { |
374 | 0 | return false; |
375 | 0 | } |
376 | 0 | } |
377 | 0 | FastErrorResult rv; |
378 | 0 | auto result(StrongOrRawPtr<mozilla::dom::RTCRtpReceiver>(self->GetReceiver(rv, (unwrappedObj ? js::GetNonCCWObjectRealm(*unwrappedObj) : js::GetContextRealm(cx))))); |
379 | 0 | if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) { |
380 | 0 | return false; |
381 | 0 | } |
382 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
383 | 0 | if (!GetOrCreateDOMReflector(cx, result, args.rval())) { |
384 | 0 | MOZ_ASSERT(JS_IsExceptionPending(cx)); |
385 | 0 | return false; |
386 | 0 | } |
387 | 0 | return true; |
388 | 0 | } |
389 | | |
390 | | static const JSJitInfo receiver_getterinfo = { |
391 | | { (JSJitGetterOp)get_receiver }, |
392 | | { prototypes::id::RTCRtpTransceiver }, |
393 | | { PrototypeTraits<prototypes::id::RTCRtpTransceiver>::Depth }, |
394 | | JSJitInfo::Getter, |
395 | | JSJitInfo::AliasNone, /* aliasSet. Not relevant for setters. */ |
396 | | JSVAL_TYPE_OBJECT, /* returnType. Not relevant for setters. */ |
397 | | false, /* isInfallible. False in setters. */ |
398 | | false, /* isMovable. Not relevant for setters. */ |
399 | | false, /* isEliminatable. Not relevant for setters. */ |
400 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
401 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
402 | | false, /* isTypedMethod. Only relevant for methods. */ |
403 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
404 | | }; |
405 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
406 | | static_assert(0 < 1, "There is no slot for us"); |
407 | | |
408 | | MOZ_CAN_RUN_SCRIPT static bool |
409 | | get_stopped(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::RTCRtpTransceiver* self, JSJitGetterCallArgs args) |
410 | 0 | { |
411 | 0 | AUTO_PROFILER_LABEL_FAST("get RTCRtpTransceiver.stopped", DOM, cx); |
412 | 0 |
|
413 | 0 | Maybe<JS::Rooted<JSObject*> > unwrappedObj; |
414 | 0 | bool objIsXray = xpc::WrapperFactory::IsXrayWrapper(obj); |
415 | 0 | if (objIsXray) { |
416 | 0 | unwrappedObj.emplace(cx, obj); |
417 | 0 | } |
418 | 0 | if (objIsXray) { |
419 | 0 | unwrappedObj.ref() = js::CheckedUnwrap(unwrappedObj.ref()); |
420 | 0 | if (!unwrappedObj.ref()) { |
421 | 0 | return false; |
422 | 0 | } |
423 | 0 | } |
424 | 0 | FastErrorResult rv; |
425 | 0 | bool result(self->GetStopped(rv, (unwrappedObj ? js::GetNonCCWObjectRealm(*unwrappedObj) : js::GetContextRealm(cx)))); |
426 | 0 | if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) { |
427 | 0 | return false; |
428 | 0 | } |
429 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
430 | 0 | args.rval().setBoolean(result); |
431 | 0 | return true; |
432 | 0 | } |
433 | | |
434 | | static const JSJitInfo stopped_getterinfo = { |
435 | | { (JSJitGetterOp)get_stopped }, |
436 | | { prototypes::id::RTCRtpTransceiver }, |
437 | | { PrototypeTraits<prototypes::id::RTCRtpTransceiver>::Depth }, |
438 | | JSJitInfo::Getter, |
439 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
440 | | JSVAL_TYPE_BOOLEAN, /* returnType. Not relevant for setters. */ |
441 | | false, /* isInfallible. False in setters. */ |
442 | | false, /* isMovable. Not relevant for setters. */ |
443 | | false, /* isEliminatable. Not relevant for setters. */ |
444 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
445 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
446 | | false, /* isTypedMethod. Only relevant for methods. */ |
447 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
448 | | }; |
449 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
450 | | static_assert(0 < 1, "There is no slot for us"); |
451 | | |
452 | | MOZ_CAN_RUN_SCRIPT static bool |
453 | | get_direction(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::RTCRtpTransceiver* self, JSJitGetterCallArgs args) |
454 | 0 | { |
455 | 0 | AUTO_PROFILER_LABEL_FAST("get RTCRtpTransceiver.direction", DOM, cx); |
456 | 0 |
|
457 | 0 | Maybe<JS::Rooted<JSObject*> > unwrappedObj; |
458 | 0 | bool objIsXray = xpc::WrapperFactory::IsXrayWrapper(obj); |
459 | 0 | if (objIsXray) { |
460 | 0 | unwrappedObj.emplace(cx, obj); |
461 | 0 | } |
462 | 0 | if (objIsXray) { |
463 | 0 | unwrappedObj.ref() = js::CheckedUnwrap(unwrappedObj.ref()); |
464 | 0 | if (!unwrappedObj.ref()) { |
465 | 0 | return false; |
466 | 0 | } |
467 | 0 | } |
468 | 0 | FastErrorResult rv; |
469 | 0 | RTCRtpTransceiverDirection result(self->GetDirection(rv, (unwrappedObj ? js::GetNonCCWObjectRealm(*unwrappedObj) : js::GetContextRealm(cx)))); |
470 | 0 | if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) { |
471 | 0 | return false; |
472 | 0 | } |
473 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
474 | 0 | if (!ToJSValue(cx, result, args.rval())) { |
475 | 0 | return false; |
476 | 0 | } |
477 | 0 | return true; |
478 | 0 | } |
479 | | |
480 | | MOZ_CAN_RUN_SCRIPT static bool |
481 | | set_direction(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::RTCRtpTransceiver* self, JSJitSetterCallArgs args) |
482 | 0 | { |
483 | 0 | AUTO_PROFILER_LABEL_FAST("set RTCRtpTransceiver.direction", DOM, cx); |
484 | 0 |
|
485 | 0 | Maybe<JS::Rooted<JSObject*> > unwrappedObj; |
486 | 0 | bool objIsXray = xpc::WrapperFactory::IsXrayWrapper(obj); |
487 | 0 | if (objIsXray) { |
488 | 0 | unwrappedObj.emplace(cx, obj); |
489 | 0 | } |
490 | 0 | RTCRtpTransceiverDirection arg0; |
491 | 0 | { |
492 | 0 | int index; |
493 | 0 | if (!FindEnumStringIndex<false>(cx, args[0], RTCRtpTransceiverDirectionValues::strings, "RTCRtpTransceiverDirection", "Value being assigned to RTCRtpTransceiver.direction", &index)) { |
494 | 0 | return false; |
495 | 0 | } |
496 | 0 | if (index < 0) { |
497 | 0 | return true; |
498 | 0 | } |
499 | 0 | arg0 = static_cast<RTCRtpTransceiverDirection>(index); |
500 | 0 | } |
501 | 0 | if (objIsXray) { |
502 | 0 | unwrappedObj.ref() = js::CheckedUnwrap(unwrappedObj.ref()); |
503 | 0 | if (!unwrappedObj.ref()) { |
504 | 0 | return false; |
505 | 0 | } |
506 | 0 | } |
507 | 0 | FastErrorResult rv; |
508 | 0 | self->SetDirection(arg0, rv, (unwrappedObj ? js::GetNonCCWObjectRealm(*unwrappedObj) : js::GetContextRealm(cx))); |
509 | 0 | if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) { |
510 | 0 | return false; |
511 | 0 | } |
512 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
513 | 0 |
|
514 | 0 | return true; |
515 | 0 | } |
516 | | |
517 | | static const JSJitInfo direction_getterinfo = { |
518 | | { (JSJitGetterOp)get_direction }, |
519 | | { prototypes::id::RTCRtpTransceiver }, |
520 | | { PrototypeTraits<prototypes::id::RTCRtpTransceiver>::Depth }, |
521 | | JSJitInfo::Getter, |
522 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
523 | | JSVAL_TYPE_STRING, /* returnType. Not relevant for setters. */ |
524 | | false, /* isInfallible. False in setters. */ |
525 | | false, /* isMovable. Not relevant for setters. */ |
526 | | false, /* isEliminatable. Not relevant for setters. */ |
527 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
528 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
529 | | false, /* isTypedMethod. Only relevant for methods. */ |
530 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
531 | | }; |
532 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
533 | | static_assert(0 < 1, "There is no slot for us"); |
534 | | static const JSJitInfo direction_setterinfo = { |
535 | | { (JSJitGetterOp)set_direction }, |
536 | | { prototypes::id::RTCRtpTransceiver }, |
537 | | { PrototypeTraits<prototypes::id::RTCRtpTransceiver>::Depth }, |
538 | | JSJitInfo::Setter, |
539 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
540 | | JSVAL_TYPE_UNDEFINED, /* returnType. Not relevant for setters. */ |
541 | | false, /* isInfallible. False in setters. */ |
542 | | false, /* isMovable. Not relevant for setters. */ |
543 | | false, /* isEliminatable. Not relevant for setters. */ |
544 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
545 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
546 | | false, /* isTypedMethod. Only relevant for methods. */ |
547 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
548 | | }; |
549 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
550 | | static_assert(0 < 1, "There is no slot for us"); |
551 | | |
552 | | MOZ_CAN_RUN_SCRIPT static bool |
553 | | get_currentDirection(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::RTCRtpTransceiver* self, JSJitGetterCallArgs args) |
554 | 0 | { |
555 | 0 | AUTO_PROFILER_LABEL_FAST("get RTCRtpTransceiver.currentDirection", DOM, cx); |
556 | 0 |
|
557 | 0 | Maybe<JS::Rooted<JSObject*> > unwrappedObj; |
558 | 0 | bool objIsXray = xpc::WrapperFactory::IsXrayWrapper(obj); |
559 | 0 | if (objIsXray) { |
560 | 0 | unwrappedObj.emplace(cx, obj); |
561 | 0 | } |
562 | 0 | if (objIsXray) { |
563 | 0 | unwrappedObj.ref() = js::CheckedUnwrap(unwrappedObj.ref()); |
564 | 0 | if (!unwrappedObj.ref()) { |
565 | 0 | return false; |
566 | 0 | } |
567 | 0 | } |
568 | 0 | FastErrorResult rv; |
569 | 0 | Nullable<RTCRtpTransceiverDirection> result(self->GetCurrentDirection(rv, (unwrappedObj ? js::GetNonCCWObjectRealm(*unwrappedObj) : js::GetContextRealm(cx)))); |
570 | 0 | if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) { |
571 | 0 | return false; |
572 | 0 | } |
573 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
574 | 0 | if (result.IsNull()) { |
575 | 0 | args.rval().setNull(); |
576 | 0 | return true; |
577 | 0 | } else { |
578 | 0 | if (!ToJSValue(cx, result.Value(), args.rval())) { |
579 | 0 | return false; |
580 | 0 | } |
581 | 0 | return true; |
582 | 0 | } |
583 | 0 | } |
584 | | |
585 | | static const JSJitInfo currentDirection_getterinfo = { |
586 | | { (JSJitGetterOp)get_currentDirection }, |
587 | | { prototypes::id::RTCRtpTransceiver }, |
588 | | { PrototypeTraits<prototypes::id::RTCRtpTransceiver>::Depth }, |
589 | | JSJitInfo::Getter, |
590 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
591 | | JSVAL_TYPE_UNKNOWN, /* returnType. Not relevant for setters. */ |
592 | | false, /* isInfallible. False in setters. */ |
593 | | false, /* isMovable. Not relevant for setters. */ |
594 | | false, /* isEliminatable. Not relevant for setters. */ |
595 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
596 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
597 | | false, /* isTypedMethod. Only relevant for methods. */ |
598 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
599 | | }; |
600 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
601 | | static_assert(0 < 1, "There is no slot for us"); |
602 | | |
603 | | MOZ_CAN_RUN_SCRIPT static bool |
604 | | stop(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::RTCRtpTransceiver* self, const JSJitMethodCallArgs& args) |
605 | 0 | { |
606 | 0 | AUTO_PROFILER_LABEL_FAST("RTCRtpTransceiver.stop", DOM, cx); |
607 | 0 |
|
608 | 0 | Maybe<JS::Rooted<JSObject*> > unwrappedObj; |
609 | 0 | bool objIsXray = xpc::WrapperFactory::IsXrayWrapper(obj); |
610 | 0 | if (objIsXray) { |
611 | 0 | unwrappedObj.emplace(cx, obj); |
612 | 0 | } |
613 | 0 | if (objIsXray) { |
614 | 0 | unwrappedObj.ref() = js::CheckedUnwrap(unwrappedObj.ref()); |
615 | 0 | if (!unwrappedObj.ref()) { |
616 | 0 | return false; |
617 | 0 | } |
618 | 0 | } |
619 | 0 | FastErrorResult rv; |
620 | 0 | self->Stop(rv, (unwrappedObj ? js::GetNonCCWObjectRealm(*unwrappedObj) : js::GetContextRealm(cx))); |
621 | 0 | if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) { |
622 | 0 | return false; |
623 | 0 | } |
624 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
625 | 0 | args.rval().setUndefined(); |
626 | 0 | return true; |
627 | 0 | } |
628 | | |
629 | | static const JSJitInfo stop_methodinfo = { |
630 | | { (JSJitGetterOp)stop }, |
631 | | { prototypes::id::RTCRtpTransceiver }, |
632 | | { PrototypeTraits<prototypes::id::RTCRtpTransceiver>::Depth }, |
633 | | JSJitInfo::Method, |
634 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
635 | | JSVAL_TYPE_UNDEFINED, /* returnType. Not relevant for setters. */ |
636 | | false, /* isInfallible. False in setters. */ |
637 | | false, /* isMovable. Not relevant for setters. */ |
638 | | false, /* isEliminatable. Not relevant for setters. */ |
639 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
640 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
641 | | false, /* isTypedMethod. Only relevant for methods. */ |
642 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
643 | | }; |
644 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
645 | | static_assert(0 < 1, "There is no slot for us"); |
646 | | |
647 | | MOZ_CAN_RUN_SCRIPT static bool |
648 | | setRemoteTrackId(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::RTCRtpTransceiver* self, const JSJitMethodCallArgs& args) |
649 | 0 | { |
650 | 0 | AUTO_PROFILER_LABEL_FAST("RTCRtpTransceiver.setRemoteTrackId", DOM, cx); |
651 | 0 |
|
652 | 0 | if (MOZ_UNLIKELY(args.length() < 1)) { |
653 | 0 | return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "RTCRtpTransceiver.setRemoteTrackId"); |
654 | 0 | } |
655 | 0 | Maybe<JS::Rooted<JSObject*> > unwrappedObj; |
656 | 0 | bool objIsXray = xpc::WrapperFactory::IsXrayWrapper(obj); |
657 | 0 | if (objIsXray) { |
658 | 0 | unwrappedObj.emplace(cx, obj); |
659 | 0 | } |
660 | 0 | binding_detail::FakeString arg0; |
661 | 0 | if (!ConvertJSValueToString(cx, args[0], eStringify, eStringify, arg0)) { |
662 | 0 | return false; |
663 | 0 | } |
664 | 0 | if (objIsXray) { |
665 | 0 | unwrappedObj.ref() = js::CheckedUnwrap(unwrappedObj.ref()); |
666 | 0 | if (!unwrappedObj.ref()) { |
667 | 0 | return false; |
668 | 0 | } |
669 | 0 | } |
670 | 0 | FastErrorResult rv; |
671 | 0 | self->SetRemoteTrackId(NonNullHelper(Constify(arg0)), rv, (unwrappedObj ? js::GetNonCCWObjectRealm(*unwrappedObj) : js::GetContextRealm(cx))); |
672 | 0 | if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) { |
673 | 0 | return false; |
674 | 0 | } |
675 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
676 | 0 | args.rval().setUndefined(); |
677 | 0 | return true; |
678 | 0 | } |
679 | | |
680 | | static const JSJitInfo setRemoteTrackId_methodinfo = { |
681 | | { (JSJitGetterOp)setRemoteTrackId }, |
682 | | { prototypes::id::RTCRtpTransceiver }, |
683 | | { PrototypeTraits<prototypes::id::RTCRtpTransceiver>::Depth }, |
684 | | JSJitInfo::Method, |
685 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
686 | | JSVAL_TYPE_UNDEFINED, /* returnType. Not relevant for setters. */ |
687 | | false, /* isInfallible. False in setters. */ |
688 | | false, /* isMovable. Not relevant for setters. */ |
689 | | false, /* isEliminatable. Not relevant for setters. */ |
690 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
691 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
692 | | false, /* isTypedMethod. Only relevant for methods. */ |
693 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
694 | | }; |
695 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
696 | | static_assert(0 < 1, "There is no slot for us"); |
697 | | |
698 | | MOZ_CAN_RUN_SCRIPT static bool |
699 | | remoteTrackIdIs(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::RTCRtpTransceiver* self, const JSJitMethodCallArgs& args) |
700 | 0 | { |
701 | 0 | AUTO_PROFILER_LABEL_FAST("RTCRtpTransceiver.remoteTrackIdIs", DOM, cx); |
702 | 0 |
|
703 | 0 | if (MOZ_UNLIKELY(args.length() < 1)) { |
704 | 0 | return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "RTCRtpTransceiver.remoteTrackIdIs"); |
705 | 0 | } |
706 | 0 | Maybe<JS::Rooted<JSObject*> > unwrappedObj; |
707 | 0 | bool objIsXray = xpc::WrapperFactory::IsXrayWrapper(obj); |
708 | 0 | if (objIsXray) { |
709 | 0 | unwrappedObj.emplace(cx, obj); |
710 | 0 | } |
711 | 0 | binding_detail::FakeString arg0; |
712 | 0 | if (!ConvertJSValueToString(cx, args[0], eStringify, eStringify, arg0)) { |
713 | 0 | return false; |
714 | 0 | } |
715 | 0 | if (objIsXray) { |
716 | 0 | unwrappedObj.ref() = js::CheckedUnwrap(unwrappedObj.ref()); |
717 | 0 | if (!unwrappedObj.ref()) { |
718 | 0 | return false; |
719 | 0 | } |
720 | 0 | } |
721 | 0 | FastErrorResult rv; |
722 | 0 | bool result(self->RemoteTrackIdIs(NonNullHelper(Constify(arg0)), rv, (unwrappedObj ? js::GetNonCCWObjectRealm(*unwrappedObj) : js::GetContextRealm(cx)))); |
723 | 0 | if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) { |
724 | 0 | return false; |
725 | 0 | } |
726 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
727 | 0 | args.rval().setBoolean(result); |
728 | 0 | return true; |
729 | 0 | } |
730 | | |
731 | | static const JSJitInfo remoteTrackIdIs_methodinfo = { |
732 | | { (JSJitGetterOp)remoteTrackIdIs }, |
733 | | { prototypes::id::RTCRtpTransceiver }, |
734 | | { PrototypeTraits<prototypes::id::RTCRtpTransceiver>::Depth }, |
735 | | JSJitInfo::Method, |
736 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
737 | | JSVAL_TYPE_BOOLEAN, /* returnType. Not relevant for setters. */ |
738 | | false, /* isInfallible. False in setters. */ |
739 | | false, /* isMovable. Not relevant for setters. */ |
740 | | false, /* isEliminatable. Not relevant for setters. */ |
741 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
742 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
743 | | false, /* isTypedMethod. Only relevant for methods. */ |
744 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
745 | | }; |
746 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
747 | | static_assert(0 < 1, "There is no slot for us"); |
748 | | |
749 | | MOZ_CAN_RUN_SCRIPT static bool |
750 | | getRemoteTrackId(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::RTCRtpTransceiver* self, const JSJitMethodCallArgs& args) |
751 | 0 | { |
752 | 0 | AUTO_PROFILER_LABEL_FAST("RTCRtpTransceiver.getRemoteTrackId", DOM, cx); |
753 | 0 |
|
754 | 0 | Maybe<JS::Rooted<JSObject*> > unwrappedObj; |
755 | 0 | bool objIsXray = xpc::WrapperFactory::IsXrayWrapper(obj); |
756 | 0 | if (objIsXray) { |
757 | 0 | unwrappedObj.emplace(cx, obj); |
758 | 0 | } |
759 | 0 | if (objIsXray) { |
760 | 0 | unwrappedObj.ref() = js::CheckedUnwrap(unwrappedObj.ref()); |
761 | 0 | if (!unwrappedObj.ref()) { |
762 | 0 | return false; |
763 | 0 | } |
764 | 0 | } |
765 | 0 | FastErrorResult rv; |
766 | 0 | DOMString result; |
767 | 0 | self->GetRemoteTrackId(result, rv, (unwrappedObj ? js::GetNonCCWObjectRealm(*unwrappedObj) : js::GetContextRealm(cx))); |
768 | 0 | if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) { |
769 | 0 | return false; |
770 | 0 | } |
771 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
772 | 0 | if (!xpc::NonVoidStringToJsval(cx, result, args.rval())) { |
773 | 0 | return false; |
774 | 0 | } |
775 | 0 | return true; |
776 | 0 | } |
777 | | |
778 | | static const JSJitInfo getRemoteTrackId_methodinfo = { |
779 | | { (JSJitGetterOp)getRemoteTrackId }, |
780 | | { prototypes::id::RTCRtpTransceiver }, |
781 | | { PrototypeTraits<prototypes::id::RTCRtpTransceiver>::Depth }, |
782 | | JSJitInfo::Method, |
783 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
784 | | JSVAL_TYPE_STRING, /* returnType. Not relevant for setters. */ |
785 | | false, /* isInfallible. False in setters. */ |
786 | | false, /* isMovable. Not relevant for setters. */ |
787 | | false, /* isEliminatable. Not relevant for setters. */ |
788 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
789 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
790 | | false, /* isTypedMethod. Only relevant for methods. */ |
791 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
792 | | }; |
793 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
794 | | static_assert(0 < 1, "There is no slot for us"); |
795 | | |
796 | | MOZ_CAN_RUN_SCRIPT static bool |
797 | | setAddTrackMagic(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::RTCRtpTransceiver* self, const JSJitMethodCallArgs& args) |
798 | 0 | { |
799 | 0 | AUTO_PROFILER_LABEL_FAST("RTCRtpTransceiver.setAddTrackMagic", DOM, cx); |
800 | 0 |
|
801 | 0 | Maybe<JS::Rooted<JSObject*> > unwrappedObj; |
802 | 0 | bool objIsXray = xpc::WrapperFactory::IsXrayWrapper(obj); |
803 | 0 | if (objIsXray) { |
804 | 0 | unwrappedObj.emplace(cx, obj); |
805 | 0 | } |
806 | 0 | if (objIsXray) { |
807 | 0 | unwrappedObj.ref() = js::CheckedUnwrap(unwrappedObj.ref()); |
808 | 0 | if (!unwrappedObj.ref()) { |
809 | 0 | return false; |
810 | 0 | } |
811 | 0 | } |
812 | 0 | FastErrorResult rv; |
813 | 0 | self->SetAddTrackMagic(rv, (unwrappedObj ? js::GetNonCCWObjectRealm(*unwrappedObj) : js::GetContextRealm(cx))); |
814 | 0 | if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) { |
815 | 0 | return false; |
816 | 0 | } |
817 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
818 | 0 | args.rval().setUndefined(); |
819 | 0 | return true; |
820 | 0 | } |
821 | | |
822 | | static const JSJitInfo setAddTrackMagic_methodinfo = { |
823 | | { (JSJitGetterOp)setAddTrackMagic }, |
824 | | { prototypes::id::RTCRtpTransceiver }, |
825 | | { PrototypeTraits<prototypes::id::RTCRtpTransceiver>::Depth }, |
826 | | JSJitInfo::Method, |
827 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
828 | | JSVAL_TYPE_UNDEFINED, /* returnType. Not relevant for setters. */ |
829 | | false, /* isInfallible. False in setters. */ |
830 | | false, /* isMovable. Not relevant for setters. */ |
831 | | false, /* isEliminatable. Not relevant for setters. */ |
832 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
833 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
834 | | false, /* isTypedMethod. Only relevant for methods. */ |
835 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
836 | | }; |
837 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
838 | | static_assert(0 < 1, "There is no slot for us"); |
839 | | |
840 | | MOZ_CAN_RUN_SCRIPT static bool |
841 | | get_addTrackMagic(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::RTCRtpTransceiver* self, JSJitGetterCallArgs args) |
842 | 0 | { |
843 | 0 | AUTO_PROFILER_LABEL_FAST("get RTCRtpTransceiver.addTrackMagic", DOM, cx); |
844 | 0 |
|
845 | 0 | Maybe<JS::Rooted<JSObject*> > unwrappedObj; |
846 | 0 | bool objIsXray = xpc::WrapperFactory::IsXrayWrapper(obj); |
847 | 0 | if (objIsXray) { |
848 | 0 | unwrappedObj.emplace(cx, obj); |
849 | 0 | } |
850 | 0 | if (objIsXray) { |
851 | 0 | unwrappedObj.ref() = js::CheckedUnwrap(unwrappedObj.ref()); |
852 | 0 | if (!unwrappedObj.ref()) { |
853 | 0 | return false; |
854 | 0 | } |
855 | 0 | } |
856 | 0 | FastErrorResult rv; |
857 | 0 | bool result(self->GetAddTrackMagic(rv, (unwrappedObj ? js::GetNonCCWObjectRealm(*unwrappedObj) : js::GetContextRealm(cx)))); |
858 | 0 | if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) { |
859 | 0 | return false; |
860 | 0 | } |
861 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
862 | 0 | args.rval().setBoolean(result); |
863 | 0 | return true; |
864 | 0 | } |
865 | | |
866 | | static const JSJitInfo addTrackMagic_getterinfo = { |
867 | | { (JSJitGetterOp)get_addTrackMagic }, |
868 | | { prototypes::id::RTCRtpTransceiver }, |
869 | | { PrototypeTraits<prototypes::id::RTCRtpTransceiver>::Depth }, |
870 | | JSJitInfo::Getter, |
871 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
872 | | JSVAL_TYPE_BOOLEAN, /* returnType. Not relevant for setters. */ |
873 | | false, /* isInfallible. False in setters. */ |
874 | | false, /* isMovable. Not relevant for setters. */ |
875 | | false, /* isEliminatable. Not relevant for setters. */ |
876 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
877 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
878 | | false, /* isTypedMethod. Only relevant for methods. */ |
879 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
880 | | }; |
881 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
882 | | static_assert(0 < 1, "There is no slot for us"); |
883 | | |
884 | | MOZ_CAN_RUN_SCRIPT static bool |
885 | | get_shouldRemove(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::RTCRtpTransceiver* self, JSJitGetterCallArgs args) |
886 | 0 | { |
887 | 0 | AUTO_PROFILER_LABEL_FAST("get RTCRtpTransceiver.shouldRemove", DOM, cx); |
888 | 0 |
|
889 | 0 | Maybe<JS::Rooted<JSObject*> > unwrappedObj; |
890 | 0 | bool objIsXray = xpc::WrapperFactory::IsXrayWrapper(obj); |
891 | 0 | if (objIsXray) { |
892 | 0 | unwrappedObj.emplace(cx, obj); |
893 | 0 | } |
894 | 0 | if (objIsXray) { |
895 | 0 | unwrappedObj.ref() = js::CheckedUnwrap(unwrappedObj.ref()); |
896 | 0 | if (!unwrappedObj.ref()) { |
897 | 0 | return false; |
898 | 0 | } |
899 | 0 | } |
900 | 0 | FastErrorResult rv; |
901 | 0 | bool result(self->GetShouldRemove(rv, (unwrappedObj ? js::GetNonCCWObjectRealm(*unwrappedObj) : js::GetContextRealm(cx)))); |
902 | 0 | if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) { |
903 | 0 | return false; |
904 | 0 | } |
905 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
906 | 0 | args.rval().setBoolean(result); |
907 | 0 | return true; |
908 | 0 | } |
909 | | |
910 | | MOZ_CAN_RUN_SCRIPT static bool |
911 | | set_shouldRemove(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::RTCRtpTransceiver* self, JSJitSetterCallArgs args) |
912 | 0 | { |
913 | 0 | AUTO_PROFILER_LABEL_FAST("set RTCRtpTransceiver.shouldRemove", DOM, cx); |
914 | 0 |
|
915 | 0 | Maybe<JS::Rooted<JSObject*> > unwrappedObj; |
916 | 0 | bool objIsXray = xpc::WrapperFactory::IsXrayWrapper(obj); |
917 | 0 | if (objIsXray) { |
918 | 0 | unwrappedObj.emplace(cx, obj); |
919 | 0 | } |
920 | 0 | bool arg0; |
921 | 0 | if (!ValueToPrimitive<bool, eDefault>(cx, args[0], &arg0)) { |
922 | 0 | return false; |
923 | 0 | } |
924 | 0 | if (objIsXray) { |
925 | 0 | unwrappedObj.ref() = js::CheckedUnwrap(unwrappedObj.ref()); |
926 | 0 | if (!unwrappedObj.ref()) { |
927 | 0 | return false; |
928 | 0 | } |
929 | 0 | } |
930 | 0 | FastErrorResult rv; |
931 | 0 | self->SetShouldRemove(arg0, rv, (unwrappedObj ? js::GetNonCCWObjectRealm(*unwrappedObj) : js::GetContextRealm(cx))); |
932 | 0 | if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) { |
933 | 0 | return false; |
934 | 0 | } |
935 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
936 | 0 |
|
937 | 0 | return true; |
938 | 0 | } |
939 | | |
940 | | static const JSJitInfo shouldRemove_getterinfo = { |
941 | | { (JSJitGetterOp)get_shouldRemove }, |
942 | | { prototypes::id::RTCRtpTransceiver }, |
943 | | { PrototypeTraits<prototypes::id::RTCRtpTransceiver>::Depth }, |
944 | | JSJitInfo::Getter, |
945 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
946 | | JSVAL_TYPE_BOOLEAN, /* returnType. Not relevant for setters. */ |
947 | | false, /* isInfallible. False in setters. */ |
948 | | false, /* isMovable. Not relevant for setters. */ |
949 | | false, /* isEliminatable. Not relevant for setters. */ |
950 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
951 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
952 | | false, /* isTypedMethod. Only relevant for methods. */ |
953 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
954 | | }; |
955 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
956 | | static_assert(0 < 1, "There is no slot for us"); |
957 | | static const JSJitInfo shouldRemove_setterinfo = { |
958 | | { (JSJitGetterOp)set_shouldRemove }, |
959 | | { prototypes::id::RTCRtpTransceiver }, |
960 | | { PrototypeTraits<prototypes::id::RTCRtpTransceiver>::Depth }, |
961 | | JSJitInfo::Setter, |
962 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
963 | | JSVAL_TYPE_UNDEFINED, /* returnType. Not relevant for setters. */ |
964 | | false, /* isInfallible. False in setters. */ |
965 | | false, /* isMovable. Not relevant for setters. */ |
966 | | false, /* isEliminatable. Not relevant for setters. */ |
967 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
968 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
969 | | false, /* isTypedMethod. Only relevant for methods. */ |
970 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
971 | | }; |
972 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
973 | | static_assert(0 < 1, "There is no slot for us"); |
974 | | |
975 | | MOZ_CAN_RUN_SCRIPT static bool |
976 | | setCurrentDirection(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::RTCRtpTransceiver* self, const JSJitMethodCallArgs& args) |
977 | 0 | { |
978 | 0 | AUTO_PROFILER_LABEL_FAST("RTCRtpTransceiver.setCurrentDirection", DOM, cx); |
979 | 0 |
|
980 | 0 | if (MOZ_UNLIKELY(args.length() < 1)) { |
981 | 0 | return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "RTCRtpTransceiver.setCurrentDirection"); |
982 | 0 | } |
983 | 0 | Maybe<JS::Rooted<JSObject*> > unwrappedObj; |
984 | 0 | bool objIsXray = xpc::WrapperFactory::IsXrayWrapper(obj); |
985 | 0 | if (objIsXray) { |
986 | 0 | unwrappedObj.emplace(cx, obj); |
987 | 0 | } |
988 | 0 | RTCRtpTransceiverDirection arg0; |
989 | 0 | { |
990 | 0 | int index; |
991 | 0 | if (!FindEnumStringIndex<true>(cx, args[0], RTCRtpTransceiverDirectionValues::strings, "RTCRtpTransceiverDirection", "Argument 1 of RTCRtpTransceiver.setCurrentDirection", &index)) { |
992 | 0 | return false; |
993 | 0 | } |
994 | 0 | MOZ_ASSERT(index >= 0); |
995 | 0 | arg0 = static_cast<RTCRtpTransceiverDirection>(index); |
996 | 0 | } |
997 | 0 | if (objIsXray) { |
998 | 0 | unwrappedObj.ref() = js::CheckedUnwrap(unwrappedObj.ref()); |
999 | 0 | if (!unwrappedObj.ref()) { |
1000 | 0 | return false; |
1001 | 0 | } |
1002 | 0 | } |
1003 | 0 | FastErrorResult rv; |
1004 | 0 | self->SetCurrentDirection(arg0, rv, (unwrappedObj ? js::GetNonCCWObjectRealm(*unwrappedObj) : js::GetContextRealm(cx))); |
1005 | 0 | if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) { |
1006 | 0 | return false; |
1007 | 0 | } |
1008 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
1009 | 0 | args.rval().setUndefined(); |
1010 | 0 | return true; |
1011 | 0 | } |
1012 | | |
1013 | | static const JSJitInfo setCurrentDirection_methodinfo = { |
1014 | | { (JSJitGetterOp)setCurrentDirection }, |
1015 | | { prototypes::id::RTCRtpTransceiver }, |
1016 | | { PrototypeTraits<prototypes::id::RTCRtpTransceiver>::Depth }, |
1017 | | JSJitInfo::Method, |
1018 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
1019 | | JSVAL_TYPE_UNDEFINED, /* returnType. Not relevant for setters. */ |
1020 | | false, /* isInfallible. False in setters. */ |
1021 | | false, /* isMovable. Not relevant for setters. */ |
1022 | | false, /* isEliminatable. Not relevant for setters. */ |
1023 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
1024 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
1025 | | false, /* isTypedMethod. Only relevant for methods. */ |
1026 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
1027 | | }; |
1028 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
1029 | | static_assert(0 < 1, "There is no slot for us"); |
1030 | | |
1031 | | MOZ_CAN_RUN_SCRIPT static bool |
1032 | | setDirectionInternal(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::RTCRtpTransceiver* self, const JSJitMethodCallArgs& args) |
1033 | 0 | { |
1034 | 0 | AUTO_PROFILER_LABEL_FAST("RTCRtpTransceiver.setDirectionInternal", DOM, cx); |
1035 | 0 |
|
1036 | 0 | if (MOZ_UNLIKELY(args.length() < 1)) { |
1037 | 0 | return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "RTCRtpTransceiver.setDirectionInternal"); |
1038 | 0 | } |
1039 | 0 | Maybe<JS::Rooted<JSObject*> > unwrappedObj; |
1040 | 0 | bool objIsXray = xpc::WrapperFactory::IsXrayWrapper(obj); |
1041 | 0 | if (objIsXray) { |
1042 | 0 | unwrappedObj.emplace(cx, obj); |
1043 | 0 | } |
1044 | 0 | RTCRtpTransceiverDirection arg0; |
1045 | 0 | { |
1046 | 0 | int index; |
1047 | 0 | if (!FindEnumStringIndex<true>(cx, args[0], RTCRtpTransceiverDirectionValues::strings, "RTCRtpTransceiverDirection", "Argument 1 of RTCRtpTransceiver.setDirectionInternal", &index)) { |
1048 | 0 | return false; |
1049 | 0 | } |
1050 | 0 | MOZ_ASSERT(index >= 0); |
1051 | 0 | arg0 = static_cast<RTCRtpTransceiverDirection>(index); |
1052 | 0 | } |
1053 | 0 | if (objIsXray) { |
1054 | 0 | unwrappedObj.ref() = js::CheckedUnwrap(unwrappedObj.ref()); |
1055 | 0 | if (!unwrappedObj.ref()) { |
1056 | 0 | return false; |
1057 | 0 | } |
1058 | 0 | } |
1059 | 0 | FastErrorResult rv; |
1060 | 0 | self->SetDirectionInternal(arg0, rv, (unwrappedObj ? js::GetNonCCWObjectRealm(*unwrappedObj) : js::GetContextRealm(cx))); |
1061 | 0 | if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) { |
1062 | 0 | return false; |
1063 | 0 | } |
1064 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
1065 | 0 | args.rval().setUndefined(); |
1066 | 0 | return true; |
1067 | 0 | } |
1068 | | |
1069 | | static const JSJitInfo setDirectionInternal_methodinfo = { |
1070 | | { (JSJitGetterOp)setDirectionInternal }, |
1071 | | { prototypes::id::RTCRtpTransceiver }, |
1072 | | { PrototypeTraits<prototypes::id::RTCRtpTransceiver>::Depth }, |
1073 | | JSJitInfo::Method, |
1074 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
1075 | | JSVAL_TYPE_UNDEFINED, /* returnType. Not relevant for setters. */ |
1076 | | false, /* isInfallible. False in setters. */ |
1077 | | false, /* isMovable. Not relevant for setters. */ |
1078 | | false, /* isEliminatable. Not relevant for setters. */ |
1079 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
1080 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
1081 | | false, /* isTypedMethod. Only relevant for methods. */ |
1082 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
1083 | | }; |
1084 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
1085 | | static_assert(0 < 1, "There is no slot for us"); |
1086 | | |
1087 | | MOZ_CAN_RUN_SCRIPT static bool |
1088 | | setMid(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::RTCRtpTransceiver* self, const JSJitMethodCallArgs& args) |
1089 | 0 | { |
1090 | 0 | AUTO_PROFILER_LABEL_FAST("RTCRtpTransceiver.setMid", DOM, cx); |
1091 | 0 |
|
1092 | 0 | if (MOZ_UNLIKELY(args.length() < 1)) { |
1093 | 0 | return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "RTCRtpTransceiver.setMid"); |
1094 | 0 | } |
1095 | 0 | Maybe<JS::Rooted<JSObject*> > unwrappedObj; |
1096 | 0 | bool objIsXray = xpc::WrapperFactory::IsXrayWrapper(obj); |
1097 | 0 | if (objIsXray) { |
1098 | 0 | unwrappedObj.emplace(cx, obj); |
1099 | 0 | } |
1100 | 0 | binding_detail::FakeString arg0; |
1101 | 0 | if (!ConvertJSValueToString(cx, args[0], eStringify, eStringify, arg0)) { |
1102 | 0 | return false; |
1103 | 0 | } |
1104 | 0 | if (objIsXray) { |
1105 | 0 | unwrappedObj.ref() = js::CheckedUnwrap(unwrappedObj.ref()); |
1106 | 0 | if (!unwrappedObj.ref()) { |
1107 | 0 | return false; |
1108 | 0 | } |
1109 | 0 | } |
1110 | 0 | FastErrorResult rv; |
1111 | 0 | self->SetMid(NonNullHelper(Constify(arg0)), rv, (unwrappedObj ? js::GetNonCCWObjectRealm(*unwrappedObj) : js::GetContextRealm(cx))); |
1112 | 0 | if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) { |
1113 | 0 | return false; |
1114 | 0 | } |
1115 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
1116 | 0 | args.rval().setUndefined(); |
1117 | 0 | return true; |
1118 | 0 | } |
1119 | | |
1120 | | static const JSJitInfo setMid_methodinfo = { |
1121 | | { (JSJitGetterOp)setMid }, |
1122 | | { prototypes::id::RTCRtpTransceiver }, |
1123 | | { PrototypeTraits<prototypes::id::RTCRtpTransceiver>::Depth }, |
1124 | | JSJitInfo::Method, |
1125 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
1126 | | JSVAL_TYPE_UNDEFINED, /* returnType. Not relevant for setters. */ |
1127 | | false, /* isInfallible. False in setters. */ |
1128 | | false, /* isMovable. Not relevant for setters. */ |
1129 | | false, /* isEliminatable. Not relevant for setters. */ |
1130 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
1131 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
1132 | | false, /* isTypedMethod. Only relevant for methods. */ |
1133 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
1134 | | }; |
1135 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
1136 | | static_assert(0 < 1, "There is no slot for us"); |
1137 | | |
1138 | | MOZ_CAN_RUN_SCRIPT static bool |
1139 | | unsetMid(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::RTCRtpTransceiver* self, const JSJitMethodCallArgs& args) |
1140 | 0 | { |
1141 | 0 | AUTO_PROFILER_LABEL_FAST("RTCRtpTransceiver.unsetMid", DOM, cx); |
1142 | 0 |
|
1143 | 0 | Maybe<JS::Rooted<JSObject*> > unwrappedObj; |
1144 | 0 | bool objIsXray = xpc::WrapperFactory::IsXrayWrapper(obj); |
1145 | 0 | if (objIsXray) { |
1146 | 0 | unwrappedObj.emplace(cx, obj); |
1147 | 0 | } |
1148 | 0 | if (objIsXray) { |
1149 | 0 | unwrappedObj.ref() = js::CheckedUnwrap(unwrappedObj.ref()); |
1150 | 0 | if (!unwrappedObj.ref()) { |
1151 | 0 | return false; |
1152 | 0 | } |
1153 | 0 | } |
1154 | 0 | FastErrorResult rv; |
1155 | 0 | self->UnsetMid(rv, (unwrappedObj ? js::GetNonCCWObjectRealm(*unwrappedObj) : js::GetContextRealm(cx))); |
1156 | 0 | if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) { |
1157 | 0 | return false; |
1158 | 0 | } |
1159 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
1160 | 0 | args.rval().setUndefined(); |
1161 | 0 | return true; |
1162 | 0 | } |
1163 | | |
1164 | | static const JSJitInfo unsetMid_methodinfo = { |
1165 | | { (JSJitGetterOp)unsetMid }, |
1166 | | { prototypes::id::RTCRtpTransceiver }, |
1167 | | { PrototypeTraits<prototypes::id::RTCRtpTransceiver>::Depth }, |
1168 | | JSJitInfo::Method, |
1169 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
1170 | | JSVAL_TYPE_UNDEFINED, /* returnType. Not relevant for setters. */ |
1171 | | false, /* isInfallible. False in setters. */ |
1172 | | false, /* isMovable. Not relevant for setters. */ |
1173 | | false, /* isEliminatable. Not relevant for setters. */ |
1174 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
1175 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
1176 | | false, /* isTypedMethod. Only relevant for methods. */ |
1177 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
1178 | | }; |
1179 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
1180 | | static_assert(0 < 1, "There is no slot for us"); |
1181 | | |
1182 | | MOZ_CAN_RUN_SCRIPT static bool |
1183 | | setStopped(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::RTCRtpTransceiver* self, const JSJitMethodCallArgs& args) |
1184 | 0 | { |
1185 | 0 | AUTO_PROFILER_LABEL_FAST("RTCRtpTransceiver.setStopped", DOM, cx); |
1186 | 0 |
|
1187 | 0 | Maybe<JS::Rooted<JSObject*> > unwrappedObj; |
1188 | 0 | bool objIsXray = xpc::WrapperFactory::IsXrayWrapper(obj); |
1189 | 0 | if (objIsXray) { |
1190 | 0 | unwrappedObj.emplace(cx, obj); |
1191 | 0 | } |
1192 | 0 | if (objIsXray) { |
1193 | 0 | unwrappedObj.ref() = js::CheckedUnwrap(unwrappedObj.ref()); |
1194 | 0 | if (!unwrappedObj.ref()) { |
1195 | 0 | return false; |
1196 | 0 | } |
1197 | 0 | } |
1198 | 0 | FastErrorResult rv; |
1199 | 0 | self->SetStopped(rv, (unwrappedObj ? js::GetNonCCWObjectRealm(*unwrappedObj) : js::GetContextRealm(cx))); |
1200 | 0 | if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) { |
1201 | 0 | return false; |
1202 | 0 | } |
1203 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
1204 | 0 | args.rval().setUndefined(); |
1205 | 0 | return true; |
1206 | 0 | } |
1207 | | |
1208 | | static const JSJitInfo setStopped_methodinfo = { |
1209 | | { (JSJitGetterOp)setStopped }, |
1210 | | { prototypes::id::RTCRtpTransceiver }, |
1211 | | { PrototypeTraits<prototypes::id::RTCRtpTransceiver>::Depth }, |
1212 | | JSJitInfo::Method, |
1213 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
1214 | | JSVAL_TYPE_UNDEFINED, /* returnType. Not relevant for setters. */ |
1215 | | false, /* isInfallible. False in setters. */ |
1216 | | false, /* isMovable. Not relevant for setters. */ |
1217 | | false, /* isEliminatable. Not relevant for setters. */ |
1218 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
1219 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
1220 | | false, /* isTypedMethod. Only relevant for methods. */ |
1221 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
1222 | | }; |
1223 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
1224 | | static_assert(0 < 1, "There is no slot for us"); |
1225 | | |
1226 | | MOZ_CAN_RUN_SCRIPT static bool |
1227 | | getKind(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::RTCRtpTransceiver* self, const JSJitMethodCallArgs& args) |
1228 | 0 | { |
1229 | 0 | AUTO_PROFILER_LABEL_FAST("RTCRtpTransceiver.getKind", DOM, cx); |
1230 | 0 |
|
1231 | 0 | Maybe<JS::Rooted<JSObject*> > unwrappedObj; |
1232 | 0 | bool objIsXray = xpc::WrapperFactory::IsXrayWrapper(obj); |
1233 | 0 | if (objIsXray) { |
1234 | 0 | unwrappedObj.emplace(cx, obj); |
1235 | 0 | } |
1236 | 0 | if (objIsXray) { |
1237 | 0 | unwrappedObj.ref() = js::CheckedUnwrap(unwrappedObj.ref()); |
1238 | 0 | if (!unwrappedObj.ref()) { |
1239 | 0 | return false; |
1240 | 0 | } |
1241 | 0 | } |
1242 | 0 | FastErrorResult rv; |
1243 | 0 | DOMString result; |
1244 | 0 | self->GetKind(result, rv, (unwrappedObj ? js::GetNonCCWObjectRealm(*unwrappedObj) : js::GetContextRealm(cx))); |
1245 | 0 | if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) { |
1246 | 0 | return false; |
1247 | 0 | } |
1248 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
1249 | 0 | if (!xpc::NonVoidStringToJsval(cx, result, args.rval())) { |
1250 | 0 | return false; |
1251 | 0 | } |
1252 | 0 | return true; |
1253 | 0 | } |
1254 | | |
1255 | | static const JSJitInfo getKind_methodinfo = { |
1256 | | { (JSJitGetterOp)getKind }, |
1257 | | { prototypes::id::RTCRtpTransceiver }, |
1258 | | { PrototypeTraits<prototypes::id::RTCRtpTransceiver>::Depth }, |
1259 | | JSJitInfo::Method, |
1260 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
1261 | | JSVAL_TYPE_STRING, /* returnType. Not relevant for setters. */ |
1262 | | false, /* isInfallible. False in setters. */ |
1263 | | false, /* isMovable. Not relevant for setters. */ |
1264 | | false, /* isEliminatable. Not relevant for setters. */ |
1265 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
1266 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
1267 | | false, /* isTypedMethod. Only relevant for methods. */ |
1268 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
1269 | | }; |
1270 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
1271 | | static_assert(0 < 1, "There is no slot for us"); |
1272 | | |
1273 | | MOZ_CAN_RUN_SCRIPT static bool |
1274 | | hasBeenUsedToSend(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::RTCRtpTransceiver* self, const JSJitMethodCallArgs& args) |
1275 | 0 | { |
1276 | 0 | AUTO_PROFILER_LABEL_FAST("RTCRtpTransceiver.hasBeenUsedToSend", DOM, cx); |
1277 | 0 |
|
1278 | 0 | Maybe<JS::Rooted<JSObject*> > unwrappedObj; |
1279 | 0 | bool objIsXray = xpc::WrapperFactory::IsXrayWrapper(obj); |
1280 | 0 | if (objIsXray) { |
1281 | 0 | unwrappedObj.emplace(cx, obj); |
1282 | 0 | } |
1283 | 0 | if (objIsXray) { |
1284 | 0 | unwrappedObj.ref() = js::CheckedUnwrap(unwrappedObj.ref()); |
1285 | 0 | if (!unwrappedObj.ref()) { |
1286 | 0 | return false; |
1287 | 0 | } |
1288 | 0 | } |
1289 | 0 | FastErrorResult rv; |
1290 | 0 | bool result(self->HasBeenUsedToSend(rv, (unwrappedObj ? js::GetNonCCWObjectRealm(*unwrappedObj) : js::GetContextRealm(cx)))); |
1291 | 0 | if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) { |
1292 | 0 | return false; |
1293 | 0 | } |
1294 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
1295 | 0 | args.rval().setBoolean(result); |
1296 | 0 | return true; |
1297 | 0 | } |
1298 | | |
1299 | | static const JSJitInfo hasBeenUsedToSend_methodinfo = { |
1300 | | { (JSJitGetterOp)hasBeenUsedToSend }, |
1301 | | { prototypes::id::RTCRtpTransceiver }, |
1302 | | { PrototypeTraits<prototypes::id::RTCRtpTransceiver>::Depth }, |
1303 | | JSJitInfo::Method, |
1304 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
1305 | | JSVAL_TYPE_BOOLEAN, /* returnType. Not relevant for setters. */ |
1306 | | false, /* isInfallible. False in setters. */ |
1307 | | false, /* isMovable. Not relevant for setters. */ |
1308 | | false, /* isEliminatable. Not relevant for setters. */ |
1309 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
1310 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
1311 | | false, /* isTypedMethod. Only relevant for methods. */ |
1312 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
1313 | | }; |
1314 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
1315 | | static_assert(0 < 1, "There is no slot for us"); |
1316 | | |
1317 | | MOZ_CAN_RUN_SCRIPT static bool |
1318 | | sync(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::RTCRtpTransceiver* self, const JSJitMethodCallArgs& args) |
1319 | 0 | { |
1320 | 0 | AUTO_PROFILER_LABEL_FAST("RTCRtpTransceiver.sync", DOM, cx); |
1321 | 0 |
|
1322 | 0 | Maybe<JS::Rooted<JSObject*> > unwrappedObj; |
1323 | 0 | bool objIsXray = xpc::WrapperFactory::IsXrayWrapper(obj); |
1324 | 0 | if (objIsXray) { |
1325 | 0 | unwrappedObj.emplace(cx, obj); |
1326 | 0 | } |
1327 | 0 | if (objIsXray) { |
1328 | 0 | unwrappedObj.ref() = js::CheckedUnwrap(unwrappedObj.ref()); |
1329 | 0 | if (!unwrappedObj.ref()) { |
1330 | 0 | return false; |
1331 | 0 | } |
1332 | 0 | } |
1333 | 0 | FastErrorResult rv; |
1334 | 0 | self->Sync(rv, (unwrappedObj ? js::GetNonCCWObjectRealm(*unwrappedObj) : js::GetContextRealm(cx))); |
1335 | 0 | if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) { |
1336 | 0 | return false; |
1337 | 0 | } |
1338 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
1339 | 0 | args.rval().setUndefined(); |
1340 | 0 | return true; |
1341 | 0 | } |
1342 | | |
1343 | | static const JSJitInfo sync_methodinfo = { |
1344 | | { (JSJitGetterOp)sync }, |
1345 | | { prototypes::id::RTCRtpTransceiver }, |
1346 | | { PrototypeTraits<prototypes::id::RTCRtpTransceiver>::Depth }, |
1347 | | JSJitInfo::Method, |
1348 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
1349 | | JSVAL_TYPE_UNDEFINED, /* returnType. Not relevant for setters. */ |
1350 | | false, /* isInfallible. False in setters. */ |
1351 | | false, /* isMovable. Not relevant for setters. */ |
1352 | | false, /* isEliminatable. Not relevant for setters. */ |
1353 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
1354 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
1355 | | false, /* isTypedMethod. Only relevant for methods. */ |
1356 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
1357 | | }; |
1358 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
1359 | | static_assert(0 < 1, "There is no slot for us"); |
1360 | | |
1361 | | MOZ_CAN_RUN_SCRIPT static bool |
1362 | | insertDTMF(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::RTCRtpTransceiver* self, const JSJitMethodCallArgs& args) |
1363 | 0 | { |
1364 | 0 | AUTO_PROFILER_LABEL_FAST("RTCRtpTransceiver.insertDTMF", DOM, cx); |
1365 | 0 |
|
1366 | 0 | if (MOZ_UNLIKELY(args.length() < 1)) { |
1367 | 0 | return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "RTCRtpTransceiver.insertDTMF"); |
1368 | 0 | } |
1369 | 0 | Maybe<JS::Rooted<JSObject*> > unwrappedObj; |
1370 | 0 | bool objIsXray = xpc::WrapperFactory::IsXrayWrapper(obj); |
1371 | 0 | if (objIsXray) { |
1372 | 0 | unwrappedObj.emplace(cx, obj); |
1373 | 0 | } |
1374 | 0 | binding_detail::FakeString arg0; |
1375 | 0 | if (!ConvertJSValueToString(cx, args[0], eStringify, eStringify, arg0)) { |
1376 | 0 | return false; |
1377 | 0 | } |
1378 | 0 | uint32_t arg1; |
1379 | 0 | if (args.hasDefined(1)) { |
1380 | 0 | if (!ValueToPrimitive<uint32_t, eDefault>(cx, args[1], &arg1)) { |
1381 | 0 | return false; |
1382 | 0 | } |
1383 | 0 | } else { |
1384 | 0 | arg1 = 100U; |
1385 | 0 | } |
1386 | 0 | uint32_t arg2; |
1387 | 0 | if (args.hasDefined(2)) { |
1388 | 0 | if (!ValueToPrimitive<uint32_t, eDefault>(cx, args[2], &arg2)) { |
1389 | 0 | return false; |
1390 | 0 | } |
1391 | 0 | } else { |
1392 | 0 | arg2 = 70U; |
1393 | 0 | } |
1394 | 0 | if (objIsXray) { |
1395 | 0 | unwrappedObj.ref() = js::CheckedUnwrap(unwrappedObj.ref()); |
1396 | 0 | if (!unwrappedObj.ref()) { |
1397 | 0 | return false; |
1398 | 0 | } |
1399 | 0 | } |
1400 | 0 | FastErrorResult rv; |
1401 | 0 | self->InsertDTMF(NonNullHelper(Constify(arg0)), arg1, arg2, rv, (unwrappedObj ? js::GetNonCCWObjectRealm(*unwrappedObj) : js::GetContextRealm(cx))); |
1402 | 0 | if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) { |
1403 | 0 | return false; |
1404 | 0 | } |
1405 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
1406 | 0 | args.rval().setUndefined(); |
1407 | 0 | return true; |
1408 | 0 | } |
1409 | | |
1410 | | static const JSJitInfo insertDTMF_methodinfo = { |
1411 | | { (JSJitGetterOp)insertDTMF }, |
1412 | | { prototypes::id::RTCRtpTransceiver }, |
1413 | | { PrototypeTraits<prototypes::id::RTCRtpTransceiver>::Depth }, |
1414 | | JSJitInfo::Method, |
1415 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
1416 | | JSVAL_TYPE_UNDEFINED, /* returnType. Not relevant for setters. */ |
1417 | | false, /* isInfallible. False in setters. */ |
1418 | | false, /* isMovable. Not relevant for setters. */ |
1419 | | false, /* isEliminatable. Not relevant for setters. */ |
1420 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
1421 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
1422 | | false, /* isTypedMethod. Only relevant for methods. */ |
1423 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
1424 | | }; |
1425 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
1426 | | static_assert(0 < 1, "There is no slot for us"); |
1427 | | |
1428 | | static bool |
1429 | | _addProperty(JSContext* cx, JS::Handle<JSObject*> obj, JS::Handle<jsid> id, JS::Handle<JS::Value> val) |
1430 | 0 | { |
1431 | 0 | mozilla::dom::RTCRtpTransceiver* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::RTCRtpTransceiver>(obj); |
1432 | 0 | // We don't want to preserve if we don't have a wrapper, and we |
1433 | 0 | // obviously can't preserve if we're not initialized. |
1434 | 0 | if (self && self->GetWrapperPreserveColor()) { |
1435 | 0 | PreserveWrapper(self); |
1436 | 0 | } |
1437 | 0 | return true; |
1438 | 0 | } |
1439 | | |
1440 | | static void |
1441 | | _finalize(js::FreeOp* fop, JSObject* obj) |
1442 | 0 | { |
1443 | 0 | mozilla::dom::RTCRtpTransceiver* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::RTCRtpTransceiver>(obj); |
1444 | 0 | if (self) { |
1445 | 0 | ClearWrapper(self, self, obj); |
1446 | 0 | AddForDeferredFinalization<mozilla::dom::RTCRtpTransceiver>(self); |
1447 | 0 | } |
1448 | 0 | } |
1449 | | |
1450 | | static size_t |
1451 | | _objectMoved(JSObject* obj, JSObject* old) |
1452 | 0 | { |
1453 | 0 | mozilla::dom::RTCRtpTransceiver* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::RTCRtpTransceiver>(obj); |
1454 | 0 | if (self) { |
1455 | 0 | UpdateWrapper(self, self, obj, old); |
1456 | 0 | } |
1457 | 0 |
|
1458 | 0 | return 0; |
1459 | 0 | } |
1460 | | |
1461 | | // We deliberately use brace-elision to make Visual Studio produce better initalization code. |
1462 | | #if defined(__clang__) |
1463 | | #pragma clang diagnostic push |
1464 | | #pragma clang diagnostic ignored "-Wmissing-braces" |
1465 | | #endif |
1466 | | static const JSFunctionSpec sChromeStaticMethods_specs[] = { |
1467 | | JS_FNSPEC("_create", RTCRtpTransceiver::_Create, nullptr, 2, 0, nullptr), |
1468 | | JS_FS_END |
1469 | | }; |
1470 | | #if defined(__clang__) |
1471 | | #pragma clang diagnostic pop |
1472 | | #endif |
1473 | | |
1474 | | |
1475 | | static const Prefable<const JSFunctionSpec> sChromeStaticMethods[] = { |
1476 | | { nullptr, &sChromeStaticMethods_specs[0] }, |
1477 | | { nullptr, nullptr } |
1478 | | }; |
1479 | | |
1480 | | static_assert(1 <= 1ull << NUM_BITS_PROPERTY_INFO_PREF_INDEX, |
1481 | | "We have a prefable index that is >= (1 << NUM_BITS_PROPERTY_INFO_PREF_INDEX)"); |
1482 | | static_assert(1 <= 1ull << NUM_BITS_PROPERTY_INFO_SPEC_INDEX, |
1483 | | "We have a spec index that is >= (1 << NUM_BITS_PROPERTY_INFO_SPEC_INDEX)"); |
1484 | | |
1485 | | // We deliberately use brace-elision to make Visual Studio produce better initalization code. |
1486 | | #if defined(__clang__) |
1487 | | #pragma clang diagnostic push |
1488 | | #pragma clang diagnostic ignored "-Wmissing-braces" |
1489 | | #endif |
1490 | | static const JSFunctionSpec sMethods_specs[] = { |
1491 | | JS_FNSPEC("stop", (GenericMethod<NormalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&stop_methodinfo), 0, JSPROP_ENUMERATE, nullptr), |
1492 | | JS_FS_END, |
1493 | | JS_FNSPEC("getRemoteTrackId", (GenericMethod<NormalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&getRemoteTrackId_methodinfo), 0, JSPROP_ENUMERATE, nullptr), |
1494 | | JS_FS_END |
1495 | | }; |
1496 | | #if defined(__clang__) |
1497 | | #pragma clang diagnostic pop |
1498 | | #endif |
1499 | | |
1500 | | // Can't be const because the pref-enabled boolean needs to be writable |
1501 | | static PrefableDisablers sMethods_disablers2 = { |
1502 | | true, false, 0, nullptr |
1503 | | }; |
1504 | | |
1505 | | static const Prefable<const JSFunctionSpec> sMethods[] = { |
1506 | | { nullptr, &sMethods_specs[0] }, |
1507 | | { &sMethods_disablers2, &sMethods_specs[2] }, |
1508 | | { nullptr, nullptr } |
1509 | | }; |
1510 | | |
1511 | | static_assert(2 <= 1ull << NUM_BITS_PROPERTY_INFO_PREF_INDEX, |
1512 | | "We have a prefable index that is >= (1 << NUM_BITS_PROPERTY_INFO_PREF_INDEX)"); |
1513 | | static_assert(1 <= 1ull << NUM_BITS_PROPERTY_INFO_SPEC_INDEX, |
1514 | | "We have a spec index that is >= (1 << NUM_BITS_PROPERTY_INFO_SPEC_INDEX)"); |
1515 | | |
1516 | | // We deliberately use brace-elision to make Visual Studio produce better initalization code. |
1517 | | #if defined(__clang__) |
1518 | | #pragma clang diagnostic push |
1519 | | #pragma clang diagnostic ignored "-Wmissing-braces" |
1520 | | #endif |
1521 | | static const JSFunctionSpec sChromeMethods_specs[] = { |
1522 | | JS_FNSPEC("setRemoteTrackId", (GenericMethod<NormalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&setRemoteTrackId_methodinfo), 1, JSPROP_ENUMERATE, nullptr), |
1523 | | JS_FNSPEC("remoteTrackIdIs", (GenericMethod<NormalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&remoteTrackIdIs_methodinfo), 1, JSPROP_ENUMERATE, nullptr), |
1524 | | JS_FNSPEC("setAddTrackMagic", (GenericMethod<NormalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&setAddTrackMagic_methodinfo), 0, JSPROP_ENUMERATE, nullptr), |
1525 | | JS_FNSPEC("setCurrentDirection", (GenericMethod<NormalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&setCurrentDirection_methodinfo), 1, JSPROP_ENUMERATE, nullptr), |
1526 | | JS_FNSPEC("setDirectionInternal", (GenericMethod<NormalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&setDirectionInternal_methodinfo), 1, JSPROP_ENUMERATE, nullptr), |
1527 | | JS_FNSPEC("setMid", (GenericMethod<NormalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&setMid_methodinfo), 1, JSPROP_ENUMERATE, nullptr), |
1528 | | JS_FNSPEC("unsetMid", (GenericMethod<NormalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&unsetMid_methodinfo), 0, JSPROP_ENUMERATE, nullptr), |
1529 | | JS_FNSPEC("setStopped", (GenericMethod<NormalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&setStopped_methodinfo), 0, JSPROP_ENUMERATE, nullptr), |
1530 | | JS_FNSPEC("getKind", (GenericMethod<NormalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&getKind_methodinfo), 0, JSPROP_ENUMERATE, nullptr), |
1531 | | JS_FNSPEC("hasBeenUsedToSend", (GenericMethod<NormalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&hasBeenUsedToSend_methodinfo), 0, JSPROP_ENUMERATE, nullptr), |
1532 | | JS_FNSPEC("sync", (GenericMethod<NormalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&sync_methodinfo), 0, JSPROP_ENUMERATE, nullptr), |
1533 | | JS_FNSPEC("insertDTMF", (GenericMethod<NormalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&insertDTMF_methodinfo), 1, JSPROP_ENUMERATE, nullptr), |
1534 | | JS_FS_END |
1535 | | }; |
1536 | | #if defined(__clang__) |
1537 | | #pragma clang diagnostic pop |
1538 | | #endif |
1539 | | |
1540 | | |
1541 | | static const Prefable<const JSFunctionSpec> sChromeMethods[] = { |
1542 | | { nullptr, &sChromeMethods_specs[0] }, |
1543 | | { nullptr, nullptr } |
1544 | | }; |
1545 | | |
1546 | | static_assert(1 <= 1ull << NUM_BITS_PROPERTY_INFO_PREF_INDEX, |
1547 | | "We have a prefable index that is >= (1 << NUM_BITS_PROPERTY_INFO_PREF_INDEX)"); |
1548 | | static_assert(12 <= 1ull << NUM_BITS_PROPERTY_INFO_SPEC_INDEX, |
1549 | | "We have a spec index that is >= (1 << NUM_BITS_PROPERTY_INFO_SPEC_INDEX)"); |
1550 | | |
1551 | | // We deliberately use brace-elision to make Visual Studio produce better initalization code. |
1552 | | #if defined(__clang__) |
1553 | | #pragma clang diagnostic push |
1554 | | #pragma clang diagnostic ignored "-Wmissing-braces" |
1555 | | #endif |
1556 | | static const JSPropertySpec sAttributes_specs[] = { |
1557 | | { "mid", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &mid_getterinfo, nullptr, nullptr }, |
1558 | | { "sender", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &sender_getterinfo, nullptr, nullptr }, |
1559 | | { "receiver", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &receiver_getterinfo, nullptr, nullptr }, |
1560 | | { "stopped", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &stopped_getterinfo, nullptr, nullptr }, |
1561 | | { "direction", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &direction_getterinfo, GenericSetter<NormalThisPolicy>, &direction_setterinfo }, |
1562 | | { "currentDirection", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, ¤tDirection_getterinfo, nullptr, nullptr }, |
1563 | | { nullptr, 0, nullptr, nullptr, nullptr, nullptr } |
1564 | | }; |
1565 | | #if defined(__clang__) |
1566 | | #pragma clang diagnostic pop |
1567 | | #endif |
1568 | | |
1569 | | |
1570 | | static const Prefable<const JSPropertySpec> sAttributes[] = { |
1571 | | { nullptr, &sAttributes_specs[0] }, |
1572 | | { nullptr, nullptr } |
1573 | | }; |
1574 | | |
1575 | | static_assert(1 <= 1ull << NUM_BITS_PROPERTY_INFO_PREF_INDEX, |
1576 | | "We have a prefable index that is >= (1 << NUM_BITS_PROPERTY_INFO_PREF_INDEX)"); |
1577 | | static_assert(6 <= 1ull << NUM_BITS_PROPERTY_INFO_SPEC_INDEX, |
1578 | | "We have a spec index that is >= (1 << NUM_BITS_PROPERTY_INFO_SPEC_INDEX)"); |
1579 | | |
1580 | | // We deliberately use brace-elision to make Visual Studio produce better initalization code. |
1581 | | #if defined(__clang__) |
1582 | | #pragma clang diagnostic push |
1583 | | #pragma clang diagnostic ignored "-Wmissing-braces" |
1584 | | #endif |
1585 | | static const JSPropertySpec sChromeAttributes_specs[] = { |
1586 | | { "addTrackMagic", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &addTrackMagic_getterinfo, nullptr, nullptr }, |
1587 | | { "shouldRemove", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &shouldRemove_getterinfo, GenericSetter<NormalThisPolicy>, &shouldRemove_setterinfo }, |
1588 | | { nullptr, 0, nullptr, nullptr, nullptr, nullptr } |
1589 | | }; |
1590 | | #if defined(__clang__) |
1591 | | #pragma clang diagnostic pop |
1592 | | #endif |
1593 | | |
1594 | | |
1595 | | static const Prefable<const JSPropertySpec> sChromeAttributes[] = { |
1596 | | { nullptr, &sChromeAttributes_specs[0] }, |
1597 | | { nullptr, nullptr } |
1598 | | }; |
1599 | | |
1600 | | static_assert(1 <= 1ull << NUM_BITS_PROPERTY_INFO_PREF_INDEX, |
1601 | | "We have a prefable index that is >= (1 << NUM_BITS_PROPERTY_INFO_PREF_INDEX)"); |
1602 | | static_assert(2 <= 1ull << NUM_BITS_PROPERTY_INFO_SPEC_INDEX, |
1603 | | "We have a spec index that is >= (1 << NUM_BITS_PROPERTY_INFO_SPEC_INDEX)"); |
1604 | | |
1605 | | |
1606 | | static uint16_t sNativeProperties_sortedPropertyIndices[8]; |
1607 | | static PropertyInfo sNativeProperties_propertyInfos[8]; |
1608 | | |
1609 | | static const NativePropertiesN<2> sNativeProperties = { |
1610 | | false, 0, |
1611 | | false, 0, |
1612 | | true, 0 /* sMethods */, |
1613 | | true, 1 /* sAttributes */, |
1614 | | false, 0, |
1615 | | false, 0, |
1616 | | false, 0, |
1617 | | -1, |
1618 | | 8, |
1619 | | sNativeProperties_sortedPropertyIndices, |
1620 | | { |
1621 | | { sMethods, &sNativeProperties_propertyInfos[0] }, |
1622 | | { sAttributes, &sNativeProperties_propertyInfos[2] } |
1623 | | } |
1624 | | }; |
1625 | | static_assert(8 < 1ull << CHAR_BIT * sizeof(sNativeProperties.propertyInfoCount), |
1626 | | "We have a property info count that is oversized"); |
1627 | | |
1628 | | static uint16_t sChromeOnlyNativeProperties_sortedPropertyIndices[15]; |
1629 | | static PropertyInfo sChromeOnlyNativeProperties_propertyInfos[15]; |
1630 | | |
1631 | | static const NativePropertiesN<3> sChromeOnlyNativeProperties = { |
1632 | | true, 0 /* sChromeStaticMethods */, |
1633 | | false, 0, |
1634 | | true, 1 /* sChromeMethods */, |
1635 | | true, 2 /* sChromeAttributes */, |
1636 | | false, 0, |
1637 | | false, 0, |
1638 | | false, 0, |
1639 | | -1, |
1640 | | 15, |
1641 | | sChromeOnlyNativeProperties_sortedPropertyIndices, |
1642 | | { |
1643 | | { sChromeStaticMethods, &sChromeOnlyNativeProperties_propertyInfos[0] }, |
1644 | | { sChromeMethods, &sChromeOnlyNativeProperties_propertyInfos[1] }, |
1645 | | { sChromeAttributes, &sChromeOnlyNativeProperties_propertyInfos[13] } |
1646 | | } |
1647 | | }; |
1648 | | static_assert(15 < 1ull << CHAR_BIT * sizeof(sChromeOnlyNativeProperties.propertyInfoCount), |
1649 | | "We have a property info count that is oversized"); |
1650 | | |
1651 | | static const DOMIfaceAndProtoJSClass sInterfaceObjectClass = { |
1652 | | { |
1653 | | "Function", |
1654 | | JSCLASS_IS_DOMIFACEANDPROTOJSCLASS | JSCLASS_HAS_RESERVED_SLOTS(DOM_INTERFACE_SLOTS_BASE), |
1655 | | &sBoringInterfaceObjectClassClassOps, |
1656 | | JS_NULL_CLASS_SPEC, |
1657 | | JS_NULL_CLASS_EXT, |
1658 | | &sInterfaceObjectClassObjectOps |
1659 | | }, |
1660 | | eInterface, |
1661 | | true, |
1662 | | prototypes::id::RTCRtpTransceiver, |
1663 | | PrototypeTraits<prototypes::id::RTCRtpTransceiver>::Depth, |
1664 | | sNativePropertyHooks, |
1665 | | "function RTCRtpTransceiver() {\n [native code]\n}", |
1666 | | JS::GetRealmFunctionPrototype |
1667 | | }; |
1668 | | |
1669 | | static const DOMIfaceAndProtoJSClass sPrototypeClass = { |
1670 | | { |
1671 | | "RTCRtpTransceiverPrototype", |
1672 | | JSCLASS_IS_DOMIFACEANDPROTOJSCLASS | JSCLASS_HAS_RESERVED_SLOTS(DOM_INTERFACE_PROTO_SLOTS_BASE), |
1673 | | JS_NULL_CLASS_OPS, |
1674 | | JS_NULL_CLASS_SPEC, |
1675 | | JS_NULL_CLASS_EXT, |
1676 | | JS_NULL_OBJECT_OPS |
1677 | | }, |
1678 | | eInterfacePrototype, |
1679 | | false, |
1680 | | prototypes::id::RTCRtpTransceiver, |
1681 | | PrototypeTraits<prototypes::id::RTCRtpTransceiver>::Depth, |
1682 | | sNativePropertyHooks, |
1683 | | "[object RTCRtpTransceiverPrototype]", |
1684 | | JS::GetRealmObjectPrototype |
1685 | | }; |
1686 | | |
1687 | | bool |
1688 | | ConstructorEnabled(JSContext* aCx, JS::Handle<JSObject*> aObj) |
1689 | 0 | { |
1690 | 0 | static bool sPrefValue; |
1691 | 0 | static bool sPrefCacheSetUp = false; |
1692 | 0 | if (!sPrefCacheSetUp) { |
1693 | 0 | sPrefCacheSetUp = true; |
1694 | 0 | Preferences::AddBoolVarCache(&sPrefValue, "media.peerconnection.enabled"); |
1695 | 0 | } |
1696 | 0 |
|
1697 | 0 | return sPrefValue; |
1698 | 0 | } |
1699 | | |
1700 | | static const js::ClassOps sClassOps = { |
1701 | | _addProperty, /* addProperty */ |
1702 | | nullptr, /* delProperty */ |
1703 | | nullptr, /* enumerate */ |
1704 | | nullptr, /* newEnumerate */ |
1705 | | nullptr, /* resolve */ |
1706 | | nullptr, /* mayResolve */ |
1707 | | _finalize, /* finalize */ |
1708 | | nullptr, /* call */ |
1709 | | nullptr, /* hasInstance */ |
1710 | | nullptr, /* construct */ |
1711 | | nullptr, /* trace */ |
1712 | | }; |
1713 | | |
1714 | | static const js::ClassExtension sClassExtension = { |
1715 | | nullptr, /* weakmapKeyDelegateOp */ |
1716 | | _objectMoved /* objectMovedOp */ |
1717 | | }; |
1718 | | |
1719 | | static const DOMJSClass sClass = { |
1720 | | { "RTCRtpTransceiver", |
1721 | | JSCLASS_IS_DOMJSCLASS | JSCLASS_FOREGROUND_FINALIZE | JSCLASS_HAS_RESERVED_SLOTS(1), |
1722 | | &sClassOps, |
1723 | | JS_NULL_CLASS_SPEC, |
1724 | | &sClassExtension, |
1725 | | JS_NULL_OBJECT_OPS |
1726 | | }, |
1727 | | { prototypes::id::RTCRtpTransceiver, 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 }, |
1728 | | IsBaseOf<nsISupports, mozilla::dom::RTCRtpTransceiver >::value, |
1729 | | sNativePropertyHooks, |
1730 | | FindAssociatedGlobalForNative<mozilla::dom::RTCRtpTransceiver>::Get, |
1731 | | GetProtoObjectHandle, |
1732 | | GetCCParticipant<mozilla::dom::RTCRtpTransceiver>::Get() |
1733 | | }; |
1734 | | static_assert(1 == DOM_INSTANCE_RESERVED_SLOTS, |
1735 | | "Must have the right minimal number of reserved slots."); |
1736 | | static_assert(1 >= 1, |
1737 | | "Must have enough reserved slots."); |
1738 | | |
1739 | | const JSClass* |
1740 | | GetJSClass() |
1741 | 0 | { |
1742 | 0 | return sClass.ToJSClass(); |
1743 | 0 | } |
1744 | | |
1745 | | bool |
1746 | | Wrap(JSContext* aCx, mozilla::dom::RTCRtpTransceiver* aObject, nsWrapperCache* aCache, JS::Handle<JSObject*> aGivenProto, JS::MutableHandle<JSObject*> aReflector) |
1747 | 0 | { |
1748 | 0 | static_assert(!IsBaseOf<NonRefcountedDOMObject, mozilla::dom::RTCRtpTransceiver>::value, |
1749 | 0 | "Shouldn't have wrappercached things that are not refcounted."); |
1750 | 0 | MOZ_ASSERT(static_cast<mozilla::dom::RTCRtpTransceiver*>(aObject) == |
1751 | 0 | reinterpret_cast<mozilla::dom::RTCRtpTransceiver*>(aObject), |
1752 | 0 | "Multiple inheritance for mozilla::dom::RTCRtpTransceiver is broken."); |
1753 | 0 | MOZ_ASSERT(ToSupportsIsCorrect(aObject)); |
1754 | 0 | MOZ_ASSERT_IF(aGivenProto, js::IsObjectInContextCompartment(aGivenProto, aCx)); |
1755 | 0 | MOZ_ASSERT(!aCache->GetWrapper(), |
1756 | 0 | "You should probably not be using Wrap() directly; use " |
1757 | 0 | "GetOrCreateDOMReflector instead"); |
1758 | 0 |
|
1759 | 0 | MOZ_ASSERT(ToSupportsIsOnPrimaryInheritanceChain(aObject, aCache), |
1760 | 0 | "nsISupports must be on our primary inheritance chain"); |
1761 | 0 |
|
1762 | 0 | JS::Rooted<JSObject*> global(aCx, FindAssociatedGlobal(aCx, aObject->GetParentObject())); |
1763 | 0 | if (!global) { |
1764 | 0 | return false; |
1765 | 0 | } |
1766 | 0 | MOZ_ASSERT(JS_IsGlobalObject(global)); |
1767 | 0 | MOZ_ASSERT(JS::ObjectIsNotGray(global)); |
1768 | 0 |
|
1769 | 0 | // That might have ended up wrapping us already, due to the wonders |
1770 | 0 | // of XBL. Check for that, and bail out as needed. |
1771 | 0 | aReflector.set(aCache->GetWrapper()); |
1772 | 0 | if (aReflector) { |
1773 | | #ifdef DEBUG |
1774 | | AssertReflectorHasGivenProto(aCx, aReflector, aGivenProto); |
1775 | | #endif // DEBUG |
1776 | | return true; |
1777 | 0 | } |
1778 | 0 |
|
1779 | 0 | JSAutoRealm ar(aCx, global); |
1780 | 0 | JS::Handle<JSObject*> canonicalProto = GetProtoObjectHandle(aCx); |
1781 | 0 | if (!canonicalProto) { |
1782 | 0 | return false; |
1783 | 0 | } |
1784 | 0 | JS::Rooted<JSObject*> proto(aCx); |
1785 | 0 | if (aGivenProto) { |
1786 | 0 | proto = aGivenProto; |
1787 | 0 | // Unfortunately, while aGivenProto was in the compartment of aCx |
1788 | 0 | // coming in, we changed compartments to that of "parent" so may need |
1789 | 0 | // to wrap the proto here. |
1790 | 0 | if (js::GetContextCompartment(aCx) != js::GetObjectCompartment(proto)) { |
1791 | 0 | if (!JS_WrapObject(aCx, &proto)) { |
1792 | 0 | return false; |
1793 | 0 | } |
1794 | 0 | } |
1795 | 0 | } else { |
1796 | 0 | proto = canonicalProto; |
1797 | 0 | } |
1798 | 0 |
|
1799 | 0 | BindingJSObjectCreator<mozilla::dom::RTCRtpTransceiver> creator(aCx); |
1800 | 0 | creator.CreateObject(aCx, sClass.ToJSClass(), proto, aObject, aReflector); |
1801 | 0 | if (!aReflector) { |
1802 | 0 | return false; |
1803 | 0 | } |
1804 | 0 | |
1805 | 0 | aCache->SetWrapper(aReflector); |
1806 | 0 | creator.InitializationSucceeded(); |
1807 | 0 |
|
1808 | 0 | MOZ_ASSERT(aCache->GetWrapperPreserveColor() && |
1809 | 0 | aCache->GetWrapperPreserveColor() == aReflector); |
1810 | 0 | // If proto != canonicalProto, we have to preserve our wrapper; |
1811 | 0 | // otherwise we won't be able to properly recreate it later, since |
1812 | 0 | // we won't know what proto to use. Note that we don't check |
1813 | 0 | // aGivenProto here, since it's entirely possible (and even |
1814 | 0 | // somewhat common) to have a non-null aGivenProto which is the |
1815 | 0 | // same as canonicalProto. |
1816 | 0 | if (proto != canonicalProto) { |
1817 | 0 | PreserveWrapper(aObject); |
1818 | 0 | } |
1819 | 0 |
|
1820 | 0 | return true; |
1821 | 0 | } |
1822 | | |
1823 | | const NativePropertyHooks sNativePropertyHooks[] = { { |
1824 | | nullptr, |
1825 | | nullptr, |
1826 | | nullptr, |
1827 | | { sNativeProperties.Upcast(), sChromeOnlyNativeProperties.Upcast() }, |
1828 | | prototypes::id::RTCRtpTransceiver, |
1829 | | constructors::id::RTCRtpTransceiver, |
1830 | | nullptr, |
1831 | | &DefaultXrayExpandoObjectClass |
1832 | | } }; |
1833 | | |
1834 | | void |
1835 | | CreateInterfaceObjects(JSContext* aCx, JS::Handle<JSObject*> aGlobal, ProtoAndIfaceCache& aProtoAndIfaceCache, bool aDefineOnGlobal) |
1836 | 0 | { |
1837 | 0 | JS::Rooted<JSObject*> parentProto(aCx, JS::GetRealmObjectPrototype(aCx)); |
1838 | 0 | if (!parentProto) { |
1839 | 0 | return; |
1840 | 0 | } |
1841 | 0 | |
1842 | 0 | JS::Rooted<JSObject*> constructorProto(aCx, JS::GetRealmFunctionPrototype(aCx)); |
1843 | 0 | if (!constructorProto) { |
1844 | 0 | return; |
1845 | 0 | } |
1846 | 0 | |
1847 | 0 | static bool sIdsInited = false; |
1848 | 0 | if (!sIdsInited && NS_IsMainThread()) { |
1849 | 0 | if (!InitIds(aCx, sNativeProperties.Upcast())) { |
1850 | 0 | return; |
1851 | 0 | } |
1852 | 0 | if (!InitIds(aCx, sChromeOnlyNativeProperties.Upcast())) { |
1853 | 0 | return; |
1854 | 0 | } |
1855 | 0 | sIdsInited = true; |
1856 | 0 | } |
1857 | 0 |
|
1858 | 0 | static bool sPrefCachesInited = false; |
1859 | 0 | if (!sPrefCachesInited && NS_IsMainThread()) { |
1860 | 0 | sPrefCachesInited = true; |
1861 | 0 | Preferences::AddBoolVarCache(&sMethods[1].disablers->enabled, "media.peerconnection.remoteTrackId.enabled"); |
1862 | 0 | } |
1863 | 0 |
|
1864 | 0 | JS::Heap<JSObject*>* protoCache = &aProtoAndIfaceCache.EntrySlotOrCreate(prototypes::id::RTCRtpTransceiver); |
1865 | 0 | JS::Heap<JSObject*>* interfaceCache = &aProtoAndIfaceCache.EntrySlotOrCreate(constructors::id::RTCRtpTransceiver); |
1866 | 0 | dom::CreateInterfaceObjects(aCx, aGlobal, parentProto, |
1867 | 0 | &sPrototypeClass.mBase, protoCache, |
1868 | 0 | nullptr, |
1869 | 0 | constructorProto, &sInterfaceObjectClass.mBase, 0, nullptr, |
1870 | 0 | interfaceCache, |
1871 | 0 | sNativeProperties.Upcast(), |
1872 | 0 | sChromeOnlyNativeProperties.Upcast(), |
1873 | 0 | "RTCRtpTransceiver", aDefineOnGlobal, |
1874 | 0 | nullptr, |
1875 | 0 | false); |
1876 | 0 | } |
1877 | | |
1878 | | JSObject* |
1879 | | GetConstructorObject(JSContext* aCx) |
1880 | 0 | { |
1881 | 0 | return GetConstructorObjectHandle(aCx); |
1882 | 0 | } |
1883 | | |
1884 | | } // namespace RTCRtpTransceiver_Binding |
1885 | | |
1886 | | |
1887 | | |
1888 | | void |
1889 | | RTCRtpTransceiverJSImpl::Stop(ErrorResult& aRv, JS::Realm* aRealm) |
1890 | 0 | { |
1891 | 0 | CallSetup s(this, aRv, "RTCRtpTransceiver.stop", eRethrowContentExceptions, aRealm, /* aIsJSImplementedWebIDL = */ true); |
1892 | 0 | JSContext* cx = s.GetContext(); |
1893 | 0 | if (!cx) { |
1894 | 0 | MOZ_ASSERT(aRv.Failed()); |
1895 | 0 | return; |
1896 | 0 | } |
1897 | 0 | JS::Rooted<JS::Value> rval(cx, JS::UndefinedValue()); |
1898 | 0 |
|
1899 | 0 | JS::Rooted<JS::Value> callable(cx); |
1900 | 0 | RTCRtpTransceiverAtoms* atomsCache = GetAtomCache<RTCRtpTransceiverAtoms>(cx); |
1901 | 0 | if ((!*reinterpret_cast<jsid**>(atomsCache) && !InitIds(cx, atomsCache)) || |
1902 | 0 | !GetCallableProperty(cx, atomsCache->stop_id, &callable)) { |
1903 | 0 | aRv.Throw(NS_ERROR_UNEXPECTED); |
1904 | 0 | return; |
1905 | 0 | } |
1906 | 0 | JS::Rooted<JS::Value> thisValue(cx, JS::ObjectValue(*mCallback)); |
1907 | 0 | if (!JS::Call(cx, thisValue, callable, |
1908 | 0 | JS::HandleValueArray::empty(), &rval)) { |
1909 | 0 | aRv.NoteJSContextException(cx); |
1910 | 0 | return; |
1911 | 0 | } |
1912 | 0 | } |
1913 | | |
1914 | | void |
1915 | | RTCRtpTransceiverJSImpl::SetRemoteTrackId(const nsAString& trackId, ErrorResult& aRv, JS::Realm* aRealm) |
1916 | 0 | { |
1917 | 0 | CallSetup s(this, aRv, "RTCRtpTransceiver.setRemoteTrackId", eRethrowContentExceptions, aRealm, /* aIsJSImplementedWebIDL = */ true); |
1918 | 0 | JSContext* cx = s.GetContext(); |
1919 | 0 | if (!cx) { |
1920 | 0 | MOZ_ASSERT(aRv.Failed()); |
1921 | 0 | return; |
1922 | 0 | } |
1923 | 0 | JS::Rooted<JS::Value> rval(cx, JS::UndefinedValue()); |
1924 | 0 | JS::AutoValueVector argv(cx); |
1925 | 0 | if (!argv.resize(1)) { |
1926 | 0 | aRv.Throw(NS_ERROR_OUT_OF_MEMORY); |
1927 | 0 | return; |
1928 | 0 | } |
1929 | 0 | unsigned argc = 1; |
1930 | 0 |
|
1931 | 0 | do { |
1932 | 0 | nsString mutableStr(trackId); |
1933 | 0 | if (!xpc::NonVoidStringToJsval(cx, mutableStr, argv[0])) { |
1934 | 0 | aRv.Throw(NS_ERROR_UNEXPECTED); |
1935 | 0 | return; |
1936 | 0 | } |
1937 | 0 | break; |
1938 | 0 | } while (false); |
1939 | 0 |
|
1940 | 0 | JS::Rooted<JS::Value> callable(cx); |
1941 | 0 | RTCRtpTransceiverAtoms* atomsCache = GetAtomCache<RTCRtpTransceiverAtoms>(cx); |
1942 | 0 | if ((!*reinterpret_cast<jsid**>(atomsCache) && !InitIds(cx, atomsCache)) || |
1943 | 0 | !GetCallableProperty(cx, atomsCache->setRemoteTrackId_id, &callable)) { |
1944 | 0 | aRv.Throw(NS_ERROR_UNEXPECTED); |
1945 | 0 | return; |
1946 | 0 | } |
1947 | 0 | JS::Rooted<JS::Value> thisValue(cx, JS::ObjectValue(*mCallback)); |
1948 | 0 | if (!JS::Call(cx, thisValue, callable, |
1949 | 0 | JS::HandleValueArray::subarray(argv, 0, argc), &rval)) { |
1950 | 0 | aRv.NoteJSContextException(cx); |
1951 | 0 | return; |
1952 | 0 | } |
1953 | 0 | } |
1954 | | |
1955 | | bool |
1956 | | RTCRtpTransceiverJSImpl::RemoteTrackIdIs(const nsAString& trackId, ErrorResult& aRv, JS::Realm* aRealm) |
1957 | 0 | { |
1958 | 0 | CallSetup s(this, aRv, "RTCRtpTransceiver.remoteTrackIdIs", eRethrowContentExceptions, aRealm, /* aIsJSImplementedWebIDL = */ true); |
1959 | 0 | JSContext* cx = s.GetContext(); |
1960 | 0 | if (!cx) { |
1961 | 0 | MOZ_ASSERT(aRv.Failed()); |
1962 | 0 | return bool(0); |
1963 | 0 | } |
1964 | 0 | JS::Rooted<JS::Value> rval(cx, JS::UndefinedValue()); |
1965 | 0 | JS::AutoValueVector argv(cx); |
1966 | 0 | if (!argv.resize(1)) { |
1967 | 0 | aRv.Throw(NS_ERROR_OUT_OF_MEMORY); |
1968 | 0 | return bool(0); |
1969 | 0 | } |
1970 | 0 | unsigned argc = 1; |
1971 | 0 |
|
1972 | 0 | do { |
1973 | 0 | nsString mutableStr(trackId); |
1974 | 0 | if (!xpc::NonVoidStringToJsval(cx, mutableStr, argv[0])) { |
1975 | 0 | aRv.Throw(NS_ERROR_UNEXPECTED); |
1976 | 0 | return bool(0); |
1977 | 0 | } |
1978 | 0 | break; |
1979 | 0 | } while (false); |
1980 | 0 |
|
1981 | 0 | JS::Rooted<JS::Value> callable(cx); |
1982 | 0 | RTCRtpTransceiverAtoms* atomsCache = GetAtomCache<RTCRtpTransceiverAtoms>(cx); |
1983 | 0 | if ((!*reinterpret_cast<jsid**>(atomsCache) && !InitIds(cx, atomsCache)) || |
1984 | 0 | !GetCallableProperty(cx, atomsCache->remoteTrackIdIs_id, &callable)) { |
1985 | 0 | aRv.Throw(NS_ERROR_UNEXPECTED); |
1986 | 0 | return bool(0); |
1987 | 0 | } |
1988 | 0 | JS::Rooted<JS::Value> thisValue(cx, JS::ObjectValue(*mCallback)); |
1989 | 0 | if (!JS::Call(cx, thisValue, callable, |
1990 | 0 | JS::HandleValueArray::subarray(argv, 0, argc), &rval)) { |
1991 | 0 | aRv.NoteJSContextException(cx); |
1992 | 0 | return bool(0); |
1993 | 0 | } |
1994 | 0 | bool rvalDecl; |
1995 | 0 | if (!ValueToPrimitive<bool, eDefault>(cx, rval, &rvalDecl)) { |
1996 | 0 | aRv.Throw(NS_ERROR_UNEXPECTED); |
1997 | 0 | return bool(0); |
1998 | 0 | } |
1999 | 0 | return rvalDecl; |
2000 | 0 | } |
2001 | | |
2002 | | void |
2003 | | RTCRtpTransceiverJSImpl::GetRemoteTrackId(nsString& aRetVal, ErrorResult& aRv, JS::Realm* aRealm) |
2004 | 0 | { |
2005 | 0 | CallSetup s(this, aRv, "RTCRtpTransceiver.getRemoteTrackId", eRethrowContentExceptions, aRealm, /* aIsJSImplementedWebIDL = */ true); |
2006 | 0 | JSContext* cx = s.GetContext(); |
2007 | 0 | if (!cx) { |
2008 | 0 | MOZ_ASSERT(aRv.Failed()); |
2009 | 0 | return; |
2010 | 0 | } |
2011 | 0 | JS::Rooted<JS::Value> rval(cx, JS::UndefinedValue()); |
2012 | 0 |
|
2013 | 0 | JS::Rooted<JS::Value> callable(cx); |
2014 | 0 | RTCRtpTransceiverAtoms* atomsCache = GetAtomCache<RTCRtpTransceiverAtoms>(cx); |
2015 | 0 | if ((!*reinterpret_cast<jsid**>(atomsCache) && !InitIds(cx, atomsCache)) || |
2016 | 0 | !GetCallableProperty(cx, atomsCache->getRemoteTrackId_id, &callable)) { |
2017 | 0 | aRv.Throw(NS_ERROR_UNEXPECTED); |
2018 | 0 | return; |
2019 | 0 | } |
2020 | 0 | JS::Rooted<JS::Value> thisValue(cx, JS::ObjectValue(*mCallback)); |
2021 | 0 | if (!JS::Call(cx, thisValue, callable, |
2022 | 0 | JS::HandleValueArray::empty(), &rval)) { |
2023 | 0 | aRv.NoteJSContextException(cx); |
2024 | 0 | return; |
2025 | 0 | } |
2026 | 0 | binding_detail::FakeString rvalDecl; |
2027 | 0 | if (!ConvertJSValueToString(cx, rval, eStringify, eStringify, rvalDecl)) { |
2028 | 0 | aRv.Throw(NS_ERROR_UNEXPECTED); |
2029 | 0 | return; |
2030 | 0 | } |
2031 | 0 | aRetVal = rvalDecl; |
2032 | 0 | } |
2033 | | |
2034 | | void |
2035 | | RTCRtpTransceiverJSImpl::SetAddTrackMagic(ErrorResult& aRv, JS::Realm* aRealm) |
2036 | 0 | { |
2037 | 0 | CallSetup s(this, aRv, "RTCRtpTransceiver.setAddTrackMagic", eRethrowContentExceptions, aRealm, /* aIsJSImplementedWebIDL = */ true); |
2038 | 0 | JSContext* cx = s.GetContext(); |
2039 | 0 | if (!cx) { |
2040 | 0 | MOZ_ASSERT(aRv.Failed()); |
2041 | 0 | return; |
2042 | 0 | } |
2043 | 0 | JS::Rooted<JS::Value> rval(cx, JS::UndefinedValue()); |
2044 | 0 |
|
2045 | 0 | JS::Rooted<JS::Value> callable(cx); |
2046 | 0 | RTCRtpTransceiverAtoms* atomsCache = GetAtomCache<RTCRtpTransceiverAtoms>(cx); |
2047 | 0 | if ((!*reinterpret_cast<jsid**>(atomsCache) && !InitIds(cx, atomsCache)) || |
2048 | 0 | !GetCallableProperty(cx, atomsCache->setAddTrackMagic_id, &callable)) { |
2049 | 0 | aRv.Throw(NS_ERROR_UNEXPECTED); |
2050 | 0 | return; |
2051 | 0 | } |
2052 | 0 | JS::Rooted<JS::Value> thisValue(cx, JS::ObjectValue(*mCallback)); |
2053 | 0 | if (!JS::Call(cx, thisValue, callable, |
2054 | 0 | JS::HandleValueArray::empty(), &rval)) { |
2055 | 0 | aRv.NoteJSContextException(cx); |
2056 | 0 | return; |
2057 | 0 | } |
2058 | 0 | } |
2059 | | |
2060 | | void |
2061 | | RTCRtpTransceiverJSImpl::SetCurrentDirection(RTCRtpTransceiverDirection direction, ErrorResult& aRv, JS::Realm* aRealm) |
2062 | 0 | { |
2063 | 0 | CallSetup s(this, aRv, "RTCRtpTransceiver.setCurrentDirection", eRethrowContentExceptions, aRealm, /* aIsJSImplementedWebIDL = */ true); |
2064 | 0 | JSContext* cx = s.GetContext(); |
2065 | 0 | if (!cx) { |
2066 | 0 | MOZ_ASSERT(aRv.Failed()); |
2067 | 0 | return; |
2068 | 0 | } |
2069 | 0 | JS::Rooted<JS::Value> rval(cx, JS::UndefinedValue()); |
2070 | 0 | JS::AutoValueVector argv(cx); |
2071 | 0 | if (!argv.resize(1)) { |
2072 | 0 | aRv.Throw(NS_ERROR_OUT_OF_MEMORY); |
2073 | 0 | return; |
2074 | 0 | } |
2075 | 0 | unsigned argc = 1; |
2076 | 0 |
|
2077 | 0 | do { |
2078 | 0 | if (!ToJSValue(cx, direction, argv[0])) { |
2079 | 0 | aRv.Throw(NS_ERROR_UNEXPECTED); |
2080 | 0 | return; |
2081 | 0 | } |
2082 | 0 | break; |
2083 | 0 | } while (false); |
2084 | 0 |
|
2085 | 0 | JS::Rooted<JS::Value> callable(cx); |
2086 | 0 | RTCRtpTransceiverAtoms* atomsCache = GetAtomCache<RTCRtpTransceiverAtoms>(cx); |
2087 | 0 | if ((!*reinterpret_cast<jsid**>(atomsCache) && !InitIds(cx, atomsCache)) || |
2088 | 0 | !GetCallableProperty(cx, atomsCache->setCurrentDirection_id, &callable)) { |
2089 | 0 | aRv.Throw(NS_ERROR_UNEXPECTED); |
2090 | 0 | return; |
2091 | 0 | } |
2092 | 0 | JS::Rooted<JS::Value> thisValue(cx, JS::ObjectValue(*mCallback)); |
2093 | 0 | if (!JS::Call(cx, thisValue, callable, |
2094 | 0 | JS::HandleValueArray::subarray(argv, 0, argc), &rval)) { |
2095 | 0 | aRv.NoteJSContextException(cx); |
2096 | 0 | return; |
2097 | 0 | } |
2098 | 0 | } |
2099 | | |
2100 | | void |
2101 | | RTCRtpTransceiverJSImpl::SetDirectionInternal(RTCRtpTransceiverDirection direction, ErrorResult& aRv, JS::Realm* aRealm) |
2102 | 0 | { |
2103 | 0 | CallSetup s(this, aRv, "RTCRtpTransceiver.setDirectionInternal", eRethrowContentExceptions, aRealm, /* aIsJSImplementedWebIDL = */ true); |
2104 | 0 | JSContext* cx = s.GetContext(); |
2105 | 0 | if (!cx) { |
2106 | 0 | MOZ_ASSERT(aRv.Failed()); |
2107 | 0 | return; |
2108 | 0 | } |
2109 | 0 | JS::Rooted<JS::Value> rval(cx, JS::UndefinedValue()); |
2110 | 0 | JS::AutoValueVector argv(cx); |
2111 | 0 | if (!argv.resize(1)) { |
2112 | 0 | aRv.Throw(NS_ERROR_OUT_OF_MEMORY); |
2113 | 0 | return; |
2114 | 0 | } |
2115 | 0 | unsigned argc = 1; |
2116 | 0 |
|
2117 | 0 | do { |
2118 | 0 | if (!ToJSValue(cx, direction, argv[0])) { |
2119 | 0 | aRv.Throw(NS_ERROR_UNEXPECTED); |
2120 | 0 | return; |
2121 | 0 | } |
2122 | 0 | break; |
2123 | 0 | } while (false); |
2124 | 0 |
|
2125 | 0 | JS::Rooted<JS::Value> callable(cx); |
2126 | 0 | RTCRtpTransceiverAtoms* atomsCache = GetAtomCache<RTCRtpTransceiverAtoms>(cx); |
2127 | 0 | if ((!*reinterpret_cast<jsid**>(atomsCache) && !InitIds(cx, atomsCache)) || |
2128 | 0 | !GetCallableProperty(cx, atomsCache->setDirectionInternal_id, &callable)) { |
2129 | 0 | aRv.Throw(NS_ERROR_UNEXPECTED); |
2130 | 0 | return; |
2131 | 0 | } |
2132 | 0 | JS::Rooted<JS::Value> thisValue(cx, JS::ObjectValue(*mCallback)); |
2133 | 0 | if (!JS::Call(cx, thisValue, callable, |
2134 | 0 | JS::HandleValueArray::subarray(argv, 0, argc), &rval)) { |
2135 | 0 | aRv.NoteJSContextException(cx); |
2136 | 0 | return; |
2137 | 0 | } |
2138 | 0 | } |
2139 | | |
2140 | | void |
2141 | | RTCRtpTransceiverJSImpl::SetMid(const nsAString& mid, ErrorResult& aRv, JS::Realm* aRealm) |
2142 | 0 | { |
2143 | 0 | CallSetup s(this, aRv, "RTCRtpTransceiver.setMid", eRethrowContentExceptions, aRealm, /* aIsJSImplementedWebIDL = */ true); |
2144 | 0 | JSContext* cx = s.GetContext(); |
2145 | 0 | if (!cx) { |
2146 | 0 | MOZ_ASSERT(aRv.Failed()); |
2147 | 0 | return; |
2148 | 0 | } |
2149 | 0 | JS::Rooted<JS::Value> rval(cx, JS::UndefinedValue()); |
2150 | 0 | JS::AutoValueVector argv(cx); |
2151 | 0 | if (!argv.resize(1)) { |
2152 | 0 | aRv.Throw(NS_ERROR_OUT_OF_MEMORY); |
2153 | 0 | return; |
2154 | 0 | } |
2155 | 0 | unsigned argc = 1; |
2156 | 0 |
|
2157 | 0 | do { |
2158 | 0 | nsString mutableStr(mid); |
2159 | 0 | if (!xpc::NonVoidStringToJsval(cx, mutableStr, argv[0])) { |
2160 | 0 | aRv.Throw(NS_ERROR_UNEXPECTED); |
2161 | 0 | return; |
2162 | 0 | } |
2163 | 0 | break; |
2164 | 0 | } while (false); |
2165 | 0 |
|
2166 | 0 | JS::Rooted<JS::Value> callable(cx); |
2167 | 0 | RTCRtpTransceiverAtoms* atomsCache = GetAtomCache<RTCRtpTransceiverAtoms>(cx); |
2168 | 0 | if ((!*reinterpret_cast<jsid**>(atomsCache) && !InitIds(cx, atomsCache)) || |
2169 | 0 | !GetCallableProperty(cx, atomsCache->setMid_id, &callable)) { |
2170 | 0 | aRv.Throw(NS_ERROR_UNEXPECTED); |
2171 | 0 | return; |
2172 | 0 | } |
2173 | 0 | JS::Rooted<JS::Value> thisValue(cx, JS::ObjectValue(*mCallback)); |
2174 | 0 | if (!JS::Call(cx, thisValue, callable, |
2175 | 0 | JS::HandleValueArray::subarray(argv, 0, argc), &rval)) { |
2176 | 0 | aRv.NoteJSContextException(cx); |
2177 | 0 | return; |
2178 | 0 | } |
2179 | 0 | } |
2180 | | |
2181 | | void |
2182 | | RTCRtpTransceiverJSImpl::UnsetMid(ErrorResult& aRv, JS::Realm* aRealm) |
2183 | 0 | { |
2184 | 0 | CallSetup s(this, aRv, "RTCRtpTransceiver.unsetMid", eRethrowContentExceptions, aRealm, /* aIsJSImplementedWebIDL = */ true); |
2185 | 0 | JSContext* cx = s.GetContext(); |
2186 | 0 | if (!cx) { |
2187 | 0 | MOZ_ASSERT(aRv.Failed()); |
2188 | 0 | return; |
2189 | 0 | } |
2190 | 0 | JS::Rooted<JS::Value> rval(cx, JS::UndefinedValue()); |
2191 | 0 |
|
2192 | 0 | JS::Rooted<JS::Value> callable(cx); |
2193 | 0 | RTCRtpTransceiverAtoms* atomsCache = GetAtomCache<RTCRtpTransceiverAtoms>(cx); |
2194 | 0 | if ((!*reinterpret_cast<jsid**>(atomsCache) && !InitIds(cx, atomsCache)) || |
2195 | 0 | !GetCallableProperty(cx, atomsCache->unsetMid_id, &callable)) { |
2196 | 0 | aRv.Throw(NS_ERROR_UNEXPECTED); |
2197 | 0 | return; |
2198 | 0 | } |
2199 | 0 | JS::Rooted<JS::Value> thisValue(cx, JS::ObjectValue(*mCallback)); |
2200 | 0 | if (!JS::Call(cx, thisValue, callable, |
2201 | 0 | JS::HandleValueArray::empty(), &rval)) { |
2202 | 0 | aRv.NoteJSContextException(cx); |
2203 | 0 | return; |
2204 | 0 | } |
2205 | 0 | } |
2206 | | |
2207 | | void |
2208 | | RTCRtpTransceiverJSImpl::SetStopped(ErrorResult& aRv, JS::Realm* aRealm) |
2209 | 0 | { |
2210 | 0 | CallSetup s(this, aRv, "RTCRtpTransceiver.setStopped", eRethrowContentExceptions, aRealm, /* aIsJSImplementedWebIDL = */ true); |
2211 | 0 | JSContext* cx = s.GetContext(); |
2212 | 0 | if (!cx) { |
2213 | 0 | MOZ_ASSERT(aRv.Failed()); |
2214 | 0 | return; |
2215 | 0 | } |
2216 | 0 | JS::Rooted<JS::Value> rval(cx, JS::UndefinedValue()); |
2217 | 0 |
|
2218 | 0 | JS::Rooted<JS::Value> callable(cx); |
2219 | 0 | RTCRtpTransceiverAtoms* atomsCache = GetAtomCache<RTCRtpTransceiverAtoms>(cx); |
2220 | 0 | if ((!*reinterpret_cast<jsid**>(atomsCache) && !InitIds(cx, atomsCache)) || |
2221 | 0 | !GetCallableProperty(cx, atomsCache->setStopped_id, &callable)) { |
2222 | 0 | aRv.Throw(NS_ERROR_UNEXPECTED); |
2223 | 0 | return; |
2224 | 0 | } |
2225 | 0 | JS::Rooted<JS::Value> thisValue(cx, JS::ObjectValue(*mCallback)); |
2226 | 0 | if (!JS::Call(cx, thisValue, callable, |
2227 | 0 | JS::HandleValueArray::empty(), &rval)) { |
2228 | 0 | aRv.NoteJSContextException(cx); |
2229 | 0 | return; |
2230 | 0 | } |
2231 | 0 | } |
2232 | | |
2233 | | void |
2234 | | RTCRtpTransceiverJSImpl::GetKind(nsString& aRetVal, ErrorResult& aRv, JS::Realm* aRealm) |
2235 | 0 | { |
2236 | 0 | CallSetup s(this, aRv, "RTCRtpTransceiver.getKind", eRethrowContentExceptions, aRealm, /* aIsJSImplementedWebIDL = */ true); |
2237 | 0 | JSContext* cx = s.GetContext(); |
2238 | 0 | if (!cx) { |
2239 | 0 | MOZ_ASSERT(aRv.Failed()); |
2240 | 0 | return; |
2241 | 0 | } |
2242 | 0 | JS::Rooted<JS::Value> rval(cx, JS::UndefinedValue()); |
2243 | 0 |
|
2244 | 0 | JS::Rooted<JS::Value> callable(cx); |
2245 | 0 | RTCRtpTransceiverAtoms* atomsCache = GetAtomCache<RTCRtpTransceiverAtoms>(cx); |
2246 | 0 | if ((!*reinterpret_cast<jsid**>(atomsCache) && !InitIds(cx, atomsCache)) || |
2247 | 0 | !GetCallableProperty(cx, atomsCache->getKind_id, &callable)) { |
2248 | 0 | aRv.Throw(NS_ERROR_UNEXPECTED); |
2249 | 0 | return; |
2250 | 0 | } |
2251 | 0 | JS::Rooted<JS::Value> thisValue(cx, JS::ObjectValue(*mCallback)); |
2252 | 0 | if (!JS::Call(cx, thisValue, callable, |
2253 | 0 | JS::HandleValueArray::empty(), &rval)) { |
2254 | 0 | aRv.NoteJSContextException(cx); |
2255 | 0 | return; |
2256 | 0 | } |
2257 | 0 | binding_detail::FakeString rvalDecl; |
2258 | 0 | if (!ConvertJSValueToString(cx, rval, eStringify, eStringify, rvalDecl)) { |
2259 | 0 | aRv.Throw(NS_ERROR_UNEXPECTED); |
2260 | 0 | return; |
2261 | 0 | } |
2262 | 0 | aRetVal = rvalDecl; |
2263 | 0 | } |
2264 | | |
2265 | | bool |
2266 | | RTCRtpTransceiverJSImpl::HasBeenUsedToSend(ErrorResult& aRv, JS::Realm* aRealm) |
2267 | 0 | { |
2268 | 0 | CallSetup s(this, aRv, "RTCRtpTransceiver.hasBeenUsedToSend", eRethrowContentExceptions, aRealm, /* aIsJSImplementedWebIDL = */ true); |
2269 | 0 | JSContext* cx = s.GetContext(); |
2270 | 0 | if (!cx) { |
2271 | 0 | MOZ_ASSERT(aRv.Failed()); |
2272 | 0 | return bool(0); |
2273 | 0 | } |
2274 | 0 | JS::Rooted<JS::Value> rval(cx, JS::UndefinedValue()); |
2275 | 0 |
|
2276 | 0 | JS::Rooted<JS::Value> callable(cx); |
2277 | 0 | RTCRtpTransceiverAtoms* atomsCache = GetAtomCache<RTCRtpTransceiverAtoms>(cx); |
2278 | 0 | if ((!*reinterpret_cast<jsid**>(atomsCache) && !InitIds(cx, atomsCache)) || |
2279 | 0 | !GetCallableProperty(cx, atomsCache->hasBeenUsedToSend_id, &callable)) { |
2280 | 0 | aRv.Throw(NS_ERROR_UNEXPECTED); |
2281 | 0 | return bool(0); |
2282 | 0 | } |
2283 | 0 | JS::Rooted<JS::Value> thisValue(cx, JS::ObjectValue(*mCallback)); |
2284 | 0 | if (!JS::Call(cx, thisValue, callable, |
2285 | 0 | JS::HandleValueArray::empty(), &rval)) { |
2286 | 0 | aRv.NoteJSContextException(cx); |
2287 | 0 | return bool(0); |
2288 | 0 | } |
2289 | 0 | bool rvalDecl; |
2290 | 0 | if (!ValueToPrimitive<bool, eDefault>(cx, rval, &rvalDecl)) { |
2291 | 0 | aRv.Throw(NS_ERROR_UNEXPECTED); |
2292 | 0 | return bool(0); |
2293 | 0 | } |
2294 | 0 | return rvalDecl; |
2295 | 0 | } |
2296 | | |
2297 | | void |
2298 | | RTCRtpTransceiverJSImpl::Sync(ErrorResult& aRv, JS::Realm* aRealm) |
2299 | 0 | { |
2300 | 0 | CallSetup s(this, aRv, "RTCRtpTransceiver.sync", eRethrowContentExceptions, aRealm, /* aIsJSImplementedWebIDL = */ true); |
2301 | 0 | JSContext* cx = s.GetContext(); |
2302 | 0 | if (!cx) { |
2303 | 0 | MOZ_ASSERT(aRv.Failed()); |
2304 | 0 | return; |
2305 | 0 | } |
2306 | 0 | JS::Rooted<JS::Value> rval(cx, JS::UndefinedValue()); |
2307 | 0 |
|
2308 | 0 | JS::Rooted<JS::Value> callable(cx); |
2309 | 0 | RTCRtpTransceiverAtoms* atomsCache = GetAtomCache<RTCRtpTransceiverAtoms>(cx); |
2310 | 0 | if ((!*reinterpret_cast<jsid**>(atomsCache) && !InitIds(cx, atomsCache)) || |
2311 | 0 | !GetCallableProperty(cx, atomsCache->sync_id, &callable)) { |
2312 | 0 | aRv.Throw(NS_ERROR_UNEXPECTED); |
2313 | 0 | return; |
2314 | 0 | } |
2315 | 0 | JS::Rooted<JS::Value> thisValue(cx, JS::ObjectValue(*mCallback)); |
2316 | 0 | if (!JS::Call(cx, thisValue, callable, |
2317 | 0 | JS::HandleValueArray::empty(), &rval)) { |
2318 | 0 | aRv.NoteJSContextException(cx); |
2319 | 0 | return; |
2320 | 0 | } |
2321 | 0 | } |
2322 | | |
2323 | | void |
2324 | | RTCRtpTransceiverJSImpl::InsertDTMF(const nsAString& tones, uint32_t duration, uint32_t interToneGap, ErrorResult& aRv, JS::Realm* aRealm) |
2325 | 0 | { |
2326 | 0 | CallSetup s(this, aRv, "RTCRtpTransceiver.insertDTMF", eRethrowContentExceptions, aRealm, /* aIsJSImplementedWebIDL = */ true); |
2327 | 0 | JSContext* cx = s.GetContext(); |
2328 | 0 | if (!cx) { |
2329 | 0 | MOZ_ASSERT(aRv.Failed()); |
2330 | 0 | return; |
2331 | 0 | } |
2332 | 0 | JS::Rooted<JS::Value> rval(cx, JS::UndefinedValue()); |
2333 | 0 | JS::AutoValueVector argv(cx); |
2334 | 0 | if (!argv.resize(3)) { |
2335 | 0 | aRv.Throw(NS_ERROR_OUT_OF_MEMORY); |
2336 | 0 | return; |
2337 | 0 | } |
2338 | 0 | unsigned argc = 3; |
2339 | 0 |
|
2340 | 0 | do { |
2341 | 0 | argv[2].setNumber(interToneGap); |
2342 | 0 | break; |
2343 | 0 | } while (false); |
2344 | 0 |
|
2345 | 0 | do { |
2346 | 0 | argv[1].setNumber(duration); |
2347 | 0 | break; |
2348 | 0 | } while (false); |
2349 | 0 |
|
2350 | 0 | do { |
2351 | 0 | nsString mutableStr(tones); |
2352 | 0 | if (!xpc::NonVoidStringToJsval(cx, mutableStr, argv[0])) { |
2353 | 0 | aRv.Throw(NS_ERROR_UNEXPECTED); |
2354 | 0 | return; |
2355 | 0 | } |
2356 | 0 | break; |
2357 | 0 | } while (false); |
2358 | 0 |
|
2359 | 0 | JS::Rooted<JS::Value> callable(cx); |
2360 | 0 | RTCRtpTransceiverAtoms* atomsCache = GetAtomCache<RTCRtpTransceiverAtoms>(cx); |
2361 | 0 | if ((!*reinterpret_cast<jsid**>(atomsCache) && !InitIds(cx, atomsCache)) || |
2362 | 0 | !GetCallableProperty(cx, atomsCache->insertDTMF_id, &callable)) { |
2363 | 0 | aRv.Throw(NS_ERROR_UNEXPECTED); |
2364 | 0 | return; |
2365 | 0 | } |
2366 | 0 | JS::Rooted<JS::Value> thisValue(cx, JS::ObjectValue(*mCallback)); |
2367 | 0 | if (!JS::Call(cx, thisValue, callable, |
2368 | 0 | JS::HandleValueArray::subarray(argv, 0, argc), &rval)) { |
2369 | 0 | aRv.NoteJSContextException(cx); |
2370 | 0 | return; |
2371 | 0 | } |
2372 | 0 | } |
2373 | | |
2374 | | bool |
2375 | | RTCRtpTransceiverJSImpl::InitIds(JSContext* cx, RTCRtpTransceiverAtoms* atomsCache) |
2376 | 0 | { |
2377 | 0 | MOZ_ASSERT(!*reinterpret_cast<jsid**>(atomsCache)); |
2378 | 0 |
|
2379 | 0 | // Initialize these in reverse order so that any failure leaves the first one |
2380 | 0 | // uninitialized. |
2381 | 0 | if (!atomsCache->insertDTMF_id.init(cx, "insertDTMF") || |
2382 | 0 | !atomsCache->sync_id.init(cx, "sync") || |
2383 | 0 | !atomsCache->hasBeenUsedToSend_id.init(cx, "hasBeenUsedToSend") || |
2384 | 0 | !atomsCache->getKind_id.init(cx, "getKind") || |
2385 | 0 | !atomsCache->setStopped_id.init(cx, "setStopped") || |
2386 | 0 | !atomsCache->unsetMid_id.init(cx, "unsetMid") || |
2387 | 0 | !atomsCache->setMid_id.init(cx, "setMid") || |
2388 | 0 | !atomsCache->setDirectionInternal_id.init(cx, "setDirectionInternal") || |
2389 | 0 | !atomsCache->setCurrentDirection_id.init(cx, "setCurrentDirection") || |
2390 | 0 | !atomsCache->shouldRemove_id.init(cx, "shouldRemove") || |
2391 | 0 | !atomsCache->addTrackMagic_id.init(cx, "addTrackMagic") || |
2392 | 0 | !atomsCache->setAddTrackMagic_id.init(cx, "setAddTrackMagic") || |
2393 | 0 | !atomsCache->getRemoteTrackId_id.init(cx, "getRemoteTrackId") || |
2394 | 0 | !atomsCache->remoteTrackIdIs_id.init(cx, "remoteTrackIdIs") || |
2395 | 0 | !atomsCache->setRemoteTrackId_id.init(cx, "setRemoteTrackId") || |
2396 | 0 | !atomsCache->stop_id.init(cx, "stop") || |
2397 | 0 | !atomsCache->currentDirection_id.init(cx, "currentDirection") || |
2398 | 0 | !atomsCache->direction_id.init(cx, "direction") || |
2399 | 0 | !atomsCache->stopped_id.init(cx, "stopped") || |
2400 | 0 | !atomsCache->receiver_id.init(cx, "receiver") || |
2401 | 0 | !atomsCache->sender_id.init(cx, "sender") || |
2402 | 0 | !atomsCache->mid_id.init(cx, "mid")) { |
2403 | 0 | return false; |
2404 | 0 | } |
2405 | 0 | return true; |
2406 | 0 | } |
2407 | | |
2408 | | |
2409 | | void |
2410 | | RTCRtpTransceiverJSImpl::GetMid(nsString& aRetVal, ErrorResult& aRv, JS::Realm* aRealm) |
2411 | 0 | { |
2412 | 0 | CallSetup s(this, aRv, "RTCRtpTransceiver.mid", eRethrowContentExceptions, aRealm, /* aIsJSImplementedWebIDL = */ true); |
2413 | 0 | JSContext* cx = s.GetContext(); |
2414 | 0 | if (!cx) { |
2415 | 0 | MOZ_ASSERT(aRv.Failed()); |
2416 | 0 | return; |
2417 | 0 | } |
2418 | 0 | JS::Rooted<JS::Value> rval(cx, JS::UndefinedValue()); |
2419 | 0 |
|
2420 | 0 | JS::Rooted<JSObject *> callback(cx, mCallback); |
2421 | 0 | RTCRtpTransceiverAtoms* atomsCache = GetAtomCache<RTCRtpTransceiverAtoms>(cx); |
2422 | 0 | if ((!*reinterpret_cast<jsid**>(atomsCache) && !InitIds(cx, atomsCache)) || |
2423 | 0 | !JS_GetPropertyById(cx, callback, atomsCache->mid_id, &rval)) { |
2424 | 0 | aRv.Throw(NS_ERROR_UNEXPECTED); |
2425 | 0 | return; |
2426 | 0 | } |
2427 | 0 | binding_detail::FakeString rvalDecl; |
2428 | 0 | if (!ConvertJSValueToString(cx, rval, eNull, eNull, rvalDecl)) { |
2429 | 0 | aRv.Throw(NS_ERROR_UNEXPECTED); |
2430 | 0 | return; |
2431 | 0 | } |
2432 | 0 | aRetVal = rvalDecl; |
2433 | 0 | } |
2434 | | |
2435 | | already_AddRefed<RTCRtpSender> |
2436 | | RTCRtpTransceiverJSImpl::GetSender(ErrorResult& aRv, JS::Realm* aRealm) |
2437 | 0 | { |
2438 | 0 | CallSetup s(this, aRv, "RTCRtpTransceiver.sender", eRethrowContentExceptions, aRealm, /* aIsJSImplementedWebIDL = */ true); |
2439 | 0 | JSContext* cx = s.GetContext(); |
2440 | 0 | if (!cx) { |
2441 | 0 | MOZ_ASSERT(aRv.Failed()); |
2442 | 0 | return nullptr; |
2443 | 0 | } |
2444 | 0 | JS::Rooted<JS::Value> rval(cx, JS::UndefinedValue()); |
2445 | 0 |
|
2446 | 0 | JS::Rooted<JSObject *> callback(cx, mCallback); |
2447 | 0 | RTCRtpTransceiverAtoms* atomsCache = GetAtomCache<RTCRtpTransceiverAtoms>(cx); |
2448 | 0 | if ((!*reinterpret_cast<jsid**>(atomsCache) && !InitIds(cx, atomsCache)) || |
2449 | 0 | !JS_GetPropertyById(cx, callback, atomsCache->sender_id, &rval)) { |
2450 | 0 | aRv.Throw(NS_ERROR_UNEXPECTED); |
2451 | 0 | return nullptr; |
2452 | 0 | } |
2453 | 0 | RefPtr<mozilla::dom::RTCRtpSender> rvalDecl; |
2454 | 0 | if (rval.isObject()) { |
2455 | 0 | static_assert(IsRefcounted<mozilla::dom::RTCRtpSender>::value, "We can only store refcounted classes.");{ |
2456 | 0 | nsresult rv = UnwrapObject<prototypes::id::RTCRtpSender, mozilla::dom::RTCRtpSender>(rval, rvalDecl); |
2457 | 0 | if (NS_FAILED(rv)) { |
2458 | 0 | // Be careful to not wrap random DOM objects here, even if |
2459 | 0 | // they're wrapped in opaque security wrappers for some reason. |
2460 | 0 | // XXXbz Wish we could check for a JS-implemented object |
2461 | 0 | // that already has a content reflection... |
2462 | 0 | if (!IsDOMObject(js::UncheckedUnwrap(&rval.toObject()))) { |
2463 | 0 | nsCOMPtr<nsIGlobalObject> contentGlobal; |
2464 | 0 | JS::Handle<JSObject*> callback = CallbackOrNull(); |
2465 | 0 | if (!callback || |
2466 | 0 | !GetContentGlobalForJSImplementedObject(cx, callback, getter_AddRefs(contentGlobal))) { |
2467 | 0 | aRv.Throw(NS_ERROR_UNEXPECTED); |
2468 | 0 | return nullptr; |
2469 | 0 | } |
2470 | 0 | JS::Rooted<JSObject*> jsImplSourceObj(cx, &rval.toObject()); |
2471 | 0 | MOZ_RELEASE_ASSERT(!js::IsWrapper(jsImplSourceObj), |
2472 | 0 | "Don't return JS implementations from other compartments"); |
2473 | 0 | JS::Rooted<JSObject*> jsImplSourceGlobal(cx, JS::GetNonCCWObjectGlobal(jsImplSourceObj)); |
2474 | 0 | rvalDecl = new mozilla::dom::RTCRtpSender(jsImplSourceObj, jsImplSourceGlobal, contentGlobal); |
2475 | 0 | } else { |
2476 | 0 | ThrowErrorMessage(cx, MSG_DOES_NOT_IMPLEMENT_INTERFACE, "Return value of RTCRtpTransceiver.sender", "RTCRtpSender"); |
2477 | 0 | aRv.Throw(NS_ERROR_UNEXPECTED); |
2478 | 0 | return nullptr; |
2479 | 0 | } |
2480 | 0 | } |
2481 | 0 | } |
2482 | 0 | } else { |
2483 | 0 | ThrowErrorMessage(cx, MSG_NOT_OBJECT, "Return value of RTCRtpTransceiver.sender"); |
2484 | 0 | aRv.Throw(NS_ERROR_UNEXPECTED); |
2485 | 0 | return nullptr; |
2486 | 0 | } |
2487 | 0 | return rvalDecl.forget(); |
2488 | 0 | } |
2489 | | |
2490 | | already_AddRefed<RTCRtpReceiver> |
2491 | | RTCRtpTransceiverJSImpl::GetReceiver(ErrorResult& aRv, JS::Realm* aRealm) |
2492 | 0 | { |
2493 | 0 | CallSetup s(this, aRv, "RTCRtpTransceiver.receiver", eRethrowContentExceptions, aRealm, /* aIsJSImplementedWebIDL = */ true); |
2494 | 0 | JSContext* cx = s.GetContext(); |
2495 | 0 | if (!cx) { |
2496 | 0 | MOZ_ASSERT(aRv.Failed()); |
2497 | 0 | return nullptr; |
2498 | 0 | } |
2499 | 0 | JS::Rooted<JS::Value> rval(cx, JS::UndefinedValue()); |
2500 | 0 |
|
2501 | 0 | JS::Rooted<JSObject *> callback(cx, mCallback); |
2502 | 0 | RTCRtpTransceiverAtoms* atomsCache = GetAtomCache<RTCRtpTransceiverAtoms>(cx); |
2503 | 0 | if ((!*reinterpret_cast<jsid**>(atomsCache) && !InitIds(cx, atomsCache)) || |
2504 | 0 | !JS_GetPropertyById(cx, callback, atomsCache->receiver_id, &rval)) { |
2505 | 0 | aRv.Throw(NS_ERROR_UNEXPECTED); |
2506 | 0 | return nullptr; |
2507 | 0 | } |
2508 | 0 | RefPtr<mozilla::dom::RTCRtpReceiver> rvalDecl; |
2509 | 0 | if (rval.isObject()) { |
2510 | 0 | static_assert(IsRefcounted<mozilla::dom::RTCRtpReceiver>::value, "We can only store refcounted classes.");{ |
2511 | 0 | nsresult rv = UnwrapObject<prototypes::id::RTCRtpReceiver, mozilla::dom::RTCRtpReceiver>(rval, rvalDecl); |
2512 | 0 | if (NS_FAILED(rv)) { |
2513 | 0 | // Be careful to not wrap random DOM objects here, even if |
2514 | 0 | // they're wrapped in opaque security wrappers for some reason. |
2515 | 0 | // XXXbz Wish we could check for a JS-implemented object |
2516 | 0 | // that already has a content reflection... |
2517 | 0 | if (!IsDOMObject(js::UncheckedUnwrap(&rval.toObject()))) { |
2518 | 0 | nsCOMPtr<nsIGlobalObject> contentGlobal; |
2519 | 0 | JS::Handle<JSObject*> callback = CallbackOrNull(); |
2520 | 0 | if (!callback || |
2521 | 0 | !GetContentGlobalForJSImplementedObject(cx, callback, getter_AddRefs(contentGlobal))) { |
2522 | 0 | aRv.Throw(NS_ERROR_UNEXPECTED); |
2523 | 0 | return nullptr; |
2524 | 0 | } |
2525 | 0 | JS::Rooted<JSObject*> jsImplSourceObj(cx, &rval.toObject()); |
2526 | 0 | MOZ_RELEASE_ASSERT(!js::IsWrapper(jsImplSourceObj), |
2527 | 0 | "Don't return JS implementations from other compartments"); |
2528 | 0 | JS::Rooted<JSObject*> jsImplSourceGlobal(cx, JS::GetNonCCWObjectGlobal(jsImplSourceObj)); |
2529 | 0 | rvalDecl = new mozilla::dom::RTCRtpReceiver(jsImplSourceObj, jsImplSourceGlobal, contentGlobal); |
2530 | 0 | } else { |
2531 | 0 | ThrowErrorMessage(cx, MSG_DOES_NOT_IMPLEMENT_INTERFACE, "Return value of RTCRtpTransceiver.receiver", "RTCRtpReceiver"); |
2532 | 0 | aRv.Throw(NS_ERROR_UNEXPECTED); |
2533 | 0 | return nullptr; |
2534 | 0 | } |
2535 | 0 | } |
2536 | 0 | } |
2537 | 0 | } else { |
2538 | 0 | ThrowErrorMessage(cx, MSG_NOT_OBJECT, "Return value of RTCRtpTransceiver.receiver"); |
2539 | 0 | aRv.Throw(NS_ERROR_UNEXPECTED); |
2540 | 0 | return nullptr; |
2541 | 0 | } |
2542 | 0 | return rvalDecl.forget(); |
2543 | 0 | } |
2544 | | |
2545 | | bool |
2546 | | RTCRtpTransceiverJSImpl::GetStopped(ErrorResult& aRv, JS::Realm* aRealm) |
2547 | 0 | { |
2548 | 0 | CallSetup s(this, aRv, "RTCRtpTransceiver.stopped", eRethrowContentExceptions, aRealm, /* aIsJSImplementedWebIDL = */ true); |
2549 | 0 | JSContext* cx = s.GetContext(); |
2550 | 0 | if (!cx) { |
2551 | 0 | MOZ_ASSERT(aRv.Failed()); |
2552 | 0 | return bool(0); |
2553 | 0 | } |
2554 | 0 | JS::Rooted<JS::Value> rval(cx, JS::UndefinedValue()); |
2555 | 0 |
|
2556 | 0 | JS::Rooted<JSObject *> callback(cx, mCallback); |
2557 | 0 | RTCRtpTransceiverAtoms* atomsCache = GetAtomCache<RTCRtpTransceiverAtoms>(cx); |
2558 | 0 | if ((!*reinterpret_cast<jsid**>(atomsCache) && !InitIds(cx, atomsCache)) || |
2559 | 0 | !JS_GetPropertyById(cx, callback, atomsCache->stopped_id, &rval)) { |
2560 | 0 | aRv.Throw(NS_ERROR_UNEXPECTED); |
2561 | 0 | return bool(0); |
2562 | 0 | } |
2563 | 0 | bool rvalDecl; |
2564 | 0 | if (!ValueToPrimitive<bool, eDefault>(cx, rval, &rvalDecl)) { |
2565 | 0 | aRv.Throw(NS_ERROR_UNEXPECTED); |
2566 | 0 | return bool(0); |
2567 | 0 | } |
2568 | 0 | return rvalDecl; |
2569 | 0 | } |
2570 | | |
2571 | | RTCRtpTransceiverDirection |
2572 | | RTCRtpTransceiverJSImpl::GetDirection(ErrorResult& aRv, JS::Realm* aRealm) |
2573 | 0 | { |
2574 | 0 | CallSetup s(this, aRv, "RTCRtpTransceiver.direction", eRethrowContentExceptions, aRealm, /* aIsJSImplementedWebIDL = */ true); |
2575 | 0 | JSContext* cx = s.GetContext(); |
2576 | 0 | if (!cx) { |
2577 | 0 | MOZ_ASSERT(aRv.Failed()); |
2578 | 0 | return RTCRtpTransceiverDirection(0); |
2579 | 0 | } |
2580 | 0 | JS::Rooted<JS::Value> rval(cx, JS::UndefinedValue()); |
2581 | 0 |
|
2582 | 0 | JS::Rooted<JSObject *> callback(cx, mCallback); |
2583 | 0 | RTCRtpTransceiverAtoms* atomsCache = GetAtomCache<RTCRtpTransceiverAtoms>(cx); |
2584 | 0 | if ((!*reinterpret_cast<jsid**>(atomsCache) && !InitIds(cx, atomsCache)) || |
2585 | 0 | !JS_GetPropertyById(cx, callback, atomsCache->direction_id, &rval)) { |
2586 | 0 | aRv.Throw(NS_ERROR_UNEXPECTED); |
2587 | 0 | return RTCRtpTransceiverDirection(0); |
2588 | 0 | } |
2589 | 0 | RTCRtpTransceiverDirection rvalDecl; |
2590 | 0 | { |
2591 | 0 | int index; |
2592 | 0 | if (!FindEnumStringIndex<true>(cx, rval, RTCRtpTransceiverDirectionValues::strings, "RTCRtpTransceiverDirection", "Return value of RTCRtpTransceiver.direction", &index)) { |
2593 | 0 | aRv.Throw(NS_ERROR_UNEXPECTED); |
2594 | 0 | return RTCRtpTransceiverDirection(0); |
2595 | 0 | } |
2596 | 0 | MOZ_ASSERT(index >= 0); |
2597 | 0 | rvalDecl = static_cast<RTCRtpTransceiverDirection>(index); |
2598 | 0 | } |
2599 | 0 | return rvalDecl; |
2600 | 0 | } |
2601 | | |
2602 | | Nullable<RTCRtpTransceiverDirection> |
2603 | | RTCRtpTransceiverJSImpl::GetCurrentDirection(ErrorResult& aRv, JS::Realm* aRealm) |
2604 | 0 | { |
2605 | 0 | CallSetup s(this, aRv, "RTCRtpTransceiver.currentDirection", eRethrowContentExceptions, aRealm, /* aIsJSImplementedWebIDL = */ true); |
2606 | 0 | JSContext* cx = s.GetContext(); |
2607 | 0 | if (!cx) { |
2608 | 0 | MOZ_ASSERT(aRv.Failed()); |
2609 | 0 | return Nullable<RTCRtpTransceiverDirection>(); |
2610 | 0 | } |
2611 | 0 | JS::Rooted<JS::Value> rval(cx, JS::UndefinedValue()); |
2612 | 0 |
|
2613 | 0 | JS::Rooted<JSObject *> callback(cx, mCallback); |
2614 | 0 | RTCRtpTransceiverAtoms* atomsCache = GetAtomCache<RTCRtpTransceiverAtoms>(cx); |
2615 | 0 | if ((!*reinterpret_cast<jsid**>(atomsCache) && !InitIds(cx, atomsCache)) || |
2616 | 0 | !JS_GetPropertyById(cx, callback, atomsCache->currentDirection_id, &rval)) { |
2617 | 0 | aRv.Throw(NS_ERROR_UNEXPECTED); |
2618 | 0 | return Nullable<RTCRtpTransceiverDirection>(); |
2619 | 0 | } |
2620 | 0 | Nullable<RTCRtpTransceiverDirection> rvalDecl; |
2621 | 0 | if (rval.isNullOrUndefined()) { |
2622 | 0 | rvalDecl.SetNull(); |
2623 | 0 | } else { |
2624 | 0 | { |
2625 | 0 | int index; |
2626 | 0 | if (!FindEnumStringIndex<true>(cx, rval, RTCRtpTransceiverDirectionValues::strings, "RTCRtpTransceiverDirection", "Return value of RTCRtpTransceiver.currentDirection", &index)) { |
2627 | 0 | aRv.Throw(NS_ERROR_UNEXPECTED); |
2628 | 0 | return Nullable<RTCRtpTransceiverDirection>(); |
2629 | 0 | } |
2630 | 0 | MOZ_ASSERT(index >= 0); |
2631 | 0 | rvalDecl.SetValue() = static_cast<RTCRtpTransceiverDirection>(index); |
2632 | 0 | } |
2633 | 0 | } |
2634 | 0 | return rvalDecl; |
2635 | 0 | } |
2636 | | |
2637 | | bool |
2638 | | RTCRtpTransceiverJSImpl::GetAddTrackMagic(ErrorResult& aRv, JS::Realm* aRealm) |
2639 | 0 | { |
2640 | 0 | CallSetup s(this, aRv, "RTCRtpTransceiver.addTrackMagic", eRethrowContentExceptions, aRealm, /* aIsJSImplementedWebIDL = */ true); |
2641 | 0 | JSContext* cx = s.GetContext(); |
2642 | 0 | if (!cx) { |
2643 | 0 | MOZ_ASSERT(aRv.Failed()); |
2644 | 0 | return bool(0); |
2645 | 0 | } |
2646 | 0 | JS::Rooted<JS::Value> rval(cx, JS::UndefinedValue()); |
2647 | 0 |
|
2648 | 0 | JS::Rooted<JSObject *> callback(cx, mCallback); |
2649 | 0 | RTCRtpTransceiverAtoms* atomsCache = GetAtomCache<RTCRtpTransceiverAtoms>(cx); |
2650 | 0 | if ((!*reinterpret_cast<jsid**>(atomsCache) && !InitIds(cx, atomsCache)) || |
2651 | 0 | !JS_GetPropertyById(cx, callback, atomsCache->addTrackMagic_id, &rval)) { |
2652 | 0 | aRv.Throw(NS_ERROR_UNEXPECTED); |
2653 | 0 | return bool(0); |
2654 | 0 | } |
2655 | 0 | bool rvalDecl; |
2656 | 0 | if (!ValueToPrimitive<bool, eDefault>(cx, rval, &rvalDecl)) { |
2657 | 0 | aRv.Throw(NS_ERROR_UNEXPECTED); |
2658 | 0 | return bool(0); |
2659 | 0 | } |
2660 | 0 | return rvalDecl; |
2661 | 0 | } |
2662 | | |
2663 | | bool |
2664 | | RTCRtpTransceiverJSImpl::GetShouldRemove(ErrorResult& aRv, JS::Realm* aRealm) |
2665 | 0 | { |
2666 | 0 | CallSetup s(this, aRv, "RTCRtpTransceiver.shouldRemove", eRethrowContentExceptions, aRealm, /* aIsJSImplementedWebIDL = */ true); |
2667 | 0 | JSContext* cx = s.GetContext(); |
2668 | 0 | if (!cx) { |
2669 | 0 | MOZ_ASSERT(aRv.Failed()); |
2670 | 0 | return bool(0); |
2671 | 0 | } |
2672 | 0 | JS::Rooted<JS::Value> rval(cx, JS::UndefinedValue()); |
2673 | 0 |
|
2674 | 0 | JS::Rooted<JSObject *> callback(cx, mCallback); |
2675 | 0 | RTCRtpTransceiverAtoms* atomsCache = GetAtomCache<RTCRtpTransceiverAtoms>(cx); |
2676 | 0 | if ((!*reinterpret_cast<jsid**>(atomsCache) && !InitIds(cx, atomsCache)) || |
2677 | 0 | !JS_GetPropertyById(cx, callback, atomsCache->shouldRemove_id, &rval)) { |
2678 | 0 | aRv.Throw(NS_ERROR_UNEXPECTED); |
2679 | 0 | return bool(0); |
2680 | 0 | } |
2681 | 0 | bool rvalDecl; |
2682 | 0 | if (!ValueToPrimitive<bool, eDefault>(cx, rval, &rvalDecl)) { |
2683 | 0 | aRv.Throw(NS_ERROR_UNEXPECTED); |
2684 | 0 | return bool(0); |
2685 | 0 | } |
2686 | 0 | return rvalDecl; |
2687 | 0 | } |
2688 | | |
2689 | | void |
2690 | | RTCRtpTransceiverJSImpl::SetDirection(RTCRtpTransceiverDirection arg, ErrorResult& aRv, JS::Realm* aRealm) |
2691 | 0 | { |
2692 | 0 | CallSetup s(this, aRv, "RTCRtpTransceiver.direction", eRethrowContentExceptions, aRealm, /* aIsJSImplementedWebIDL = */ true); |
2693 | 0 | JSContext* cx = s.GetContext(); |
2694 | 0 | if (!cx) { |
2695 | 0 | MOZ_ASSERT(aRv.Failed()); |
2696 | 0 | return; |
2697 | 0 | } |
2698 | 0 | JS::AutoValueVector argv(cx); |
2699 | 0 | if (!argv.resize(1)) { |
2700 | 0 | aRv.Throw(NS_ERROR_OUT_OF_MEMORY); |
2701 | 0 | return; |
2702 | 0 | } |
2703 | 0 | do { |
2704 | 0 | if (!ToJSValue(cx, arg, argv[0])) { |
2705 | 0 | aRv.Throw(NS_ERROR_UNEXPECTED); |
2706 | 0 | return; |
2707 | 0 | } |
2708 | 0 | break; |
2709 | 0 | } while (false); |
2710 | 0 |
|
2711 | 0 | MOZ_ASSERT(argv.length() == 1); |
2712 | 0 | RTCRtpTransceiverAtoms* atomsCache = GetAtomCache<RTCRtpTransceiverAtoms>(cx); |
2713 | 0 | if ((!*reinterpret_cast<jsid**>(atomsCache) && !InitIds(cx, atomsCache)) || |
2714 | 0 | !JS_SetPropertyById(cx, CallbackKnownNotGray(), atomsCache->direction_id, argv[0])) { |
2715 | 0 | aRv.Throw(NS_ERROR_UNEXPECTED); |
2716 | 0 | return; |
2717 | 0 | } |
2718 | 0 | } |
2719 | | |
2720 | | void |
2721 | | RTCRtpTransceiverJSImpl::SetShouldRemove(bool arg, ErrorResult& aRv, JS::Realm* aRealm) |
2722 | 0 | { |
2723 | 0 | CallSetup s(this, aRv, "RTCRtpTransceiver.shouldRemove", eRethrowContentExceptions, aRealm, /* aIsJSImplementedWebIDL = */ true); |
2724 | 0 | JSContext* cx = s.GetContext(); |
2725 | 0 | if (!cx) { |
2726 | 0 | MOZ_ASSERT(aRv.Failed()); |
2727 | 0 | return; |
2728 | 0 | } |
2729 | 0 | JS::AutoValueVector argv(cx); |
2730 | 0 | if (!argv.resize(1)) { |
2731 | 0 | aRv.Throw(NS_ERROR_OUT_OF_MEMORY); |
2732 | 0 | return; |
2733 | 0 | } |
2734 | 0 | do { |
2735 | 0 | argv[0].setBoolean(arg); |
2736 | 0 | break; |
2737 | 0 | } while (false); |
2738 | 0 |
|
2739 | 0 | MOZ_ASSERT(argv.length() == 1); |
2740 | 0 | RTCRtpTransceiverAtoms* atomsCache = GetAtomCache<RTCRtpTransceiverAtoms>(cx); |
2741 | 0 | if ((!*reinterpret_cast<jsid**>(atomsCache) && !InitIds(cx, atomsCache)) || |
2742 | 0 | !JS_SetPropertyById(cx, CallbackKnownNotGray(), atomsCache->shouldRemove_id, argv[0])) { |
2743 | 0 | aRv.Throw(NS_ERROR_UNEXPECTED); |
2744 | 0 | return; |
2745 | 0 | } |
2746 | 0 | } |
2747 | | |
2748 | | |
2749 | | NS_IMPL_CYCLE_COLLECTION_CLASS(RTCRtpTransceiver) |
2750 | 0 | NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN(RTCRtpTransceiver) |
2751 | 0 | NS_IMPL_CYCLE_COLLECTION_UNLINK(mImpl) |
2752 | 0 | NS_IMPL_CYCLE_COLLECTION_UNLINK(mParent) |
2753 | 0 | NS_IMPL_CYCLE_COLLECTION_UNLINK_PRESERVED_WRAPPER |
2754 | 0 | tmp->ClearWeakReferences(); |
2755 | 0 | NS_IMPL_CYCLE_COLLECTION_UNLINK_END |
2756 | 0 | NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN(RTCRtpTransceiver) |
2757 | 0 | NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mImpl) |
2758 | 0 | NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mParent) |
2759 | 0 | NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END |
2760 | | NS_IMPL_CYCLE_COLLECTION_TRACE_WRAPPERCACHE(RTCRtpTransceiver) |
2761 | | NS_IMPL_CYCLE_COLLECTING_ADDREF(RTCRtpTransceiver) |
2762 | | NS_IMPL_CYCLE_COLLECTING_RELEASE(RTCRtpTransceiver) |
2763 | 0 | NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(RTCRtpTransceiver) |
2764 | 0 | NS_WRAPPERCACHE_INTERFACE_MAP_ENTRY |
2765 | 0 | NS_INTERFACE_MAP_ENTRY(nsISupports) |
2766 | 0 | NS_INTERFACE_MAP_ENTRY(nsISupportsWeakReference) |
2767 | 0 | NS_INTERFACE_MAP_END |
2768 | | |
2769 | | RTCRtpTransceiver::RTCRtpTransceiver(JS::Handle<JSObject*> aJSImplObject, JS::Handle<JSObject*> aJSImplGlobal, nsIGlobalObject* aParent) |
2770 | | : mImpl(new RTCRtpTransceiverJSImpl(nullptr, aJSImplObject, aJSImplGlobal, /* aIncumbentGlobal = */ nullptr)), |
2771 | | mParent(aParent) |
2772 | 0 | { |
2773 | 0 | } |
2774 | | |
2775 | | |
2776 | | RTCRtpTransceiver::~RTCRtpTransceiver() |
2777 | 0 | { |
2778 | 0 | } |
2779 | | |
2780 | | nsISupports* |
2781 | | RTCRtpTransceiver::GetParentObject() const |
2782 | 0 | { |
2783 | 0 | return mParent; |
2784 | 0 | } |
2785 | | |
2786 | | JSObject* |
2787 | | RTCRtpTransceiver::WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto) |
2788 | 0 | { |
2789 | 0 | JS::Rooted<JSObject*> obj(aCx, RTCRtpTransceiver_Binding::Wrap(aCx, this, aGivenProto)); |
2790 | 0 | if (!obj) { |
2791 | 0 | return nullptr; |
2792 | 0 | } |
2793 | 0 | |
2794 | 0 | // Now define it on our chrome object |
2795 | 0 | JSAutoRealm ar(aCx, mImpl->CallbackGlobalOrNull()); |
2796 | 0 | if (!JS_WrapObject(aCx, &obj)) { |
2797 | 0 | return nullptr; |
2798 | 0 | } |
2799 | 0 | if (!JS_DefineProperty(aCx, mImpl->CallbackOrNull(), "__DOM_IMPL__", obj, 0)) { |
2800 | 0 | return nullptr; |
2801 | 0 | } |
2802 | 0 | return obj; |
2803 | 0 | } |
2804 | | |
2805 | | void |
2806 | | RTCRtpTransceiver::GetMid(nsString& aRetVal, ErrorResult& aRv, JS::Realm* aRealm) const |
2807 | 0 | { |
2808 | 0 | return mImpl->GetMid(aRetVal, aRv, aRealm); |
2809 | 0 | } |
2810 | | |
2811 | | // Return a raw pointer here to avoid refcounting, but make sure it's safe (the object should be kept alive by the callee). |
2812 | | already_AddRefed<RTCRtpSender> |
2813 | | RTCRtpTransceiver::GetSender(ErrorResult& aRv, JS::Realm* aRealm) const |
2814 | 0 | { |
2815 | 0 | return mImpl->GetSender(aRv, aRealm); |
2816 | 0 | } |
2817 | | |
2818 | | // Return a raw pointer here to avoid refcounting, but make sure it's safe (the object should be kept alive by the callee). |
2819 | | already_AddRefed<RTCRtpReceiver> |
2820 | | RTCRtpTransceiver::GetReceiver(ErrorResult& aRv, JS::Realm* aRealm) const |
2821 | 0 | { |
2822 | 0 | return mImpl->GetReceiver(aRv, aRealm); |
2823 | 0 | } |
2824 | | |
2825 | | bool |
2826 | | RTCRtpTransceiver::GetStopped(ErrorResult& aRv, JS::Realm* aRealm) const |
2827 | 0 | { |
2828 | 0 | return mImpl->GetStopped(aRv, aRealm); |
2829 | 0 | } |
2830 | | |
2831 | | RTCRtpTransceiverDirection |
2832 | | RTCRtpTransceiver::GetDirection(ErrorResult& aRv, JS::Realm* aRealm) const |
2833 | 0 | { |
2834 | 0 | return mImpl->GetDirection(aRv, aRealm); |
2835 | 0 | } |
2836 | | |
2837 | | void |
2838 | | RTCRtpTransceiver::SetDirection(RTCRtpTransceiverDirection arg, ErrorResult& aRv, JS::Realm* aRealm) |
2839 | 0 | { |
2840 | 0 | mImpl->SetDirection(arg, aRv, aRealm); |
2841 | 0 | } |
2842 | | |
2843 | | Nullable<RTCRtpTransceiverDirection> |
2844 | | RTCRtpTransceiver::GetCurrentDirection(ErrorResult& aRv, JS::Realm* aRealm) const |
2845 | 0 | { |
2846 | 0 | return mImpl->GetCurrentDirection(aRv, aRealm); |
2847 | 0 | } |
2848 | | |
2849 | | void |
2850 | | RTCRtpTransceiver::Stop(ErrorResult& aRv, JS::Realm* aRealm) |
2851 | 0 | { |
2852 | 0 | return mImpl->Stop(aRv, aRealm); |
2853 | 0 | } |
2854 | | |
2855 | | void |
2856 | | RTCRtpTransceiver::SetRemoteTrackId(const nsAString& trackId, ErrorResult& aRv, JS::Realm* aRealm) |
2857 | 0 | { |
2858 | 0 | return mImpl->SetRemoteTrackId(trackId, aRv, aRealm); |
2859 | 0 | } |
2860 | | |
2861 | | bool |
2862 | | RTCRtpTransceiver::RemoteTrackIdIs(const nsAString& trackId, ErrorResult& aRv, JS::Realm* aRealm) |
2863 | 0 | { |
2864 | 0 | return mImpl->RemoteTrackIdIs(trackId, aRv, aRealm); |
2865 | 0 | } |
2866 | | |
2867 | | void |
2868 | | RTCRtpTransceiver::GetRemoteTrackId(nsString& aRetVal, ErrorResult& aRv, JS::Realm* aRealm) |
2869 | 0 | { |
2870 | 0 | return mImpl->GetRemoteTrackId(aRetVal, aRv, aRealm); |
2871 | 0 | } |
2872 | | |
2873 | | void |
2874 | | RTCRtpTransceiver::SetAddTrackMagic(ErrorResult& aRv, JS::Realm* aRealm) |
2875 | 0 | { |
2876 | 0 | return mImpl->SetAddTrackMagic(aRv, aRealm); |
2877 | 0 | } |
2878 | | |
2879 | | bool |
2880 | | RTCRtpTransceiver::GetAddTrackMagic(ErrorResult& aRv, JS::Realm* aRealm) const |
2881 | 0 | { |
2882 | 0 | return mImpl->GetAddTrackMagic(aRv, aRealm); |
2883 | 0 | } |
2884 | | |
2885 | | bool |
2886 | | RTCRtpTransceiver::GetShouldRemove(ErrorResult& aRv, JS::Realm* aRealm) const |
2887 | 0 | { |
2888 | 0 | return mImpl->GetShouldRemove(aRv, aRealm); |
2889 | 0 | } |
2890 | | |
2891 | | void |
2892 | | RTCRtpTransceiver::SetShouldRemove(bool arg, ErrorResult& aRv, JS::Realm* aRealm) |
2893 | 0 | { |
2894 | 0 | mImpl->SetShouldRemove(arg, aRv, aRealm); |
2895 | 0 | } |
2896 | | |
2897 | | void |
2898 | | RTCRtpTransceiver::SetCurrentDirection(RTCRtpTransceiverDirection direction, ErrorResult& aRv, JS::Realm* aRealm) |
2899 | 0 | { |
2900 | 0 | return mImpl->SetCurrentDirection(direction, aRv, aRealm); |
2901 | 0 | } |
2902 | | |
2903 | | void |
2904 | | RTCRtpTransceiver::SetDirectionInternal(RTCRtpTransceiverDirection direction, ErrorResult& aRv, JS::Realm* aRealm) |
2905 | 0 | { |
2906 | 0 | return mImpl->SetDirectionInternal(direction, aRv, aRealm); |
2907 | 0 | } |
2908 | | |
2909 | | void |
2910 | | RTCRtpTransceiver::SetMid(const nsAString& mid, ErrorResult& aRv, JS::Realm* aRealm) |
2911 | 0 | { |
2912 | 0 | return mImpl->SetMid(mid, aRv, aRealm); |
2913 | 0 | } |
2914 | | |
2915 | | void |
2916 | | RTCRtpTransceiver::UnsetMid(ErrorResult& aRv, JS::Realm* aRealm) |
2917 | 0 | { |
2918 | 0 | return mImpl->UnsetMid(aRv, aRealm); |
2919 | 0 | } |
2920 | | |
2921 | | void |
2922 | | RTCRtpTransceiver::SetStopped(ErrorResult& aRv, JS::Realm* aRealm) |
2923 | 0 | { |
2924 | 0 | return mImpl->SetStopped(aRv, aRealm); |
2925 | 0 | } |
2926 | | |
2927 | | void |
2928 | | RTCRtpTransceiver::GetKind(nsString& aRetVal, ErrorResult& aRv, JS::Realm* aRealm) |
2929 | 0 | { |
2930 | 0 | return mImpl->GetKind(aRetVal, aRv, aRealm); |
2931 | 0 | } |
2932 | | |
2933 | | bool |
2934 | | RTCRtpTransceiver::HasBeenUsedToSend(ErrorResult& aRv, JS::Realm* aRealm) |
2935 | 0 | { |
2936 | 0 | return mImpl->HasBeenUsedToSend(aRv, aRealm); |
2937 | 0 | } |
2938 | | |
2939 | | void |
2940 | | RTCRtpTransceiver::Sync(ErrorResult& aRv, JS::Realm* aRealm) |
2941 | 0 | { |
2942 | 0 | return mImpl->Sync(aRv, aRealm); |
2943 | 0 | } |
2944 | | |
2945 | | void |
2946 | | RTCRtpTransceiver::InsertDTMF(const nsAString& tones, uint32_t duration, uint32_t interToneGap, ErrorResult& aRv, JS::Realm* aRealm) |
2947 | 0 | { |
2948 | 0 | return mImpl->InsertDTMF(tones, duration, interToneGap, aRv, aRealm); |
2949 | 0 | } |
2950 | | |
2951 | | bool |
2952 | | RTCRtpTransceiver::_Create(JSContext* cx, unsigned argc, JS::Value* vp) |
2953 | 0 | { |
2954 | 0 | JS::CallArgs args = JS::CallArgsFromVp(argc, vp); |
2955 | 0 | if (args.length() < 2) { |
2956 | 0 | return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "RTCRtpTransceiver._create"); |
2957 | 0 | } |
2958 | 0 | if (!args[0].isObject()) { |
2959 | 0 | return ThrowErrorMessage(cx, MSG_NOT_OBJECT, "Argument 1 of RTCRtpTransceiver._create"); |
2960 | 0 | } |
2961 | 0 | if (!args[1].isObject()) { |
2962 | 0 | return ThrowErrorMessage(cx, MSG_NOT_OBJECT, "Argument 2 of RTCRtpTransceiver._create"); |
2963 | 0 | } |
2964 | 0 | |
2965 | 0 | // GlobalObject will go through wrappers as needed for us, and |
2966 | 0 | // is simpler than the right UnwrapArg incantation. |
2967 | 0 | GlobalObject global(cx, &args[0].toObject()); |
2968 | 0 | if (global.Failed()) { |
2969 | 0 | return false; |
2970 | 0 | } |
2971 | 0 | nsCOMPtr<nsIGlobalObject> globalHolder = do_QueryInterface(global.GetAsSupports()); |
2972 | 0 | MOZ_ASSERT(globalHolder); |
2973 | 0 | JS::Rooted<JSObject*> arg(cx, &args[1].toObject()); |
2974 | 0 | JS::Rooted<JSObject*> argGlobal(cx, JS::CurrentGlobalOrNull(cx)); |
2975 | 0 | RefPtr<RTCRtpTransceiver> impl = new RTCRtpTransceiver(arg, argGlobal, globalHolder); |
2976 | 0 | MOZ_ASSERT(js::IsObjectInContextCompartment(arg, cx)); |
2977 | 0 | return GetOrCreateDOMReflector(cx, impl, args.rval()); |
2978 | 0 | } |
2979 | | |
2980 | | |
2981 | | } // namespace dom |
2982 | | } // namespace mozilla |