Commit d5ec4a08 authored by Liquan (Max) Gu's avatar Liquan (Max) Gu Committed by Commit Bot

Revert "[ExpandablePaymentHandler] Add tests: request.abort()"

This reverts commit f0990340.

Reason for revert: the added test is flaky

Original change's description:
> [ExpandablePaymentHandler] Add tests: request.abort()
>
> Context:
> This CL adds a test for payment abortion. The test calls request.abort()
> from the merchant side.
>
> Expectation:
> The test expects that the request.show() promise would be rejected with
> the reason written in the exception message.
>
> Bug: 1042892
>
> Change-Id: Ib764ad689a6b114a45e86d8351086c9a4519fbfe
> Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2040440
> Commit-Queue: Liquan (Max) Gu <maxlg@chromium.org>
> Reviewed-by: Liquan (Max) Gu <maxlg@chromium.org>
> Reviewed-by: Rouslan Solomakhin <rouslan@chromium.org>
> Cr-Commit-Position: refs/heads/master@{#741551}

TBR=rouslan@chromium.org,maxlg@chromium.org

# Not skipping CQ checks because original CL landed > 1 day ago.

Bug: 1042892, 1053877
Change-Id: I4332ba329a13f54aad5b36096b21971df523e95b
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2063664
Commit-Queue: Liquan (Max) Gu <maxlg@chromium.org>
Reviewed-by: default avatarLiquan (Max) Gu <maxlg@chromium.org>
Cr-Commit-Position: refs/heads/master@{#742661}
parent 8cd87c9b
......@@ -44,8 +44,8 @@ class ExpandablePaymentHandlerBrowserTest : public PlatformBrowserTest {
PlatformBrowserTest::SetUpOnMainThread();
}
GURL GetHttpPageUrl(const std::string path) {
return http_server_.GetURL(path);
GURL GetHttpPageUrl() {
return http_server_.GetURL("/maxpay.com/merchant.html");
}
content::WebContents* GetActiveWebContents() {
......@@ -116,8 +116,7 @@ IN_PROC_BROWSER_TEST_F(ExpandablePaymentHandlerBrowserTest,
EXPECT_EQ("open_window_failed",
content::EvalJs(
GetActiveWebContents(),
"launchAndWaitUntilReady('" +
GetHttpPageUrl("/maxpay.com/merchant.html").spec() + "')"));
"launchAndWaitUntilReady('" + GetHttpPageUrl().spec() + "')"));
}
// Make sure openWindow() can be resolved into window client.
......@@ -134,22 +133,5 @@ IN_PROC_BROWSER_TEST_F(ExpandablePaymentHandlerBrowserTest, WindowClientReady) {
content::EvalJs(test_controller_.GetPaymentHandlerWebContents(),
"isWindowClientReady()"));
}
// Make sure merchants can abort the payment.
IN_PROC_BROWSER_TEST_F(ExpandablePaymentHandlerBrowserTest, PaymentAborted) {
std::string expected = "success";
EXPECT_EQ(expected, content::EvalJs(GetActiveWebContents(), "install()"));
EXPECT_EQ("app_is_ready",
content::EvalJs(
GetActiveWebContents(),
"launchAndWaitUntilReady('./payment_handler_window.html')"));
DCHECK(test_controller_.GetPaymentHandlerWebContents());
EXPECT_EQ("aborted",
content::EvalJs(test_controller_.GetPaymentHandlerWebContents(),
"abort()"));
EXPECT_EQ("The website has aborted the payment",
content::EvalJs(GetActiveWebContents(), "getResult()"));
}
} // namespace
} // namespace payments
......@@ -90,11 +90,7 @@ function launchAndWaitUntilReady( // eslint-disable-line no-unused-vars
[{supportedMethods: methodName, data: {url}}],
{total: {label: 'Total', amount: {currency: 'USD', value: '0.01'}}});
request.onpaymentmethodchange = (event) => {
const status = event.methodDetails.status;
if (status === 'abort') {
request.abort();
}
appReadyResolver(status);
appReadyResolver(event.methodDetails.status);
};
resultPromise = request.show();
updateLogView('launched and waiting until app gets ready.');
......
......@@ -12,10 +12,6 @@ self.addEventListener('canmakepayment', (evt) => {
evt.respondWith(true);
});
self.addEventListener('abortpayment', (evt) => {
evt.respondWith(true);
});
self.addEventListener('message', (evt) => {
// Sent from the Payment app.
if (evt.data === 'confirm') {
......@@ -27,7 +23,7 @@ self.addEventListener('message', (evt) => {
} else if (evt.data === 'cancel') {
paymentRequestResponder({methodName, details: {status: 'unknown'}});
return;
} else if (evt.data === 'app_is_ready' || evt.data === 'abort') {
} else if (evt.data === 'app_is_ready') {
paymentRequestEvent.changePaymentMethod(methodName, {
status: evt.data,
});
......
......@@ -7,12 +7,10 @@ found in the LICENSE file.
<meta
name="viewport"
content="width=device-width, initial-scale=1, maximum-scale=1, minimum-scale=1">
<title>Max Pay test</title>
<body>
<button onclick="confirm()">confirm</button>
<button onclick="cancel()">cancel</button>
<button onclick="fail()">fail</button>
<button onclick="abort()">abort</button>
<div>Messages:</div>
<pre id="log"></pre>
</body>
......@@ -42,12 +40,6 @@ function fail() {
return 'failed';
}
function abort() {
navigator.serviceWorker.controller.postMessage('abort');
updateLogView('abort is invoked.');
return 'aborted';
}
function cancel() {
navigator.serviceWorker.controller.postMessage('cancel');
updateLogView('cancel is invoked.');
......@@ -65,7 +57,7 @@ window.onload = function() {
navigator.serviceWorker.addEventListener('message', (evt) => {
if (!evt.data) {
updateLogView('Received an empty message.');
updateLogView('Received an empty message');
return;
}
......
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