mirror of
https://github.com/servo/servo.git
synced 2025-09-04 20:18:21 +01:00
Update web-platform-tests to revision 8a2ceb5f18911302b7a5c1cd2791f4ab50ad4326
This commit is contained in:
parent
462c272380
commit
1f531f66ea
5377 changed files with 174916 additions and 84369 deletions
|
@ -0,0 +1,131 @@
|
|||
<!DOCTYPE html>
|
||||
<!-- Copyright © 2017 Mozilla and World Wide Web Consortium, (Massachusetts Institute of Technology, ERCIM, Keio University, Beihang). -->
|
||||
<meta charset="utf-8">
|
||||
<title>Test for validity of payment method identifiers when calling updateWith() method</title>
|
||||
<link rel="help" href="https://www.w3.org/TR/payment-request/#updatewith()-method">
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
<script>
|
||||
"use strict";
|
||||
setup({ explicit_done: true, explicit_timeout: true });
|
||||
const validMethod = Object.freeze({
|
||||
supportedMethods: "https://:@wpt.fyi:443/payment-request",
|
||||
});
|
||||
|
||||
const validMethods = Object.freeze([validMethod]);
|
||||
|
||||
const validAmount = Object.freeze({
|
||||
currency: "USD",
|
||||
value: "1.0",
|
||||
});
|
||||
|
||||
const validTotal = Object.freeze({
|
||||
label: "Default Total",
|
||||
amount: validAmount,
|
||||
});
|
||||
|
||||
const validShippingOption = Object.freeze({
|
||||
id: "standard",
|
||||
label: "Shipping option",
|
||||
amount: validAmount,
|
||||
selected: true,
|
||||
});
|
||||
|
||||
const validDetails = Object.freeze({
|
||||
total: validTotal,
|
||||
shippingOptions: [validShippingOption],
|
||||
});
|
||||
|
||||
const validModifier = Object.freeze({
|
||||
supportedMethods: "basic-card",
|
||||
total: validTotal,
|
||||
});
|
||||
|
||||
test(() => {
|
||||
try {
|
||||
new PaymentRequest(validMethods, validDetails);
|
||||
} catch (err) {
|
||||
done();
|
||||
throw err;
|
||||
}
|
||||
}, "smoke test");
|
||||
|
||||
function manualTest(button, { invalidMethod }) {
|
||||
button.disabled = true;
|
||||
promise_test(async t => {
|
||||
const request = new PaymentRequest(
|
||||
[{ supportedMethods: "basic-card" }],
|
||||
validDetails,
|
||||
{ requestShipping: true }
|
||||
);
|
||||
const listener = ev => {
|
||||
const invalidModifier = Object.assign({}, validModifier, {
|
||||
supportedMethods: invalidMethod,
|
||||
});
|
||||
const invalidDetails = Object.assign({}, validDetails, {
|
||||
modifiers: [validModifier, invalidModifier],
|
||||
});
|
||||
ev.updateWith(invalidDetails);
|
||||
};
|
||||
// We test against a valid and an invalid modifier
|
||||
request.addEventListener("shippingaddresschange", listener, { once: true });
|
||||
const showPromise = request.show();
|
||||
await promise_rejects(t, new RangeError(), showPromise);
|
||||
}, button.textContent.trim());
|
||||
}
|
||||
</script>
|
||||
<h2>updateWith() method: test validity of payment method identifiers.</h2>
|
||||
<p>
|
||||
When shown a payment sheet, select a different address.
|
||||
</p>
|
||||
<ol>
|
||||
<li>
|
||||
<button onclick="manualTest(this, {invalidMethod: 'https://:password@example.com'});">
|
||||
Must throw if the URL has a password.
|
||||
</button>
|
||||
</li>
|
||||
<li>
|
||||
<button onclick="manualTest(this, {invalidMethod: 'https://username@example.com'});">
|
||||
Must throw if the URL has a username.
|
||||
</button>
|
||||
</li>
|
||||
<li>
|
||||
<button onclick="manualTest(this, {invalidMethod: 'https://username:password@example.com/pay'});">
|
||||
Must throw if the URL has a username and a password.
|
||||
</button>
|
||||
</li>
|
||||
<li>
|
||||
<button onclick="manualTest(this, {invalidMethod: 'http://username:password@example.com/pay'});">
|
||||
Must throw if it's http, and has a username and password.
|
||||
</button>
|
||||
</li>
|
||||
<li>
|
||||
<button onclick="manualTest(this, {invalidMethod: 'http://foo.com:100000000/pay'});">
|
||||
Must throw if the URL is invalid (port range).
|
||||
</button>
|
||||
</li>
|
||||
<li>
|
||||
<button onclick="manualTest(this, {invalidMethod: 'basic-💳'});">
|
||||
Must throw if the PMI contains characters that are out of range.
|
||||
</button>
|
||||
</li>
|
||||
<li>
|
||||
<button onclick="manualTest(this, {invalidMethod: 'not-https://wpt.fyi/payment-request'});">
|
||||
Must throw if not https.
|
||||
</button>
|
||||
</li>
|
||||
<li>
|
||||
<button onclick="manualTest(this, {invalidMethod: '¡basic-*-card!'});">
|
||||
Must throw if the standardized PMI contains characters outside the ascii range.
|
||||
</button>
|
||||
</li>
|
||||
<li>
|
||||
<button onclick="manualTest(this, {invalidMethod: 'Basic-Card'}); done();">
|
||||
Must throw if standardized PMI has uppercase characters.
|
||||
</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>
|
Loading…
Add table
Add a link
Reference in a new issue