File: payment-request-id-attribute.https.html

package info (click to toggle)
thunderbird 1%3A140.5.0esr-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 4,609,032 kB
  • sloc: cpp: 7,672,739; javascript: 5,901,898; ansic: 3,898,899; python: 1,413,347; xml: 653,997; asm: 462,284; java: 180,927; sh: 113,491; makefile: 20,460; perl: 14,288; objc: 13,059; yacc: 4,583; pascal: 3,352; lex: 1,720; ruby: 1,222; exp: 762; sql: 715; awk: 580; php: 436; lisp: 430; sed: 70; csh: 10
file content (39 lines) | stat: -rw-r--r-- 1,499 bytes parent folder | download | duplicates (28)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
<!DOCTYPE html>
<!-- Copyright © 2017 Chromium authors and World Wide Web Consortium, (Massachusetts Institute of Technology, ERCIM, Keio University, Beihang). -->
<meta charset="utf-8">
<title>Test for PaymentRequest id attribute</title>
<link rel="help" href="https://w3c.github.io/payment-request/#constructor">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script>
const methods = [{ supportedMethods: "foo" }];
const total = { label: "label", amount: { currency: "USD", value: "5.00" } };

test(() => {
  const request1 = new PaymentRequest(methods, {
    id: "pass",
    total,
  });
  assert_idl_attribute(request1, "id");
  assert_equals(request1.id, "pass", "Expected PaymentRequest.id to be 'pass'");
}, "PaymentRequest's id attribute's value can be set via PaymentDetailsInit dictionary");

// Test for https://github.com/w3c/payment-request/pull/665
test(() => {
  const uuidRegExp = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
  const request1 = new PaymentRequest(methods, {
    total,
  });
  const request2 = new PaymentRequest(methods, {
    total,
  });
  assert_true(
    uuidRegExp.test(request1.id) && uuidRegExp.test(request2.id) ,
    "Expected PaymentRequest.id be a UUID"
  );
  assert_not_equals(
    request1.id, request2.id,
    "Expected PaymentRequest.id be unique per instance"
  );
}, "PaymentRequest's id attribute must be a UUID when PaymentDetailsInit.id is missing");
</script>