Line data Source code
1 : /* THIS FILE IS AUTOGENERATED FROM FakePluginTagInit.webidl BY Codegen.py - DO NOT EDIT */
2 :
3 : #include "AtomList.h"
4 : #include "FakePluginTagInitBinding.h"
5 : #include "mozilla/OwningNonNull.h"
6 : #include "mozilla/dom/BindingUtils.h"
7 : #include "mozilla/dom/NonRefcountedDOMObject.h"
8 : #include "mozilla/dom/ScriptSettings.h"
9 : #include "mozilla/dom/SimpleGlobalObject.h"
10 :
11 : namespace mozilla {
12 : namespace dom {
13 :
14 :
15 0 : FakePluginMimeEntry::FakePluginMimeEntry()
16 : {
17 : // Safe to pass a null context if we pass a null value
18 0 : Init(nullptr, JS::NullHandleValue);
19 0 : }
20 :
21 :
22 :
23 : bool
24 0 : FakePluginMimeEntry::InitIds(JSContext* cx, FakePluginMimeEntryAtoms* atomsCache)
25 : {
26 0 : MOZ_ASSERT(!*reinterpret_cast<jsid**>(atomsCache));
27 :
28 : // Initialize these in reverse order so that any failure leaves the first one
29 : // uninitialized.
30 0 : if (!atomsCache->type_id.init(cx, "type") ||
31 0 : !atomsCache->extension_id.init(cx, "extension") ||
32 0 : !atomsCache->description_id.init(cx, "description")) {
33 0 : return false;
34 : }
35 0 : return true;
36 : }
37 :
38 : bool
39 0 : FakePluginMimeEntry::Init(JSContext* cx, JS::Handle<JS::Value> val, const char* sourceDescription, bool passedToJSImpl)
40 : {
41 : // Passing a null JSContext is OK only if we're initing from null,
42 : // Since in that case we will not have to do any property gets
43 : // Also evaluate isNullOrUndefined in order to avoid false-positive
44 : // checkers by static analysis tools
45 0 : MOZ_ASSERT_IF(!cx, val.isNull() && val.isNullOrUndefined());
46 0 : FakePluginMimeEntryAtoms* atomsCache = nullptr;
47 0 : if (cx) {
48 0 : atomsCache = GetAtomCache<FakePluginMimeEntryAtoms>(cx);
49 0 : if (!*reinterpret_cast<jsid**>(atomsCache) && !InitIds(cx, atomsCache)) {
50 0 : return false;
51 : }
52 : }
53 :
54 0 : if (!IsConvertibleToDictionary(val)) {
55 0 : return ThrowErrorMessage(cx, MSG_NOT_DICTIONARY, sourceDescription);
56 : }
57 :
58 0 : bool isNull = val.isNullOrUndefined();
59 : // We only need these if !isNull, in which case we have |cx|.
60 0 : Maybe<JS::Rooted<JSObject *> > object;
61 0 : Maybe<JS::Rooted<JS::Value> > temp;
62 0 : if (!isNull) {
63 0 : MOZ_ASSERT(cx);
64 0 : object.emplace(cx, &val.toObject());
65 0 : temp.emplace(cx);
66 : }
67 0 : if (!isNull) {
68 0 : if (!JS_GetPropertyById(cx, *object, atomsCache->description_id, temp.ptr())) {
69 0 : return false;
70 : }
71 : }
72 0 : if (!isNull && !temp->isUndefined()) {
73 0 : if (!ConvertJSValueToString(cx, temp.ref(), eStringify, eStringify, mDescription)) {
74 0 : return false;
75 : }
76 : } else {
77 : static const char16_t data[] = { 0 };
78 0 : mDescription.Rebind(data, ArrayLength(data) - 1);
79 : }
80 0 : mIsAnyMemberPresent = true;
81 :
82 0 : if (!isNull) {
83 0 : if (!JS_GetPropertyById(cx, *object, atomsCache->extension_id, temp.ptr())) {
84 0 : return false;
85 : }
86 : }
87 0 : if (!isNull && !temp->isUndefined()) {
88 0 : if (!ConvertJSValueToString(cx, temp.ref(), eStringify, eStringify, mExtension)) {
89 0 : return false;
90 : }
91 : } else {
92 : static const char16_t data[] = { 0 };
93 0 : mExtension.Rebind(data, ArrayLength(data) - 1);
94 : }
95 0 : mIsAnyMemberPresent = true;
96 :
97 0 : if (!isNull) {
98 0 : if (!JS_GetPropertyById(cx, *object, atomsCache->type_id, temp.ptr())) {
99 0 : return false;
100 : }
101 : }
102 0 : if (!isNull && !temp->isUndefined()) {
103 0 : if (!ConvertJSValueToString(cx, temp.ref(), eStringify, eStringify, mType)) {
104 0 : return false;
105 : }
106 0 : mIsAnyMemberPresent = true;
107 0 : } else if (cx) {
108 : // Don't error out if we have no cx. In that
109 : // situation the caller is default-constructing us and we'll
110 : // just assume they know what they're doing.
111 0 : return ThrowErrorMessage(cx, MSG_MISSING_REQUIRED_DICTIONARY_MEMBER,
112 0 : "'type' member of FakePluginMimeEntry");
113 : }
114 0 : return true;
115 : }
116 :
117 : bool
118 0 : FakePluginMimeEntry::Init(const nsAString& aJSON)
119 : {
120 0 : AutoJSAPI jsapi;
121 0 : JSObject* cleanGlobal = SimpleGlobalObject::Create(SimpleGlobalObject::GlobalType::BindingDetail);
122 0 : if (!cleanGlobal) {
123 0 : return false;
124 : }
125 0 : if (!jsapi.Init(cleanGlobal)) {
126 0 : return false;
127 : }
128 0 : JSContext* cx = jsapi.cx();
129 0 : JS::Rooted<JS::Value> json(cx);
130 0 : bool ok = ParseJSON(cx, aJSON, &json);
131 0 : NS_ENSURE_TRUE(ok, false);
132 0 : return Init(cx, json);
133 : }
134 :
135 : bool
136 0 : FakePluginMimeEntry::ToObjectInternal(JSContext* cx, JS::MutableHandle<JS::Value> rval) const
137 : {
138 0 : FakePluginMimeEntryAtoms* atomsCache = GetAtomCache<FakePluginMimeEntryAtoms>(cx);
139 0 : if (!*reinterpret_cast<jsid**>(atomsCache) && !InitIds(cx, atomsCache)) {
140 0 : return false;
141 : }
142 :
143 0 : JS::Rooted<JSObject*> obj(cx, JS_NewPlainObject(cx));
144 0 : if (!obj) {
145 0 : return false;
146 : }
147 0 : rval.set(JS::ObjectValue(*obj));
148 :
149 : do {
150 : // block for our 'break' successCode and scope for 'temp' and 'currentValue'
151 0 : JS::Rooted<JS::Value> temp(cx);
152 0 : nsString const & currentValue = mDescription;
153 0 : if (!xpc::NonVoidStringToJsval(cx, currentValue, &temp)) {
154 0 : return false;
155 : }
156 0 : if (!JS_DefinePropertyById(cx, obj, atomsCache->description_id, temp, JSPROP_ENUMERATE)) {
157 0 : return false;
158 : }
159 0 : break;
160 : } while(0);
161 :
162 : do {
163 : // block for our 'break' successCode and scope for 'temp' and 'currentValue'
164 0 : JS::Rooted<JS::Value> temp(cx);
165 0 : nsString const & currentValue = mExtension;
166 0 : if (!xpc::NonVoidStringToJsval(cx, currentValue, &temp)) {
167 0 : return false;
168 : }
169 0 : if (!JS_DefinePropertyById(cx, obj, atomsCache->extension_id, temp, JSPROP_ENUMERATE)) {
170 0 : return false;
171 : }
172 0 : break;
173 : } while(0);
174 :
175 : do {
176 : // block for our 'break' successCode and scope for 'temp' and 'currentValue'
177 0 : JS::Rooted<JS::Value> temp(cx);
178 0 : nsString const & currentValue = mType;
179 0 : if (!xpc::NonVoidStringToJsval(cx, currentValue, &temp)) {
180 0 : return false;
181 : }
182 0 : if (!JS_DefinePropertyById(cx, obj, atomsCache->type_id, temp, JSPROP_ENUMERATE)) {
183 0 : return false;
184 : }
185 0 : break;
186 : } while(0);
187 :
188 0 : return true;
189 : }
190 :
191 : bool
192 0 : FakePluginMimeEntry::ToJSON(nsAString& aJSON) const
193 : {
194 0 : AutoJSAPI jsapi;
195 0 : jsapi.Init();
196 0 : JSContext *cx = jsapi.cx();
197 : // It's safe to use UnprivilegedJunkScopeOrWorkerGlobal here
198 : // because we'll only be creating objects, in ways that have no
199 : // side-effects, followed by a call to JS::ToJSONMaybeSafely,
200 : // which likewise guarantees no side-effects for the sorts of
201 : // things we will pass it.
202 0 : JSAutoCompartment ac(cx, binding_detail::UnprivilegedJunkScopeOrWorkerGlobal());
203 0 : JS::Rooted<JS::Value> val(cx);
204 0 : if (!ToObjectInternal(cx, &val)) {
205 0 : return false;
206 : }
207 0 : JS::Rooted<JSObject*> obj(cx, &val.toObject());
208 0 : return StringifyToJSON(cx, obj, aJSON);
209 : }
210 :
211 : void
212 0 : FakePluginMimeEntry::TraceDictionary(JSTracer* trc)
213 : {
214 0 : }
215 :
216 : FakePluginMimeEntry&
217 0 : FakePluginMimeEntry::operator=(const FakePluginMimeEntry& aOther)
218 : {
219 0 : mDescription = aOther.mDescription;
220 0 : mExtension = aOther.mExtension;
221 0 : mType = aOther.mType;
222 0 : return *this;
223 : }
224 :
225 : namespace binding_detail {
226 : } // namespace binding_detail
227 :
228 :
229 :
230 0 : FakePluginTagInit::FakePluginTagInit()
231 : {
232 : // Safe to pass a null context if we pass a null value
233 0 : Init(nullptr, JS::NullHandleValue);
234 0 : }
235 :
236 :
237 :
238 : bool
239 0 : FakePluginTagInit::InitIds(JSContext* cx, FakePluginTagInitAtoms* atomsCache)
240 : {
241 0 : MOZ_ASSERT(!*reinterpret_cast<jsid**>(atomsCache));
242 :
243 : // Initialize these in reverse order so that any failure leaves the first one
244 : // uninitialized.
245 0 : if (!atomsCache->version_id.init(cx, "version") ||
246 0 : !atomsCache->sandboxScript_id.init(cx, "sandboxScript") ||
247 0 : !atomsCache->niceName_id.init(cx, "niceName") ||
248 0 : !atomsCache->name_id.init(cx, "name") ||
249 0 : !atomsCache->mimeEntries_id.init(cx, "mimeEntries") ||
250 0 : !atomsCache->handlerURI_id.init(cx, "handlerURI") ||
251 0 : !atomsCache->fullPath_id.init(cx, "fullPath") ||
252 0 : !atomsCache->fileName_id.init(cx, "fileName") ||
253 0 : !atomsCache->description_id.init(cx, "description")) {
254 0 : return false;
255 : }
256 0 : return true;
257 : }
258 :
259 : bool
260 0 : FakePluginTagInit::Init(JSContext* cx, JS::Handle<JS::Value> val, const char* sourceDescription, bool passedToJSImpl)
261 : {
262 : // Passing a null JSContext is OK only if we're initing from null,
263 : // Since in that case we will not have to do any property gets
264 : // Also evaluate isNullOrUndefined in order to avoid false-positive
265 : // checkers by static analysis tools
266 0 : MOZ_ASSERT_IF(!cx, val.isNull() && val.isNullOrUndefined());
267 0 : FakePluginTagInitAtoms* atomsCache = nullptr;
268 0 : if (cx) {
269 0 : atomsCache = GetAtomCache<FakePluginTagInitAtoms>(cx);
270 0 : if (!*reinterpret_cast<jsid**>(atomsCache) && !InitIds(cx, atomsCache)) {
271 0 : return false;
272 : }
273 : }
274 :
275 0 : if (!IsConvertibleToDictionary(val)) {
276 0 : return ThrowErrorMessage(cx, MSG_NOT_DICTIONARY, sourceDescription);
277 : }
278 :
279 0 : bool isNull = val.isNullOrUndefined();
280 : // We only need these if !isNull, in which case we have |cx|.
281 0 : Maybe<JS::Rooted<JSObject *> > object;
282 0 : Maybe<JS::Rooted<JS::Value> > temp;
283 0 : if (!isNull) {
284 0 : MOZ_ASSERT(cx);
285 0 : object.emplace(cx, &val.toObject());
286 0 : temp.emplace(cx);
287 : }
288 0 : if (!isNull) {
289 0 : if (!JS_GetPropertyById(cx, *object, atomsCache->description_id, temp.ptr())) {
290 0 : return false;
291 : }
292 : }
293 0 : if (!isNull && !temp->isUndefined()) {
294 0 : if (!ConvertJSValueToString(cx, temp.ref(), eStringify, eStringify, mDescription)) {
295 0 : return false;
296 : }
297 : } else {
298 : static const char16_t data[] = { 0 };
299 0 : mDescription.Rebind(data, ArrayLength(data) - 1);
300 : }
301 0 : mIsAnyMemberPresent = true;
302 :
303 0 : if (!isNull) {
304 0 : if (!JS_GetPropertyById(cx, *object, atomsCache->fileName_id, temp.ptr())) {
305 0 : return false;
306 : }
307 : }
308 0 : if (!isNull && !temp->isUndefined()) {
309 0 : if (!ConvertJSValueToString(cx, temp.ref(), eStringify, eStringify, mFileName)) {
310 0 : return false;
311 : }
312 : } else {
313 : static const char16_t data[] = { 0 };
314 0 : mFileName.Rebind(data, ArrayLength(data) - 1);
315 : }
316 0 : mIsAnyMemberPresent = true;
317 :
318 0 : if (!isNull) {
319 0 : if (!JS_GetPropertyById(cx, *object, atomsCache->fullPath_id, temp.ptr())) {
320 0 : return false;
321 : }
322 : }
323 0 : if (!isNull && !temp->isUndefined()) {
324 0 : if (!ConvertJSValueToString(cx, temp.ref(), eStringify, eStringify, mFullPath)) {
325 0 : return false;
326 : }
327 : } else {
328 : static const char16_t data[] = { 0 };
329 0 : mFullPath.Rebind(data, ArrayLength(data) - 1);
330 : }
331 0 : mIsAnyMemberPresent = true;
332 :
333 0 : if (!isNull) {
334 0 : if (!JS_GetPropertyById(cx, *object, atomsCache->handlerURI_id, temp.ptr())) {
335 0 : return false;
336 : }
337 : }
338 0 : if (!isNull && !temp->isUndefined()) {
339 0 : if (!ConvertJSValueToString(cx, temp.ref(), eStringify, eStringify, mHandlerURI)) {
340 0 : return false;
341 : }
342 0 : mIsAnyMemberPresent = true;
343 0 : } else if (cx) {
344 : // Don't error out if we have no cx. In that
345 : // situation the caller is default-constructing us and we'll
346 : // just assume they know what they're doing.
347 0 : return ThrowErrorMessage(cx, MSG_MISSING_REQUIRED_DICTIONARY_MEMBER,
348 0 : "'handlerURI' member of FakePluginTagInit");
349 : }
350 :
351 0 : if (!isNull) {
352 0 : if (!JS_GetPropertyById(cx, *object, atomsCache->mimeEntries_id, temp.ptr())) {
353 0 : return false;
354 : }
355 : }
356 0 : if (!isNull && !temp->isUndefined()) {
357 0 : if (temp.ref().isObject()) {
358 0 : JS::ForOfIterator iter(cx);
359 0 : if (!iter.init(temp.ref(), JS::ForOfIterator::AllowNonIterable)) {
360 0 : return false;
361 : }
362 0 : if (!iter.valueIsIterable()) {
363 0 : ThrowErrorMessage(cx, MSG_NOT_SEQUENCE, "'mimeEntries' member of FakePluginTagInit");
364 0 : return false;
365 : }
366 0 : Sequence<FakePluginMimeEntry> &arr = mMimeEntries;
367 0 : JS::Rooted<JS::Value> temp(cx);
368 : while (true) {
369 : bool done;
370 0 : if (!iter.next(&temp, &done)) {
371 0 : return false;
372 : }
373 0 : if (done) {
374 0 : break;
375 : }
376 0 : FakePluginMimeEntry* slotPtr = arr.AppendElement(mozilla::fallible);
377 0 : if (!slotPtr) {
378 0 : JS_ReportOutOfMemory(cx);
379 0 : return false;
380 : }
381 0 : FakePluginMimeEntry& slot = *slotPtr;
382 0 : if (!slot.Init(cx, temp, "Element of 'mimeEntries' member of FakePluginTagInit", passedToJSImpl)) {
383 0 : return false;
384 : }
385 0 : }
386 : } else {
387 0 : ThrowErrorMessage(cx, MSG_NOT_SEQUENCE, "'mimeEntries' member of FakePluginTagInit");
388 0 : return false;
389 : }
390 0 : mIsAnyMemberPresent = true;
391 0 : } else if (cx) {
392 : // Don't error out if we have no cx. In that
393 : // situation the caller is default-constructing us and we'll
394 : // just assume they know what they're doing.
395 0 : return ThrowErrorMessage(cx, MSG_MISSING_REQUIRED_DICTIONARY_MEMBER,
396 0 : "'mimeEntries' member of FakePluginTagInit");
397 : }
398 :
399 0 : if (!isNull) {
400 0 : if (!JS_GetPropertyById(cx, *object, atomsCache->name_id, temp.ptr())) {
401 0 : return false;
402 : }
403 : }
404 0 : if (!isNull && !temp->isUndefined()) {
405 0 : if (!ConvertJSValueToString(cx, temp.ref(), eStringify, eStringify, mName)) {
406 0 : return false;
407 : }
408 : } else {
409 : static const char16_t data[] = { 0 };
410 0 : mName.Rebind(data, ArrayLength(data) - 1);
411 : }
412 0 : mIsAnyMemberPresent = true;
413 :
414 0 : if (!isNull) {
415 0 : if (!JS_GetPropertyById(cx, *object, atomsCache->niceName_id, temp.ptr())) {
416 0 : return false;
417 : }
418 : }
419 0 : if (!isNull && !temp->isUndefined()) {
420 0 : if (!ConvertJSValueToString(cx, temp.ref(), eStringify, eStringify, mNiceName)) {
421 0 : return false;
422 : }
423 : } else {
424 : static const char16_t data[] = { 0 };
425 0 : mNiceName.Rebind(data, ArrayLength(data) - 1);
426 : }
427 0 : mIsAnyMemberPresent = true;
428 :
429 0 : if (!isNull) {
430 0 : if (!JS_GetPropertyById(cx, *object, atomsCache->sandboxScript_id, temp.ptr())) {
431 0 : return false;
432 : }
433 : }
434 0 : if (!isNull && !temp->isUndefined()) {
435 0 : if (!ConvertJSValueToString(cx, temp.ref(), eStringify, eStringify, mSandboxScript)) {
436 0 : return false;
437 : }
438 : } else {
439 : static const char16_t data[] = { 0 };
440 0 : mSandboxScript.Rebind(data, ArrayLength(data) - 1);
441 : }
442 0 : mIsAnyMemberPresent = true;
443 :
444 0 : if (!isNull) {
445 0 : if (!JS_GetPropertyById(cx, *object, atomsCache->version_id, temp.ptr())) {
446 0 : return false;
447 : }
448 : }
449 0 : if (!isNull && !temp->isUndefined()) {
450 0 : if (!ConvertJSValueToString(cx, temp.ref(), eStringify, eStringify, mVersion)) {
451 0 : return false;
452 : }
453 : } else {
454 : static const char16_t data[] = { 0 };
455 0 : mVersion.Rebind(data, ArrayLength(data) - 1);
456 : }
457 0 : mIsAnyMemberPresent = true;
458 0 : return true;
459 : }
460 :
461 : bool
462 0 : FakePluginTagInit::Init(const nsAString& aJSON)
463 : {
464 0 : AutoJSAPI jsapi;
465 0 : JSObject* cleanGlobal = SimpleGlobalObject::Create(SimpleGlobalObject::GlobalType::BindingDetail);
466 0 : if (!cleanGlobal) {
467 0 : return false;
468 : }
469 0 : if (!jsapi.Init(cleanGlobal)) {
470 0 : return false;
471 : }
472 0 : JSContext* cx = jsapi.cx();
473 0 : JS::Rooted<JS::Value> json(cx);
474 0 : bool ok = ParseJSON(cx, aJSON, &json);
475 0 : NS_ENSURE_TRUE(ok, false);
476 0 : return Init(cx, json);
477 : }
478 :
479 : bool
480 0 : FakePluginTagInit::ToObjectInternal(JSContext* cx, JS::MutableHandle<JS::Value> rval) const
481 : {
482 0 : FakePluginTagInitAtoms* atomsCache = GetAtomCache<FakePluginTagInitAtoms>(cx);
483 0 : if (!*reinterpret_cast<jsid**>(atomsCache) && !InitIds(cx, atomsCache)) {
484 0 : return false;
485 : }
486 :
487 0 : JS::Rooted<JSObject*> obj(cx, JS_NewPlainObject(cx));
488 0 : if (!obj) {
489 0 : return false;
490 : }
491 0 : rval.set(JS::ObjectValue(*obj));
492 :
493 : do {
494 : // block for our 'break' successCode and scope for 'temp' and 'currentValue'
495 0 : JS::Rooted<JS::Value> temp(cx);
496 0 : nsString const & currentValue = mDescription;
497 0 : if (!xpc::NonVoidStringToJsval(cx, currentValue, &temp)) {
498 0 : return false;
499 : }
500 0 : if (!JS_DefinePropertyById(cx, obj, atomsCache->description_id, temp, JSPROP_ENUMERATE)) {
501 0 : return false;
502 : }
503 0 : break;
504 : } while(0);
505 :
506 : do {
507 : // block for our 'break' successCode and scope for 'temp' and 'currentValue'
508 0 : JS::Rooted<JS::Value> temp(cx);
509 0 : nsString const & currentValue = mFileName;
510 0 : if (!xpc::NonVoidStringToJsval(cx, currentValue, &temp)) {
511 0 : return false;
512 : }
513 0 : if (!JS_DefinePropertyById(cx, obj, atomsCache->fileName_id, temp, JSPROP_ENUMERATE)) {
514 0 : return false;
515 : }
516 0 : break;
517 : } while(0);
518 :
519 : do {
520 : // block for our 'break' successCode and scope for 'temp' and 'currentValue'
521 0 : JS::Rooted<JS::Value> temp(cx);
522 0 : nsString const & currentValue = mFullPath;
523 0 : if (!xpc::NonVoidStringToJsval(cx, currentValue, &temp)) {
524 0 : return false;
525 : }
526 0 : if (!JS_DefinePropertyById(cx, obj, atomsCache->fullPath_id, temp, JSPROP_ENUMERATE)) {
527 0 : return false;
528 : }
529 0 : break;
530 : } while(0);
531 :
532 : do {
533 : // block for our 'break' successCode and scope for 'temp' and 'currentValue'
534 0 : JS::Rooted<JS::Value> temp(cx);
535 0 : nsString const & currentValue = mHandlerURI;
536 0 : if (!xpc::NonVoidStringToJsval(cx, currentValue, &temp)) {
537 0 : return false;
538 : }
539 0 : if (!JS_DefinePropertyById(cx, obj, atomsCache->handlerURI_id, temp, JSPROP_ENUMERATE)) {
540 0 : return false;
541 : }
542 0 : break;
543 : } while(0);
544 :
545 : do {
546 : // block for our 'break' successCode and scope for 'temp' and 'currentValue'
547 0 : JS::Rooted<JS::Value> temp(cx);
548 0 : Sequence<FakePluginMimeEntry> const & currentValue = mMimeEntries;
549 :
550 0 : uint32_t length = currentValue.Length();
551 0 : JS::Rooted<JSObject*> returnArray(cx, JS_NewArrayObject(cx, length));
552 0 : if (!returnArray) {
553 0 : return false;
554 : }
555 : // Scope for 'tmp'
556 : {
557 0 : JS::Rooted<JS::Value> tmp(cx);
558 0 : for (uint32_t sequenceIdx0 = 0; sequenceIdx0 < length; ++sequenceIdx0) {
559 : // Control block to let us common up the JS_DefineElement calls when there
560 : // are different ways to succeed at wrapping the object.
561 : do {
562 0 : if (!currentValue[sequenceIdx0].ToObjectInternal(cx, &tmp)) {
563 0 : return false;
564 : }
565 0 : break;
566 : } while (0);
567 0 : if (!JS_DefineElement(cx, returnArray, sequenceIdx0, tmp,
568 : JSPROP_ENUMERATE)) {
569 0 : return false;
570 : }
571 : }
572 : }
573 0 : temp.setObject(*returnArray);
574 0 : if (!JS_DefinePropertyById(cx, obj, atomsCache->mimeEntries_id, temp, JSPROP_ENUMERATE)) {
575 0 : return false;
576 : }
577 0 : break;
578 : } while(0);
579 :
580 : do {
581 : // block for our 'break' successCode and scope for 'temp' and 'currentValue'
582 0 : JS::Rooted<JS::Value> temp(cx);
583 0 : nsString const & currentValue = mName;
584 0 : if (!xpc::NonVoidStringToJsval(cx, currentValue, &temp)) {
585 0 : return false;
586 : }
587 0 : if (!JS_DefinePropertyById(cx, obj, atomsCache->name_id, temp, JSPROP_ENUMERATE)) {
588 0 : return false;
589 : }
590 0 : break;
591 : } while(0);
592 :
593 : do {
594 : // block for our 'break' successCode and scope for 'temp' and 'currentValue'
595 0 : JS::Rooted<JS::Value> temp(cx);
596 0 : nsString const & currentValue = mNiceName;
597 0 : if (!xpc::NonVoidStringToJsval(cx, currentValue, &temp)) {
598 0 : return false;
599 : }
600 0 : if (!JS_DefinePropertyById(cx, obj, atomsCache->niceName_id, temp, JSPROP_ENUMERATE)) {
601 0 : return false;
602 : }
603 0 : break;
604 : } while(0);
605 :
606 : do {
607 : // block for our 'break' successCode and scope for 'temp' and 'currentValue'
608 0 : JS::Rooted<JS::Value> temp(cx);
609 0 : nsString const & currentValue = mSandboxScript;
610 0 : if (!xpc::NonVoidStringToJsval(cx, currentValue, &temp)) {
611 0 : return false;
612 : }
613 0 : if (!JS_DefinePropertyById(cx, obj, atomsCache->sandboxScript_id, temp, JSPROP_ENUMERATE)) {
614 0 : return false;
615 : }
616 0 : break;
617 : } while(0);
618 :
619 : do {
620 : // block for our 'break' successCode and scope for 'temp' and 'currentValue'
621 0 : JS::Rooted<JS::Value> temp(cx);
622 0 : nsString const & currentValue = mVersion;
623 0 : if (!xpc::NonVoidStringToJsval(cx, currentValue, &temp)) {
624 0 : return false;
625 : }
626 0 : if (!JS_DefinePropertyById(cx, obj, atomsCache->version_id, temp, JSPROP_ENUMERATE)) {
627 0 : return false;
628 : }
629 0 : break;
630 : } while(0);
631 :
632 0 : return true;
633 : }
634 :
635 : bool
636 0 : FakePluginTagInit::ToJSON(nsAString& aJSON) const
637 : {
638 0 : AutoJSAPI jsapi;
639 0 : jsapi.Init();
640 0 : JSContext *cx = jsapi.cx();
641 : // It's safe to use UnprivilegedJunkScopeOrWorkerGlobal here
642 : // because we'll only be creating objects, in ways that have no
643 : // side-effects, followed by a call to JS::ToJSONMaybeSafely,
644 : // which likewise guarantees no side-effects for the sorts of
645 : // things we will pass it.
646 0 : JSAutoCompartment ac(cx, binding_detail::UnprivilegedJunkScopeOrWorkerGlobal());
647 0 : JS::Rooted<JS::Value> val(cx);
648 0 : if (!ToObjectInternal(cx, &val)) {
649 0 : return false;
650 : }
651 0 : JS::Rooted<JSObject*> obj(cx, &val.toObject());
652 0 : return StringifyToJSON(cx, obj, aJSON);
653 : }
654 :
655 : void
656 0 : FakePluginTagInit::TraceDictionary(JSTracer* trc)
657 : {
658 0 : }
659 :
660 : FakePluginTagInit&
661 0 : FakePluginTagInit::operator=(const FakePluginTagInit& aOther)
662 : {
663 0 : mDescription = aOther.mDescription;
664 0 : mFileName = aOther.mFileName;
665 0 : mFullPath = aOther.mFullPath;
666 0 : mHandlerURI = aOther.mHandlerURI;
667 0 : mMimeEntries = aOther.mMimeEntries;
668 0 : mName = aOther.mName;
669 0 : mNiceName = aOther.mNiceName;
670 0 : mSandboxScript = aOther.mSandboxScript;
671 0 : mVersion = aOther.mVersion;
672 0 : return *this;
673 : }
674 :
675 : namespace binding_detail {
676 : } // namespace binding_detail
677 :
678 :
679 : } // namespace dom
680 : } // namespace mozilla
|