Skip to content

Commit

Permalink
Remove unused instrument.set() calls from test support files
Browse files Browse the repository at this point in the history
Bug: 1327265
Change-Id: I2e3d209cae6eca326ff8da0e8d2dc6cef0966d4f
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4184395
Reviewed-by: Nick Burris <nburris@chromium.org>
Commit-Queue: Rouslan Solomakhin <rouslan@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1096783}
  • Loading branch information
rsolomakhin authored and Chromium LUCI CQ committed Jan 25, 2023
1 parent 6d95866 commit 188e782
Show file tree
Hide file tree
Showing 14 changed files with 0 additions and 453 deletions.
17 changes: 0 additions & 17 deletions components/test/data/payments/alicepay.test/app1/index.html

This file was deleted.

74 changes: 0 additions & 74 deletions components/test/data/payments/alicepay.test/app1/index.js

This file was deleted.

17 changes: 0 additions & 17 deletions components/test/data/payments/alicepay.test/app2/index.html

This file was deleted.

74 changes: 0 additions & 74 deletions components/test/data/payments/alicepay.test/app2/index.js

This file was deleted.

Expand Up @@ -5,7 +5,6 @@
<meta name="viewport" content="width=device-width, initial-scale=0.5, maximum-scale=0.5, minimum-scale=0.5">
</head>
<body>
<button onclick="install()">install</button>
<button onclick="addSupportedMethod('https://play.google.com/billing')">addSupportedMethod('https://play.google.com/billing')</button>
<button onclick="createPaymentRequest()">create PaymentRequest</button>
<button onclick="show()">show</button>
Expand Down
27 changes: 0 additions & 27 deletions components/test/data/payments/app_store_billing_tests/index.js
Expand Up @@ -8,33 +8,6 @@ const methodName = window.location.origin + '/method_manifest.json';
let request;
let supportedInstruments = [];

/**
* Install a payment app.
* @return {string} - a message indicating whether the installation is
* successful.
*/
async function install() {
info('installing');

await navigator.serviceWorker.register('empty_app.js');
const registration = await navigator.serviceWorker.ready;
if (!registration.paymentManager) {
return 'No payment handler capability in this browser. Is' +
'chrome://flags/#service-worker-payment-apps enabled?';
}

if (!registration.paymentManager.instruments) {
return 'Payment handler is not fully implemented. ' +
'Cannot set the instruments.';
}
await registration.paymentManager.instruments.set('instrument-key', {
// Chrome uses name and icon from the web app manifest
name: 'MaxPay',
method: methodName,
});
return 'success';
}

/**
* Add a payment method to the payment request.
* @param {string} method - the payment method.
Expand Down
4 changes: 0 additions & 4 deletions components/test/data/payments/bobpay.test/app1/index.html
Expand Up @@ -9,9 +9,5 @@
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=0.5, maximum-scale=0.5, minimum-scale=0.5">
<title>Bob Pay 1</title>
<link rel="manifest" href="../app.json">
</head>
<body>
<script src="index.js"></script>
</body>
</html>
74 changes: 0 additions & 74 deletions components/test/data/payments/bobpay.test/app1/index.js

This file was deleted.

Expand Up @@ -8,7 +8,6 @@
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=0.5, maximum-scale=0.5, minimum-scale=0.5">
<link rel="manifest" href="app_manifest.json">
<title>Enforce Full Delegation Tests</title>
</head>
<style>
Expand All @@ -17,8 +16,6 @@
}
</style>
<body>
<div><button onclick="install()">install</button>
<button onclick="uninstall()">uninstall</button></div>
<div><button onclick="enableDelegations(['payerName'])">enableDelegations(['payerName'])</button></div>
<div><button onclick="addSupportedMethod('https://play.google.com/billing')">addSupportedMethod('https://play.google.com/billing')</button>
<button onclick="addDefaultSupportedMethod()">addDefaultSupportedMethod()</button></div>
Expand Down
Expand Up @@ -11,68 +11,6 @@ const SW_SRC_URL = 'app.js';
let request;
let supportedInstruments = [];

/**
* Installs the given payment handler with the given payment method.
* @param {string} method - The payment method that this service worker
* supports.
* @return {Promise<string>} - 'success' or error message on failure.
*/
async function install(method = METHOD_NAME) {
info('installing');
try {
const registration = await navigator.serviceWorker.register(SW_SRC_URL);
await activation(registration);
await registration.paymentManager.instruments.set(
'instrument-for-' + method, {name: 'Instrument Name', method});
return 'success';
} catch (e) {
return e.message;
}
}

/**
* Returns a promise that resolves when the service worker of the given
* registration has activated.
* @param {ServiceWorkerRegistration} registration - A service worker
* registration.
* @return {Promise<void>} - A promise that resolves when the service worker
* has activated.
*/
async function activation(registration) {
return new Promise((resolve) => {
if (registration.active) {
resolve();
return;
}
registration.addEventListener('updatefound', () => {
const newWorker = registration.installing;
if (newWorker.state == 'activated') {
resolve();
return;
}
newWorker.addEventListener('statechange', () => {
if (newWorker.state == 'activated') {
resolve();
}
});
});
});
}

/**
* Uninstall the payment handler.
* @return {string} - the message about the uninstallation result.
*/
async function uninstall() {
info('uninstall');
let registration = await navigator.serviceWorker.getRegistration(SW_SRC_URL);
if (!registration) {
return 'The Payment handler has not been installed yet.';
}
await registration.unregister();
return 'success';
}

/**
* Delegates handling of the provided options to the payment handler.
* @param {Array<string>} delegations The list of payment options to delegate.
Expand Down

0 comments on commit 188e782

Please sign in to comment.