Skip to content

Commit

Permalink
Track password field id so it can be used to improve uniqueness of pa…
Browse files Browse the repository at this point in the history
…sswordId

BUG=618717
CQ_INCLUDE_TRYBOTS=tryserver.chromium.linux:closure_compilation

Review-Url: https://codereview.chromium.org/2053393003
Cr-Commit-Position: refs/heads/master@{#399266}
  • Loading branch information
jay0lee authored and Commit bot committed Jun 10, 2016
1 parent f466a07 commit 8623bfc
Showing 1 changed file with 11 additions and 7 deletions.
18 changes: 11 additions & 7 deletions chrome/browser/resources/gaia_auth/saml_injected.js
Original file line number Diff line number Diff line change
Expand Up @@ -143,8 +143,9 @@
return;

var index = this.passwordFields_.length;
var fieldId = passwordField.id || passwordField.name || '';
passwordField.addEventListener(
'input', this.onPasswordChanged_.bind(this, index));
'input', this.onPasswordChanged_.bind(this, index, fieldId));
this.passwordFields_.push(passwordField);
this.passwordValues_.push(passwordField.value);
},
Expand All @@ -153,16 +154,18 @@
* Check if the password field at |index| has changed. If so, sends back
* the updated value.
*/
maybeSendUpdatedPassword: function(index) {
maybeSendUpdatedPassword: function(index, fieldId) {
var newValue = this.passwordFields_[index].value;
if (newValue == this.passwordValues_[index])
return;

this.passwordValues_[index] = newValue;

// Use an invalid char for URL as delimiter to concatenate page url and
// password field index to construct a unique ID for the password field.
var passwordId = this.pageURL_.split('#')[0].split('?')[0] + '|' + index;
// Use an invalid char for URL as delimiter to concatenate page url,
// password field index and id to construct a unique ID for the password
// field.
var passwordId = this.pageURL_.split('#')[0].split('?')[0] +
'|' + index + '|' + fieldId;
this.channel_.send({
name: 'updatePassword',
id: passwordId,
Expand All @@ -174,9 +177,10 @@
* Handles 'change' event in the scraped password fields.
* @param {number} index The index of the password fields in
* |passwordFields_|.
* @param {string} fieldId The id or name of the password field or blank.
*/
onPasswordChanged_: function(index) {
this.maybeSendUpdatedPassword(index);
onPasswordChanged_: function(index, fieldId) {
this.maybeSendUpdatedPassword(index, fieldId);
}
};

Expand Down

0 comments on commit 8623bfc

Please sign in to comment.