Skip to content

Commit

Permalink
Import wpt@ed50cf49edc57e2e2d3b2b0381fc1f1070e23835
Browse files Browse the repository at this point in the history
Using wpt-import in Chromium 3543d97.

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/520464
Reviewed-by: Blink W3C Test Autoroller <blink-w3c-test-autoroller@chromium.org>
Reviewed-by: Quinten Yearsley <qyearsley@chromium.org>
Commit-Queue: Blink W3C Test Autoroller <blink-w3c-test-autoroller@chromium.org>
Cr-Commit-Position: refs/heads/master@{#476321}
  • Loading branch information
chromium-wpt-export-bot authored and Commit Bot committed Jun 1, 2017
1 parent 5e98276 commit 81bd492
Show file tree
Hide file tree
Showing 16 changed files with 936 additions and 83 deletions.
183 changes: 136 additions & 47 deletions third_party/WebKit/LayoutTests/external/WPT_BASE_MANIFEST.json

Large diffs are not rendered by default.

300 changes: 300 additions & 0 deletions third_party/WebKit/LayoutTests/external/wpt/assumptions/ahem-ref.html

Large diffs are not rendered by default.

297 changes: 297 additions & 0 deletions third_party/WebKit/LayoutTests/external/wpt/assumptions/ahem.html

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
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.

Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
<!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>
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@

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(
Expand Down Expand Up @@ -305,6 +305,17 @@
}, `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(
{
Expand Down Expand Up @@ -375,7 +386,9 @@
[
{
supportedMethods: ["basic-card"],
data: ["some-data"],
data: {
supportedTypes: ["debit"],
},
},
],
{
Expand Down Expand Up @@ -410,6 +423,49 @@
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",
Expand Down Expand Up @@ -451,7 +507,11 @@
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(() => {
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -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>
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,6 @@
set -ex

2dcontext/tools/build.sh
assumptions/tools/build.sh
html/tools/build.sh
offscreen-canvas/tools/build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
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.

Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
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.

Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
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.

Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
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.

Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
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.

Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
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.

Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
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.

0 comments on commit 81bd492

Please sign in to comment.