authentication-invalid-payment-entity-logo.https.html (2799B)
1 <!DOCTYPE html> 2 <meta charset="utf-8"> 3 <title>Test for the 'secure-payment-confirmation' payment method authentication - invalid payment entity logo</title> 4 <link rel="help" href="https://w3c.github.io/secure-payment-confirmation#sctn-steps-to-check-if-a-payment-can-be-made"> 5 <script src="/resources/testharness.js"></script> 6 <script src="/resources/testharnessreport.js"></script> 7 <script src="/resources/testdriver.js"></script> 8 <script src="/resources/testdriver-vendor.js"></script> 9 <script src="utils.sub.js"></script> 10 <script> 11 'use strict'; 12 13 promise_test(async t => { 14 const authenticator = await window.test_driver.add_virtual_authenticator( 15 AUTHENTICATOR_OPTS); 16 t.add_cleanup(() => { 17 return window.test_driver.remove_virtual_authenticator(authenticator); 18 }); 19 20 await window.test_driver.set_spc_transaction_mode("autoAccept"); 21 t.add_cleanup(() => { 22 return window.test_driver.set_spc_transaction_mode("none"); 23 }); 24 25 const credential = await createCredential(); 26 27 const challenge = 'server challenge'; 28 const payeeOrigin = 'https://merchant.com'; 29 const displayName = 'Troycard ***1234'; 30 31 const paymentEntity1Label = 'Payment Entity #1'; 32 const paymentEntity2Label = 'Payment Entity #2'; 33 34 let request = new PaymentRequest([{ 35 supportedMethods: 'secure-payment-confirmation', 36 data: { 37 credentialIds: [credential.rawId], 38 challenge: Uint8Array.from(challenge, c => c.charCodeAt(0)), 39 payeeOrigin, 40 rpId: window.location.hostname, 41 timeout: 60000, 42 instrument: { 43 displayName, 44 icon: ICON_URL, 45 }, 46 paymentEntitiesLogos: [ 47 { 48 url: NONEXISTENT_PAYMENT_ENTITY_LOGO_URL, 49 label: paymentEntity1Label, 50 }, 51 { 52 url: PAYMENT_ENTITY_LOGO_URL, 53 label: paymentEntity2Label, 54 }, 55 ], 56 } 57 }], PAYMENT_DETAILS); 58 59 await test_driver.bless('user activation'); 60 const responsePromise = request.show(); 61 const response = await responsePromise; 62 await response.complete('success'); 63 const cred = response.details; 64 const clientDataJSON = JSON.parse(arrayBufferToString(cred.response.clientDataJSON)); 65 66 // Both PaymentEntityLogos should still be present, but the non-existent url 67 // should have been replaced by an empty string. 68 assert_equals(clientDataJSON.payment.paymentEntitiesLogos.length, 2); 69 assert_equals(clientDataJSON.payment.paymentEntitiesLogos[0].url, ''); 70 assert_equals(clientDataJSON.payment.paymentEntitiesLogos[0].label, paymentEntity1Label); 71 assert_equals(clientDataJSON.payment.paymentEntitiesLogos[1].url, PAYMENT_ENTITY_LOGO_URL); 72 assert_equals(clientDataJSON.payment.paymentEntitiesLogos[1].label, paymentEntity2Label); 73 }, 'SPC authentication with a PaymentEntityLogo that cannot be downloaded.'); 74 </script>