Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 <!doctype html> | |
|
falken
2017/01/24 02:00:51
Can you put a comment here about why is this test
| |
| 2 <meta charset="utf-8"> | |
| 3 <title>Payment App: Test for invoking payment app</title> | |
| 4 <link rel="help" href="https://w3c.github.io/webpayments-payment-apps-api/#payme nt-app-invocation"> | |
| 5 <script src="../../resources/testharness.js"></script> | |
| 6 <script src="../../resources/testharnessreport.js"></script> | |
| 7 <script src="../../serviceworker/resources/test-helpers.js"></script> | |
| 8 <script> | |
| 9 'use strict'; | |
| 10 | |
| 11 promise_test(test => { | |
| 12 const script_url = 'resources/payment-app.js'; | |
| 13 const scope_url = 'resources/'; | |
| 14 | |
| 15 var registration; | |
| 16 var service_worker; | |
| 17 var port; | |
| 18 | |
| 19 return service_worker_unregister_and_register(test, script_url, scope_url) | |
| 20 .then(r => { | |
| 21 registration = r; | |
| 22 service_worker = registration.installing; | |
| 23 return wait_for_state(test, service_worker, 'activated'); | |
| 24 }) | |
| 25 .then(state => { | |
| 26 assert_equals(state, 'activated'); | |
|
falken
2017/01/24 02:00:51
This assert just tests that the helper function is
| |
| 27 return registration.paymentAppManager.setManifest({ | |
| 28 name: 'Payment App', | |
| 29 icon: 'payment-app-icon', | |
| 30 options: [{ | |
| 31 name: 'Visa ****', | |
| 32 icon: 'payment-app-icon', | |
| 33 id: 'payment-app-id', | |
| 34 enabledMethods: ['visa'] | |
| 35 }] | |
| 36 }); | |
| 37 }) | |
| 38 .then(result => { | |
| 39 assert_equals(result, undefined); | |
| 40 var channel = new MessageChannel(); | |
| 41 port = channel.port1; | |
| 42 service_worker.postMessage({port: channel.port2}, [channel.port2]); | |
| 43 return new Promise(resolve => { port.onmessage = resolve; }); | |
|
falken
2017/01/24 02:00:51
If you can, avoid MessageChannel. Just do service_
| |
| 44 }) | |
| 45 .then(e => { | |
| 46 assert_equals(e.data, 'payment_app_ready'); | |
| 47 return new Promise(resolve => { testRunner.getAllPaymentAppIDs(resolve ); }); | |
| 48 }) | |
| 49 .then(ids => { | |
| 50 assert_equals(ids.length, 1); | |
| 51 testRunner.invokePaymentApp(ids[0]); | |
| 52 return new Promise(resolve => { port.onmessage = resolve; }); | |
| 53 }) | |
| 54 .then(e => { | |
| 55 assert_equals(e.data, 'payment_app_quit'); | |
| 56 return service_worker_unregister_and_done(test, scope_url); | |
| 57 }) | |
| 58 .catch(unreached_rejection(test)); | |
|
falken
2017/01/24 02:00:51
This catch isn't needed. Just return the entire pr
| |
| 59 }, 'Payment App Invocation Test'); | |
| 60 | |
| 61 </script> | |
| OLD | NEW |