tor-browser

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

payment-request-id-attribute.https.html (1499B)


      1 <!DOCTYPE html>
      2 <!-- Copyright © 2017 Chromium authors and World Wide Web Consortium, (Massachusetts Institute of Technology, ERCIM, Keio University, Beihang). -->
      3 <meta charset="utf-8">
      4 <title>Test for PaymentRequest id attribute</title>
      5 <link rel="help" href="https://w3c.github.io/payment-request/#constructor">
      6 <script src="/resources/testharness.js"></script>
      7 <script src="/resources/testharnessreport.js"></script>
      8 <script>
      9 const methods = [{ supportedMethods: "foo" }];
     10 const total = { label: "label", amount: { currency: "USD", value: "5.00" } };
     11 
     12 test(() => {
     13  const request1 = new PaymentRequest(methods, {
     14    id: "pass",
     15    total,
     16  });
     17  assert_idl_attribute(request1, "id");
     18  assert_equals(request1.id, "pass", "Expected PaymentRequest.id to be 'pass'");
     19 }, "PaymentRequest's id attribute's value can be set via PaymentDetailsInit dictionary");
     20 
     21 // Test for https://github.com/w3c/payment-request/pull/665
     22 test(() => {
     23  const uuidRegExp = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
     24  const request1 = new PaymentRequest(methods, {
     25    total,
     26  });
     27  const request2 = new PaymentRequest(methods, {
     28    total,
     29  });
     30  assert_true(
     31    uuidRegExp.test(request1.id) && uuidRegExp.test(request2.id) ,
     32    "Expected PaymentRequest.id be a UUID"
     33  );
     34  assert_not_equals(
     35    request1.id, request2.id,
     36    "Expected PaymentRequest.id be unique per instance"
     37  );
     38 }, "PaymentRequest's id attribute must be a UUID when PaymentDetailsInit.id is missing");
     39 </script>