Update web-platform-tests to revision 9817f7f027fe1e92cc2fce31d6002c4d669918e8

This commit is contained in:
WPT Sync Bot 2018-03-08 20:11:36 -05:00 committed by Josh Matthews
parent 8e52f8a523
commit f3533538ea
2144 changed files with 21364 additions and 11001 deletions

View file

@ -2,3 +2,4 @@
@rsolomakhin
@domenic
@MSFTkihans
@mnoorenberghe

View file

@ -67,23 +67,38 @@ function runManualTest(button, expected = {}) {
<li>
<button onclick="
const expectedAddress = {
country: 'AF',
addressLine: '1 wpt street',
region: '',
city: 'Kabul',
country: 'AU',
regionCode: 'AU-QLD',
addressLine: '55 test st',
city: 'Chapel Hill',
dependentLocality: '',
postalCode: '1001',
postalCode: '6095',
sortingCode: '',
languageCode: 'fa',
languageCode: 'en',
organization: 'w3c',
recipient: 'web platform test',
phone: '+93555555555',
phone: '+61733780000',
};
runManualTest(this, expectedAddress);">
If the requestShipping member is true, then shippingAddress's PaymentAddress must match the expected values.
</button>
"web platform test" as recipient, at address "1 wpt street" in "Kabul, Afghanistan", zip/postal code 1001.
Set the organization to "w3c". Set the phone number to "+93 55 555 5555"
Please use:
<dl>
<dt>Recipient:</dt>
<dd>web platform test</dd>
<dt>Address line:</dt>
<dd>55 test st</dd>
<dt>Country</dt>
<dd>Australia</dd>
<dt>Suburb</dt>
<dd>Chapel Hill</dd>
<dt>postal code </dt>
<dd>6095</dd>
<dt>organization</dt>
<dd>w3c</dd>
<dt>Phone number</dt>
<dd>+61 7 3378 0000</dd>
</dl>
</li>
</ol>
<small>

View file

@ -0,0 +1,39 @@
<!DOCTYPE html>
<meta charset="utf-8">
<title>Tests for PaymentCurrencyAmount's currencySystem</title>
<link rel="help" href="https://www.w3.org/TR/payment-request/#dom-paymentcurrencyamount-currencysystem">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script>
test(() => {
const validAmount = {
value: "0",
currency: "USD",
currencySystem: "urn:iso:std:iso:4217",
}
const validMethods = [{ supportedMethods: "valid-method" }];
const validDetails = {
total: {
label: "",
amount: validAmount,
},
};
// smoke test
const request = new PaymentRequest(validMethods, validDetails);
// real test
assert_throws(new TypeError(), () => {
const invalidAmount = {
...validAmount,
currencySystem: "this will cause the TypeError"
}
const invalidDetails = {
total: {
label: "",
amount: invalidAmount,
},
};
const request = new PaymentRequest(validMethods, invalidDetails);
})
}, "Must throw if it encounters an unknown currencySystem");
</script>

View file

@ -0,0 +1,92 @@
<!DOCTYPE html>
<meta charset="utf-8">
<title>Test for PaymentDetailsBase's shippingOptions member</title>
<link rel="help" href="https://w3c.github.io/payment-request/#dom-paymentdetailsbase-shippingoptions">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script>
setup({ explicit_done: true, explicit_timeout: true });
const validMethods = Object.freeze([
{ supportedMethods: "basic-card" },
{ supportedMethods: "https://apple.com/pay" },
]);
const validAmount = Object.freeze({ currency: "USD", value: "5.00" });
const validTotal = Object.freeze({
label: "label",
amount: validAmount,
});
const validDetails = Object.freeze({ total: validTotal });
const validShippingOption1 = Object.freeze({
id: "fail-if-selected-1",
label: "FAIL if selected 1",
amount: validAmount,
selected: true,
});
const validShippingOption2 = Object.freeze({
id: "fail-if-selected-2",
label: "FAIL if selected 2",
amount: validAmount,
selected: false,
});
const validShippingOption3 = Object.freeze({
id: "pass-if-selected",
label: "THIS MUST BE AUTOMATICALLY SELECTED",
amount: validAmount,
selected: true,
});
function testShippingOptionChanged(button) {
button.disabled = true;
promise_test(async t => {
const detailsWithShippingOptions = {
...validDetails,
shippingOptions: [
validShippingOption1,
validShippingOption2,
validShippingOption3,
],
};
const request = new PaymentRequest(
validMethods,
detailsWithShippingOptions,
{ requestShipping: true }
);
assert_equals(
request.shippingOption,
"pass-if-selected",
"Must be 'pass-if-selected', as the selected member is true"
);
request.onshippingoptionchange = () => {
assert_unreached("onshippingoptionchange fired unexpectedly");
};
const response = await request.show();
assert_equals(response.shippingOption, "pass-if-selected");
response.complete();
}, button.textContent.trim());
done();
}
</script>
<h2>PaymentRequest shippingOption attribute</h2>
<p>
Click on each button in sequence from top to bottom without refreshing the page.
Each button will bring up the Payment Request UI window.
</p>
<p>
When the payment sheet is presented, hit pay.
</p>
<ol>
<li>
<button onclick="testShippingOptionChanged(this)">
When default shipping option is pre-selected, must not fire onshippingoptionchange
and PaymentResponse must reflect the pre-selected option.
</button>
</li>
</ol>
<small>
If you find a buggy test, please <a href="https://github.com/w3c/web-platform-tests/issues">file a bug</a>
and tag one of the <a href="https://github.com/w3c/web-platform-tests/blob/master/payment-request/OWNERS">owners</a>.
</small>

View file

@ -60,6 +60,8 @@ test(() => {
"i488jh6-g18-fck-yb-v7-i",
"x-x-t-t-c34-o",
"basic-card",
// gets coerced to "basic-card", for compat with old version of spec
["basic-card"],
];
for (const validMethod of validMethods) {
try {
@ -105,6 +107,8 @@ test(() => {
" basic-card ",
"this is not supported",
" ",
"foo,var",
["visa","mastercard"], // stringifies to "visa,mastercard"
];
for (const invalidMethod of invalidMethods) {
assert_throws(
@ -116,7 +120,7 @@ test(() => {
`expected RangeError processing invalid standardized PMI "${invalidMethod}"`
);
}
});
}, "Must throw on syntactically invalid standardized payment method identifiers");
test(() => {
const invalidMethods = [

View file

@ -139,7 +139,7 @@ const passModifiers = failModifiers.map(modifier => {
});
// PaymentDetailsInit
const validDetails = Object.freeze({
const failDetails = Object.freeze({
displayItems: failPaymentItems,
id: "this cannot be changed",
modifiers: failModifiers,
@ -156,7 +156,7 @@ const neutralDetails = Object.freeze({
function smokeTest() {
promise_test(async t => {
const request = new PaymentRequest(validMethods, validDetails);
const request = new PaymentRequest(validMethods, failDetails);
await promise_rejects(
t,
new TypeError(),
@ -178,7 +178,7 @@ function runUpdateDetailsAlgorithm(
const testAssertion = buttonElement.textContent.trim();
buttonElement.disabled = true;
promise_test(async t => {
const request = new PaymentRequest(validMethods, validDetails, options);
const request = new PaymentRequest(validMethods, failDetails, options);
const detailsPromise = Promise.resolve(details);
const acceptPromise = request.show(detailsPromise);
assert_equals(request.id, "this cant be changed", "id must never change.");