authentication-rejected.https.html (2812B)
1 <!DOCTYPE html> 2 <meta charset="utf-8"> 3 <title>Test for the 'secure-payment-confirmation' payment method authentication - user rejects case</title> 4 <link rel="help" href="https://w3c.github.io/secure-payment-confirmation/#sctn-transaction-confirmation-outcome"> 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("autoReject"); 21 t.add_cleanup(() => { 22 return window.test_driver.set_spc_transaction_mode("none"); 23 }); 24 25 const challenge = 'server challenge'; 26 const payeeOrigin = 'https://merchant.com'; 27 const displayName = 'Troycard ***1234'; 28 const request = new PaymentRequest([{ 29 supportedMethods: 'secure-payment-confirmation', 30 data: { 31 credentialIds: [Uint8Array.from('nonexistent', c => c.charCodeAt(0))], 32 challenge: Uint8Array.from(challenge, c => c.charCodeAt(0)), 33 rpId: window.location.hostname, 34 payeeOrigin, 35 timeout: 60000, 36 instrument: { 37 displayName, 38 icon: ICON_URL, 39 }, 40 } 41 }], PAYMENT_DETAILS); 42 43 await test_driver.bless('user activation'); 44 return promise_rejects_dom(t, "AbortError", request.show()); 45 }, 'Rejected SPC authentication without matching credential'); 46 47 promise_test(async t => { 48 const authenticator = await window.test_driver.add_virtual_authenticator( 49 AUTHENTICATOR_OPTS); 50 t.add_cleanup(() => { 51 return window.test_driver.remove_virtual_authenticator(authenticator); 52 }); 53 54 await window.test_driver.set_spc_transaction_mode("autoReject"); 55 t.add_cleanup(() => { 56 return window.test_driver.set_spc_transaction_mode("none"); 57 }); 58 59 const credential = await createCredential(); 60 61 const challenge = 'server challenge'; 62 const payeeOrigin = 'https://merchant.com'; 63 const displayName = 'Troycard ***1234'; 64 const request = new PaymentRequest([{ 65 supportedMethods: 'secure-payment-confirmation', 66 data: { 67 credentialIds: [credential.rawId], 68 challenge: Uint8Array.from(challenge, c => c.charCodeAt(0)), 69 rpId: window.location.hostname, 70 payeeOrigin, 71 timeout: 60000, 72 instrument: { 73 displayName, 74 icon: ICON_URL, 75 }, 76 } 77 }], PAYMENT_DETAILS); 78 79 await test_driver.bless('user activation'); 80 return promise_rejects_dom(t, "AbortError", request.show()); 81 }, 'Rejected SPC authentication when credential matched'); 82 </script>