Commit 81bd4926 authored by Blink W3C Test Autoroller's avatar Blink W3C Test Autoroller Committed by Commit Bot

Import wpt@ed50cf49edc57e2e2d3b2b0381fc1f1070e23835

Using wpt-import in Chromium 3543d97c.

Build: https://build.chromium.org/p/chromium.infra.cron/builders/wpt-importer/builds/136

Background: https://chromium.googlesource.com/chromium/src/+/master/docs/testing/web_platform_tests.md

Note to sheriffs: If this CL causes a small number of new layout
test failures, it may be easier to add lines to TestExpectations
rather than reverting.
Directory owners for changes in this CL:
rouslan@chromium.org, mathp@chromium.org:
  external/wpt/payment-request

TBR=qyearsley@chromium.org
NOEXPORT=true

Change-Id: Ie7007ae595b681df80870b9bc4a9b759dfc8c24c
Reviewed-on: https://chromium-review.googlesource.com/520464Reviewed-by: default avatarBlink W3C Test Autoroller <blink-w3c-test-autoroller@chromium.org>
Reviewed-by: default avatarQuinten Yearsley <qyearsley@chromium.org>
Commit-Queue: Blink W3C Test Autoroller <blink-w3c-test-autoroller@chromium.org>
Cr-Commit-Position: refs/heads/master@{#476321}
parent 5e98276d
This is a testharness.js-based test.
PASS Throws if the promise [[state]] is not "interactive"
FAIL Calling abort must not change the [[state]] until after "interactive" assert_true: Unexpected promise rejection: Request failed expected true got false
FAIL calling .abort() causes acceptPromise to reject and closes the request. assert_true: Unexpected promise rejection: Request failed expected true got false
Harness: the test ran to completion.
<!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.abort() method</title>
<link rel="help" href="https://w3c.github.io/browser-payment-api/#abort-method">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script>
"use strict";
setup(() => {}, {
// Ignore unhandled rejections resulting from .show()'s acceptPromise
// not being explicitly handled.
allow_uncaught_exception: true,
});
const basicCard = Object.freeze({ supportedMethods: ["basic-card"] });
const defaultMethods = Object.freeze([basicCard]);
const defaultDetails = Object.freeze({
total: {
label: "Total",
amount: {
currency: "USD",
value: "1.00",
},
},
});
promise_test(async t => {
// request is in "created" state
const request = new PaymentRequest(defaultMethods, defaultDetails);
await promise_rejects(t, "InvalidStateError", request.abort());
}, `Throws if the promise [[state]] is not "interactive"`);
promise_test(async t => {
// request is in "created" state.
const request = new PaymentRequest(defaultMethods, defaultDetails);
await promise_rejects(t, "InvalidStateError", request.abort());
// Call it again, for good measure.
await promise_rejects(t, "InvalidStateError", request.abort());
// The request's state is "created", so let's show it
// which changes the state to "interactive.".
request.show();
// Let's set request the state to "closed" by calling .abort()
try {
await request.abort();
} catch (err) {
assert_true(false, "Unexpected promise rejection: " + err.message);
}
// The request is now "closed", so...
await promise_rejects(t, "InvalidStateError", request.abort());
}, `Calling abort must not change the [[state]] until after "interactive"`);
promise_test(async t => {
const request = new PaymentRequest(defaultMethods, defaultDetails);
const acceptPromise = request.show();
try {
await request.abort();
} catch (err) {
assert_true(false, "Unexpected promise rejection: " + err.message);
}
await promise_rejects(t, "AbortError", acceptPromise);
// As request is now "closed", trying to show it will fail
await promise_rejects(t, "InvalidStateError", request.show());
}, "calling .abort() causes acceptPromise to reject and closes the request.");
</script>
......@@ -41,7 +41,7 @@ test(() => {
test(() => {
const newDetails = Object.assign({}, defaultDetails, {
id: "".padStart(100000000, "\n test 123 \t \n "),
id: "".padStart(1024, "a"),
});
const request = new PaymentRequest(defaultMethods, newDetails);
assert_equals(
......@@ -305,6 +305,17 @@ for (const amount of invalidTotalAmounts) {
}, `If details.total.amount.value is not a valid decimal monetary value (in this case "${amount}"), then throw a TypeError`);
}
for (const prop in ["displayItems", "shippingOptions", "modifiers"]) {
test(() => {
try {
const details = Object.assign({}, defaultDetails, { [prop]: [] });
new PaymentRequest(defaultMethods, details);
} catch (err) {
assert_true(false, `${prop} can be zero length`);
}
}, `PaymentDetailsBase.${prop} can be 0 length`);
}
test(() => {
assert_throws(
{
......@@ -375,7 +386,9 @@ test(() => {
[
{
supportedMethods: ["basic-card"],
data: ["some-data"],
data: {
supportedTypes: ["debit"],
},
},
],
{
......@@ -410,6 +423,49 @@ test(() => {
assert_false(itThrows, "shouldn't throw when given a negative value");
}, "Negative values are allowed for displayItems.amount.value, irrespective of total amount");
test(() => {
let itThrows = false;
const largeMoney = "1".repeat(510);
try {
new PaymentRequest(
[
{
supportedMethods: ["basic-card"],
},
],
{
total: {
label: "",
amount: {
currency: "USD",
value: `${largeMoney}.${largeMoney}`,
},
},
displayItems: [
{
label: "",
amount: {
currency: "USD",
value: `-${largeMoney}`,
},
},
{
label: "",
amount: {
currency: "AUD",
value: `-${largeMoney}.${largeMoney}`,
},
},
],
}
);
} catch (err) {
itThrows = true;
}
assert_false(itThrows, "shouldn't throw when given absurd monetary values");
}, "it handles high precision currency values without throwing");
// Process shipping options:
const defaultAmount = Object.freeze({
currency: "USD",
......@@ -451,7 +507,11 @@ test(() => {
const shippingOptions = [defaultShippingOption];
const details = Object.assign({}, defaultDetails, { shippingOptions });
const request = new PaymentRequest(defaultMethods, details);
assert_equals(request.shippingOption, null, "request.shippingOption must be null");
assert_equals(
request.shippingOption,
null,
"request.shippingOption must be null"
);
}, "If there is no selected shipping option, then PaymentRequest.shippingOption remains null");
test(() => {
......
......@@ -7,34 +7,34 @@
<script src="/resources/testharnessreport.js"></script>
<script>
'use strict';
promise_test(t => {
const request1 = new PaymentRequest([{
supportedMethods: ['basic-card'],
}], {
total: {
label: 'request1',
amount: {
currency: 'USD',
value: '1.00',
},
},
});
const request2 = new PaymentRequest([{
supportedMethods: ['basic-card'],
}], {
total: {
label: 'request2',
amount: {
currency: 'USD',
value: '1.00',
},
const basicCard = Object.freeze({ supportedMethods: ["basic-card"] });
const defaultMethods = Object.freeze([basicCard]);
const defaultDetails = Object.freeze({
total: {
label: "Total",
amount: {
currency: "USD",
value: "1.00",
},
});
const result = promise_rejects(t, null, request1.show());
promise_rejects(t, 'AbortError', request2.show())
.then(t.step_func(() => request1.abort()));
return result;
}, 'If the user agent\'s "payment request is showing" boolean is true, ' +
'then return a promise rejected with an "AbortError" DOMException.');
},
});
promise_test(async t => {
const request = new PaymentRequest(defaultMethods, defaultDetails);
const acceptPromise = request.show(); // Sets state to "interactive"
await promise_rejects(t, "InvalidStateError", request.show());
await request.abort();
await promise_rejects(t, "AbortError", acceptPromise);
}, `Throws if the promise [[state]] is not "created"`);
promise_test(async t => {
const request1 = new PaymentRequest(defaultMethods, defaultDetails);
const request2 = new PaymentRequest(defaultMethods, defaultDetails);
const acceptPromise1 = request1.show();
const acceptPromise2 = request2.show();
await promise_rejects(t, "AbortError", acceptPromise2);
await request1.abort();
await promise_rejects(t, "AbortError", acceptPromise1);
}, `If the user agent's "payment request is showing" boolean is true, then return a promise rejected with an "AbortError" DOMException.`);
</script>
......@@ -2,5 +2,6 @@
set -ex
2dcontext/tools/build.sh
assumptions/tools/build.sh
html/tools/build.sh
offscreen-canvas/tools/build.sh
This is a testharness.js-based test.
FAIL If the user agent's "payment request is showing" boolean is true, then return a promise rejected with an "AbortError" DOMException. Test bug: need to pass exception to assert_throws()
FAIL Throws if the promise [[state]] is not "created" promise_test: Unhandled rejection with value: object "UnknownError: Request failed"
FAIL If the user agent's "payment request is showing" boolean is true, then return a promise rejected with an "AbortError" DOMException. assert_throws: function "function () { throw e }" threw object "UnknownError: Request failed" that is not a DOMException AbortError: property "code" is equal to 0, expected 20
Harness: the test ran to completion.
This is a testharness.js-based test.
FAIL Throws if the promise [[state]] is not "created" promise_test: Unhandled rejection with value: object "UnknownError: Request failed"
FAIL If the user agent's "payment request is showing" boolean is true, then return a promise rejected with an "AbortError" DOMException. assert_throws: function "function () { throw e }" threw object "UnknownError: Request failed" that is not a DOMException AbortError: property "code" is equal to 0, expected 20
Harness: the test ran to completion.
This is a testharness.js-based test.
Harness Error. harness_status.status = 1 , harness_status.message = Request failed
FAIL Throws if the promise [[state]] is not "created" promise_test: Unhandled rejection with value: object "UnknownError: Request failed"
FAIL If the user agent's "payment request is showing" boolean is true, then return a promise rejected with an "AbortError" DOMException. assert_throws: function "function () { throw e }" threw object "UnknownError: Request failed" that is not a DOMException AbortError: property "code" is equal to 0, expected 20
Harness: the test ran to completion.
This is a testharness.js-based test.
Harness Error. harness_status.status = 1 , harness_status.message = Request failed
FAIL Throws if the promise [[state]] is not "created" promise_test: Unhandled rejection with value: object "UnknownError: Request failed"
FAIL If the user agent's "payment request is showing" boolean is true, then return a promise rejected with an "AbortError" DOMException. assert_throws: function "function () { throw e }" threw object "UnknownError: Request failed" that is not a DOMException AbortError: property "code" is equal to 0, expected 20
Harness: the test ran to completion.
This is a testharness.js-based test.
Harness Error. harness_status.status = 1 , harness_status.message = Request failed
FAIL Throws if the promise [[state]] is not "created" promise_test: Unhandled rejection with value: object "UnknownError: Request failed"
FAIL If the user agent's "payment request is showing" boolean is true, then return a promise rejected with an "AbortError" DOMException. assert_throws: function "function () { throw e }" threw object "UnknownError: Request failed" that is not a DOMException AbortError: property "code" is equal to 0, expected 20
Harness: the test ran to completion.
This is a testharness.js-based test.
FAIL Throws if the promise [[state]] is not "created" promise_test: Unhandled rejection with value: object "UnknownError: Request failed"
FAIL If the user agent's "payment request is showing" boolean is true, then return a promise rejected with an "AbortError" DOMException. assert_throws: function "function () { throw e }" threw object "UnknownError: Request failed" that is not a DOMException AbortError: property "code" is equal to 0, expected 20
Harness: the test ran to completion.
This is a testharness.js-based test.
Harness Error. harness_status.status = 1 , harness_status.message = Request failed
FAIL Throws if the promise [[state]] is not "created" promise_test: Unhandled rejection with value: object "UnknownError: Request failed"
FAIL If the user agent's "payment request is showing" boolean is true, then return a promise rejected with an "AbortError" DOMException. assert_throws: function "function () { throw e }" threw object "UnknownError: Request failed" that is not a DOMException AbortError: property "code" is equal to 0, expected 20
Harness: the test ran to completion.
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment