Revision 699383b151a45f102159d95862096a10528c865f authored by Jinho Bang on 20 April 2018, 14:06:41 UTC, committed by Chromium WPT Sync on 20 April 2018, 14:06:41 UTC
Related spec change: https://github.com/w3c/payment-handler/pull/293 Bug: 833535 Change-Id: Id7d0cad0f150a73e2932bd8f81f9e5650830a2c0 Reviewed-on: https://chromium-review.googlesource.com/1013660 Reviewed-by: Ganggui Tang <gogerald@chromium.org> Commit-Queue: Jinho Bang <jinho.bang@samsung.com> Cr-Commit-Position: refs/heads/master@{#552319}
1 parent 55d647f
payment-request-id-attribute.https.html
<!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}-[1-4][0-9a-f]{3}-[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>
![swh spinner](/static/img/swh-spinner.gif)
Computing file changes ...