tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

head.js (3708B)


      1 const kTestRoot = getRootDirectory(gTestPath).replace(
      2  "chrome://mochitests/content",
      3  "https://example.com"
      4 );
      5 
      6 function checkSimplePayment(aSimplePayment) {
      7  // checking the passed PaymentMethods parameter
      8  is(
      9    aSimplePayment.paymentMethods.length,
     10    1,
     11    "paymentMethods' length should be 1."
     12  );
     13 
     14  const methodData = aSimplePayment.paymentMethods.queryElementAt(
     15    0,
     16    Ci.nsIPaymentMethodData
     17  );
     18  ok(methodData, "Fail to get payment methodData.");
     19  is(
     20    methodData.supportedMethods,
     21    "basic-card",
     22    "supported method should be 'basic-card'."
     23  );
     24  ok(!methodData.data, "methodData.data should not exist.");
     25 
     26  // checking the passed PaymentDetails parameter
     27  const details = aSimplePayment.paymentDetails;
     28  is(details.id, "simple details", "details.id should be 'simple details'.");
     29  is(
     30    details.totalItem.label,
     31    "Donation",
     32    "total item's label should be 'Donation'."
     33  );
     34  is(
     35    details.totalItem.amount.currency,
     36    "USD",
     37    "total item's currency should be 'USD'."
     38  );
     39  is(
     40    details.totalItem.amount.value,
     41    "55.00",
     42    "total item's value should be '55.00'."
     43  );
     44 
     45  is(
     46    details.displayItems.length,
     47    0,
     48    "details.displayItems should be a zero length array."
     49  );
     50  is(
     51    details.modifiers.length,
     52    0,
     53    "details.modifiers should be a zero length array."
     54  );
     55  is(
     56    details.shippingOptions.length,
     57    0,
     58    "details.shippingOptions should be a zero length array."
     59  );
     60 
     61  // checking the default generated PaymentOptions parameter
     62  const paymentOptions = aSimplePayment.paymentOptions;
     63  ok(!paymentOptions.requestPayerName, "payerName option should be false");
     64  ok(!paymentOptions.requestPayerEmail, "payerEmail option should be false");
     65  ok(!paymentOptions.requestPayerPhone, "payerPhone option should be false");
     66  ok(!paymentOptions.requestShipping, "requestShipping option should be false");
     67  is(
     68    paymentOptions.shippingType,
     69    "shipping",
     70    "shippingType option should be 'shipping'"
     71  );
     72 }
     73 
     74 function checkDupShippingOptionsPayment(aPayment) {
     75  // checking the passed PaymentMethods parameter
     76  is(aPayment.paymentMethods.length, 1, "paymentMethods' length should be 1.");
     77 
     78  const methodData = aPayment.paymentMethods.queryElementAt(
     79    0,
     80    Ci.nsIPaymentMethodData
     81  );
     82  ok(methodData, "Fail to get payment methodData.");
     83  is(
     84    methodData.supportedMethods,
     85    "basic-card",
     86    "methodData.supportedMethod name should be 'basic-card'."
     87  );
     88  ok(!methodData.data, "methodData.data should not exist.");
     89 
     90  // checking the passed PaymentDetails parameter
     91  const details = aPayment.paymentDetails;
     92  is(
     93    details.id,
     94    "duplicate shipping options details",
     95    "details.id should be 'duplicate shipping options details'."
     96  );
     97  is(
     98    details.totalItem.label,
     99    "Donation",
    100    "total item's label should be 'Donation'."
    101  );
    102  is(
    103    details.totalItem.amount.currency,
    104    "USD",
    105    "total item's currency should be 'USD'."
    106  );
    107  is(
    108    details.totalItem.amount.value,
    109    "55.00",
    110    "total item's value should be '55.00'."
    111  );
    112 
    113  const shippingOptions = details.shippingOptions;
    114  is(shippingOptions.length, 0, "shippingOptions' length should be 0.");
    115 
    116  // checking the passed PaymentOptions parameter
    117  const paymentOptions = aPayment.paymentOptions;
    118  ok(paymentOptions.requestPayerName, "payerName option should be true");
    119  ok(paymentOptions.requestPayerEmail, "payerEmail option should be true");
    120  ok(paymentOptions.requestPayerPhone, "payerPhone option should be true");
    121  ok(paymentOptions.requestShipping, "requestShipping option should be true");
    122  is(
    123    paymentOptions.shippingType,
    124    "shipping",
    125    "shippingType option should be 'shipping'"
    126  );
    127 }