-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Bug 1667257 - Detect credit card type by examining IIN part of credit…
… card number r=sgalich Differential Revision: https://phabricator.services.mozilla.com/D164904
- Loading branch information
Showing
17 changed files
with
192 additions
and
189 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
110 changes: 110 additions & 0 deletions
110
...ons/formautofill/test/browser/creditCard/browser_creditCard_submission_autodetect_type.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,110 @@ | ||
/* Any copyright is dedicated to the Public Domain. | ||
http://creativecommons.org/publicdomain/zero/1.0/ */ | ||
|
||
"use strict"; | ||
|
||
add_task(async function test_autodetect_credit_not_set() { | ||
await SpecialPowers.pushPrefEnv({ | ||
set: [[CREDITCARDS_USED_STATUS_PREF, 0]], | ||
}); | ||
const testCard = { | ||
"cc-name": "John Doe", | ||
"cc-number": "4012888888881881", | ||
"cc-exp-month": "06", | ||
"cc-exp-year": "2044", | ||
}; | ||
const expectedData = { | ||
...testCard, | ||
...{ "cc-type": "visa" }, | ||
}; | ||
let onChanged = waitForStorageChangedEvents("add"); | ||
|
||
await BrowserTestUtils.withNewTab( | ||
{ gBrowser, url: CREDITCARD_FORM_URL }, | ||
async function(browser) { | ||
let promiseShown = waitForPopupShown(); | ||
await focusUpdateSubmitForm(browser, { | ||
focusSelector: "#cc-name", | ||
newValues: { | ||
"#cc-name": testCard["cc-name"], | ||
"#cc-number": testCard["cc-number"], | ||
"#cc-exp-month": testCard["cc-exp-month"], | ||
"#cc-exp-year": testCard["cc-exp-year"], | ||
"#cc-type": testCard["cc-type"], | ||
}, | ||
}); | ||
|
||
await promiseShown; | ||
await clickDoorhangerButton(MAIN_BUTTON); | ||
} | ||
); | ||
|
||
await onChanged; | ||
|
||
let creditCards = await getCreditCards(); | ||
let savedCreditCard = creditCards[0]; | ||
let decryptedNumber = await OSKeyStore.decrypt( | ||
savedCreditCard["cc-number-encrypted"] | ||
); | ||
savedCreditCard["cc-number"] = decryptedNumber; | ||
for (let key in testCard) { | ||
let expected = expectedData[key]; | ||
let actual = savedCreditCard[key]; | ||
Assert.equal(expected, actual, `${key} should match`); | ||
} | ||
await removeAllRecords(); | ||
}); | ||
|
||
add_task(async function test_autodetect_credit_overwrite() { | ||
await SpecialPowers.pushPrefEnv({ | ||
set: [[CREDITCARDS_USED_STATUS_PREF, 0]], | ||
}); | ||
const testCard = { | ||
"cc-name": "John Doe", | ||
"cc-number": "4012888888881881", | ||
"cc-exp-month": "06", | ||
"cc-exp-year": "2044", | ||
"cc-type": "master", // Wrong credit card type | ||
}; | ||
const expectedData = { | ||
...testCard, | ||
...{ "cc-type": "visa" }, | ||
}; | ||
let onChanged = waitForStorageChangedEvents("add"); | ||
|
||
await BrowserTestUtils.withNewTab( | ||
{ gBrowser, url: CREDITCARD_FORM_URL }, | ||
async function(browser) { | ||
let promiseShown = waitForPopupShown(); | ||
await focusUpdateSubmitForm(browser, { | ||
focusSelector: "#cc-name", | ||
newValues: { | ||
"#cc-name": testCard["cc-name"], | ||
"#cc-number": testCard["cc-number"], | ||
"#cc-exp-month": testCard["cc-exp-month"], | ||
"#cc-exp-year": testCard["cc-exp-year"], | ||
"#cc-type": testCard["cc-type"], | ||
}, | ||
}); | ||
|
||
await promiseShown; | ||
await clickDoorhangerButton(MAIN_BUTTON); | ||
} | ||
); | ||
|
||
await onChanged; | ||
|
||
let creditCards = await getCreditCards(); | ||
let savedCreditCard = creditCards[0]; | ||
let decryptedNumber = await OSKeyStore.decrypt( | ||
savedCreditCard["cc-number-encrypted"] | ||
); | ||
savedCreditCard["cc-number"] = decryptedNumber; | ||
for (let key in testCard) { | ||
let expected = expectedData[key]; | ||
let actual = savedCreditCard[key]; | ||
Assert.equal(expected, actual, `${key} should match`); | ||
} | ||
|
||
await removeAllRecords(); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.