Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(160)

Unified Diff: third_party/WebKit/LayoutTests/http/tests/payments/chromium/payment-app-invocation.html

Issue 2646313002: PaymentApp: Implement invokePaymentApp() in renderer side. (Closed)
Patch Set: Created 3 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/LayoutTests/http/tests/payments/chromium/payment-app-invocation.html
diff --git a/third_party/WebKit/LayoutTests/http/tests/payments/chromium/payment-app-invocation.html b/third_party/WebKit/LayoutTests/http/tests/payments/chromium/payment-app-invocation.html
new file mode 100644
index 0000000000000000000000000000000000000000..d075ace69912e261292418342127cb6175265249
--- /dev/null
+++ b/third_party/WebKit/LayoutTests/http/tests/payments/chromium/payment-app-invocation.html
@@ -0,0 +1,61 @@
+<!doctype html>
falken 2017/01/24 02:00:51 Can you put a comment here about why is this test
+<meta charset="utf-8">
+<title>Payment App: Test for invoking payment app</title>
+<link rel="help" href="https://w3c.github.io/webpayments-payment-apps-api/#payment-app-invocation">
+<script src="../../resources/testharness.js"></script>
+<script src="../../resources/testharnessreport.js"></script>
+<script src="../../serviceworker/resources/test-helpers.js"></script>
+<script>
+'use strict';
+
+promise_test(test => {
+ const script_url = 'resources/payment-app.js';
+ const scope_url = 'resources/';
+
+ var registration;
+ var service_worker;
+ var port;
+
+ return service_worker_unregister_and_register(test, script_url, scope_url)
+ .then(r => {
+ registration = r;
+ service_worker = registration.installing;
+ return wait_for_state(test, service_worker, 'activated');
+ })
+ .then(state => {
+ assert_equals(state, 'activated');
falken 2017/01/24 02:00:51 This assert just tests that the helper function is
+ return registration.paymentAppManager.setManifest({
+ name: 'Payment App',
+ icon: 'payment-app-icon',
+ options: [{
+ name: 'Visa ****',
+ icon: 'payment-app-icon',
+ id: 'payment-app-id',
+ enabledMethods: ['visa']
+ }]
+ });
+ })
+ .then(result => {
+ assert_equals(result, undefined);
+ var channel = new MessageChannel();
+ port = channel.port1;
+ service_worker.postMessage({port: channel.port2}, [channel.port2]);
+ return new Promise(resolve => { port.onmessage = resolve; });
falken 2017/01/24 02:00:51 If you can, avoid MessageChannel. Just do service_
+ })
+ .then(e => {
+ assert_equals(e.data, 'payment_app_ready');
+ return new Promise(resolve => { testRunner.getAllPaymentAppIDs(resolve); });
+ })
+ .then(ids => {
+ assert_equals(ids.length, 1);
+ testRunner.invokePaymentApp(ids[0]);
+ return new Promise(resolve => { port.onmessage = resolve; });
+ })
+ .then(e => {
+ assert_equals(e.data, 'payment_app_quit');
+ return service_worker_unregister_and_done(test, scope_url);
+ })
+ .catch(unreached_rejection(test));
falken 2017/01/24 02:00:51 This catch isn't needed. Just return the entire pr
+ }, 'Payment App Invocation Test');
+
+</script>

Powered by Google App Engine
This is Rietveld 408576698