Index: chrome/test/data/webui/settings/fake_quick_unlock_private.js |
diff --git a/chrome/test/data/webui/settings/fake_quick_unlock_private.js b/chrome/test/data/webui/settings/fake_quick_unlock_private.js |
index 0852d671316e1ef2bc85220a1aa7ffecc252cc46..ae005e756922f3a9f4b78c29e916e9488f3624d8 100644 |
--- a/chrome/test/data/webui/settings/fake_quick_unlock_private.js |
+++ b/chrome/test/data/webui/settings/fake_quick_unlock_private.js |
@@ -5,6 +5,13 @@ |
/** |
* @fileoverview Fake implementation of chrome.quickUnlockPrivate for testing. |
*/ |
+ |
+/** |
+ * A couple weak pins to use for testing. |
+ * @const |
+ */ |
+var TEST_WEAK_PINS = ['1111', '1234', '1313', '2001', '1010']; |
+ |
cr.define('settings', function() { |
/** |
* Fake of the chrome.quickUnlockPrivate API. |
@@ -18,6 +25,8 @@ cr.define('settings', function() { |
this.activeModes = []; |
/** @type {!Array<string>} */ this.credentials = []; |
/** @type {string} */ this.accountPassword = ''; |
+ /** @type {!chrome.quickUnlockPrivate.CredentialRequirements} */ |
+ this.credentialRequirements = {minLength: 4, maxLength: 0}; |
} |
FakeQuickUnlockPrivate.prototype = { |
@@ -54,7 +63,47 @@ cr.define('settings', function() { |
this.activeModes = modes; |
this.credentials = credentials; |
onComplete(this.accountPassword == accountPassword); |
- } |
+ }, |
+ |
+ /** |
+ * @override |
+ * @param {!chrome.quickUnlockPrivate.QuickUnlockMode} mode |
+ * @param {string} credential |
+ * @param {function( |
+ * !chrome.quickUnlockPrivate.CredentialCheck):void} onComplete |
+ */ |
+ checkCredential: function(mode, credential, onComplete) { |
+ var message = {}; |
+ var errors = []; |
+ var warnings = []; |
+ |
+ if (!!credential && |
+ credential.length < this.credentialRequirements.minLength) { |
+ errors.push(chrome.quickUnlockPrivate.CredentialProblem.TOO_SHORT); |
+ } |
+ |
+ if (!!credential && this.credentialRequirements.maxLength != 0 && |
+ credential.length > this.credentialRequirements.maxLength) { |
+ errors.push(chrome.quickUnlockPrivate.CredentialProblem.TOO_LONG); |
+ } |
+ |
+ if (!!credential && TEST_WEAK_PINS.includes(credential)) |
+ warnings.push(chrome.quickUnlockPrivate.CredentialProblem.TOO_WEAK); |
+ |
+ message.errors = errors; |
+ message.warnings = warnings; |
+ onComplete(message); |
+ }, |
+ |
+ /** |
+ * @override. |
+ * @param {!chrome.quickUnlockPrivate.QuickUnlockMode} mode |
+ * @param {function( |
+ * !chrome.quickUnlockPrivate.CredentialRequirements):void onComplete |
+ */ |
+ getCredentialRequirements: function(mode, onComplete) { |
+ onComplete(this.credentialRequirements); |
+ }, |
}; |
/** @type {!ChromeEvent} */ |