test_getCreditCardLogo.js (925B)
1 /* Any copyright is dedicated to the Public Domain. 2 http://creativecommons.org/publicdomain/zero/1.0/ */ 3 4 "use strict"; 5 6 add_task(async function test_getCreditCardLogo() { 7 const { CreditCard } = ChromeUtils.importESModule( 8 "resource://gre/modules/CreditCard.sys.mjs" 9 ); 10 // Credit card logos can be either PNG or SVG 11 // so we construct an array that includes both of these file extensions 12 // and test to see if the logo from getCreditCardLogo matches. 13 for (let network of CreditCard.getSupportedNetworks()) { 14 const PATH_PREFIX = "chrome://formautofill/content/third-party/cc-logo-"; 15 let actual = CreditCard.getCreditCardLogo(network); 16 Assert.ok( 17 [".png", ".svg"].map(x => PATH_PREFIX + network + x).includes(actual) 18 ); 19 } 20 let genericLogo = CreditCard.getCreditCardLogo("null"); 21 Assert.equal( 22 genericLogo, 23 "chrome://formautofill/content/icon-credit-card-generic.svg" 24 ); 25 });