Coverage Report

Created: 2018-09-25 14:53

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