| Index: third_party/WebKit/LayoutTests/external/wpt/payment-request/payment-request-constructor.https.html
|
| diff --git a/third_party/WebKit/LayoutTests/external/wpt/payment-request/payment-request-constructor.https.html b/third_party/WebKit/LayoutTests/external/wpt/payment-request/payment-request-constructor.https.html
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..093d1113321f1c44448ffef447e06dd2bb962f1e
|
| --- /dev/null
|
| +++ b/third_party/WebKit/LayoutTests/external/wpt/payment-request/payment-request-constructor.https.html
|
| @@ -0,0 +1,238 @@
|
| +<!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 Constructor</title>
|
| +<link rel="help" href="https://w3c.github.io/browser-payment-api/#constructor">
|
| +<script src="/resources/testharness.js"></script>
|
| +<script src="/resources/testharnessreport.js"></script>
|
| +<script>
|
| +'use strict';
|
| +
|
| +test(() => {
|
| + assert_equals((new PaymentRequest([{
|
| + supportedMethods: ['basic-card'],
|
| + }], {
|
| + id: 'foo',
|
| + total: {
|
| + label: '',
|
| + amount: {
|
| + currency: 'USD',
|
| + value: '1.00',
|
| + },
|
| + },
|
| + })).id, 'foo');
|
| +}, 'Use provided request ID');
|
| +
|
| +test(() => {
|
| + assert_throws({
|
| + name: 'TypeError',
|
| + },
|
| + () => {
|
| + new PaymentRequest([], {
|
| + total: {
|
| + label: '',
|
| + amount: {
|
| + currency: 'USD',
|
| + value: '1.00',
|
| + },
|
| + },
|
| + });
|
| + });
|
| +}, 'If the length of the methodData sequence is zero, then throw a TypeError');
|
| +
|
| +test(() => {
|
| + assert_throws({
|
| + name: 'TypeError',
|
| + },
|
| + () => {
|
| + new PaymentRequest([{
|
| + supportedMethods: [],
|
| + }], {
|
| + total: {
|
| + label: '',
|
| + amount: {
|
| + currency: 'USD',
|
| + value: '1.00',
|
| + },
|
| + },
|
| + });
|
| + });
|
| +}, 'If the length of the paymentMethod.supportedMethods sequence is zero, ' +
|
| + 'then throw a TypeError');
|
| +
|
| +const invalidMonetaryAmounts = ['-', 'notdigits', 'ALSONOTDIGITS', '10.', '.99',
|
| + '-10.', '-.99', '10-', '1-0', '1.0.0', '1/3', '', null,
|
| +];
|
| +for (const amount of invalidMonetaryAmounts) {
|
| + test(() => {
|
| + assert_throws({
|
| + name: 'TypeError',
|
| + },
|
| + () => {
|
| + new PaymentRequest([{
|
| + supportedMethods: ['basic-card'],
|
| + }], {
|
| + total: {
|
| + label: '',
|
| + amount: {
|
| + currency: 'USD',
|
| + value: amount,
|
| + },
|
| + },
|
| + });
|
| + });
|
| + }, 'If details.total.amount.value is not a valid decimal monetary value ' +
|
| + '(in this case "' + amount + '"), then throw a TypeError');
|
| +}
|
| +
|
| +test(() => {
|
| + assert_throws({
|
| + name: 'TypeError',
|
| + },
|
| + () => {
|
| + new PaymentRequest([{
|
| + supportedMethods: ['basic-card'],
|
| + }], {
|
| + total: {
|
| + label: '',
|
| + amount: {
|
| + currency: 'USD',
|
| + value: '-1.00',
|
| + },
|
| + },
|
| + });
|
| + });
|
| +}, 'If the first character of details.total.amount.value is ' +
|
| + 'U+002D HYPHEN-MINUS, then throw a TypeError');
|
| +
|
| +for (const amount of invalidMonetaryAmounts) {
|
| + test(() => {
|
| + assert_throws({
|
| + name: 'TypeError',
|
| + },
|
| + () => {
|
| + new PaymentRequest([{
|
| + supportedMethods: ['basic-card'],
|
| + }], {
|
| + total: {
|
| + label: '',
|
| + amount: {
|
| + currency: 'USD',
|
| + value: '1.00',
|
| + },
|
| + },
|
| + displayItems: [{
|
| + label: '',
|
| + amount: {
|
| + currency: 'USD',
|
| + value: amount,
|
| + },
|
| + }],
|
| + });
|
| + });
|
| + }, 'For each item in details.displayItems: if item.amount.value is not ' +
|
| + 'a valid decimal monetary value (in this case "' + amount +
|
| + '"), then throw a TypeError');
|
| +}
|
| +
|
| +test(() => {
|
| + assert_throws({
|
| + name: 'TypeError',
|
| + },
|
| + () => {
|
| + new PaymentRequest([{
|
| + supportedMethods: ['basic-card'],
|
| + }], {});
|
| + });
|
| +}, 'Total is required');
|
| +
|
| +test(() => {
|
| + assert_throws({
|
| + name: 'TypeError',
|
| + },
|
| + () => {
|
| + new PaymentRequest([{
|
| + supportedMethods: ['basic-card'],
|
| + }], {
|
| + total: {
|
| + amount: {
|
| + currency: 'USD',
|
| + value: '1.00',
|
| + },
|
| + },
|
| + });
|
| + });
|
| +}, 'Label is required');
|
| +
|
| +test(() => {
|
| + assert_throws({
|
| + name: 'TypeError',
|
| + },
|
| + () => {
|
| + new PaymentRequest([{
|
| + supportedMethods: ['basic-card'],
|
| + }], {
|
| + total: {
|
| + label: '',
|
| + },
|
| + });
|
| + });
|
| +}, 'Amount is required');
|
| +
|
| +test(() => {
|
| + assert_throws({
|
| + name: 'TypeError',
|
| + },
|
| + () => {
|
| + new PaymentRequest([{
|
| + supportedMethods: ['basic-card'],
|
| + }], {
|
| + total: {
|
| + label: '',
|
| + amount: {
|
| + currency: 'USD',
|
| + },
|
| + },
|
| + });
|
| + });
|
| +}, 'Amount value is required');
|
| +
|
| +test(() => {
|
| + assert_throws({
|
| + name: 'TypeError',
|
| + },
|
| + () => {
|
| + new PaymentRequest([{
|
| + supportedMethods: ['basic-card'],
|
| + }], {
|
| + total: {
|
| + label: '',
|
| + amount: {
|
| + value: '1.00',
|
| + },
|
| + },
|
| + });
|
| + });
|
| +}, 'Amount currency is required');
|
| +
|
| +test(() => {
|
| + assert_throws({
|
| + name: 'TypeError',
|
| + },
|
| + () => {
|
| + new PaymentRequest([{
|
| + supportedMethods: ['basic-card'],
|
| + }], {
|
| + total: {
|
| + label: '',
|
| + amount: {
|
| + currency: 'USD',
|
| + value: '1.00',
|
| + },
|
| + },
|
| + }, {
|
| + shippingType: 'invalid',
|
| + });
|
| + });
|
| +}, 'Shipping type should be valid');
|
| +</script>
|
|
|