Bug 1750072 - Allow to prevent password revealing/unrevealing. r=mtigley
The idea is that chrome code would be able to call preventDefault(), then run primary password authentication when needed, then setRevealPassword again. Differential Revision: https://phabricator.services.mozilla.com/D173491
This commit is contained in:
@@ -6876,6 +6876,20 @@ void HTMLInputElement::SetRevealPassword(bool aValue) {
|
||||
if (NS_WARN_IF(mType != FormControlType::InputPassword)) {
|
||||
return;
|
||||
}
|
||||
if (aValue == State().HasState(ElementState::REVEALED)) {
|
||||
return;
|
||||
}
|
||||
RefPtr doc = OwnerDoc();
|
||||
// We allow chrome code to prevent this. This is important for about:logins,
|
||||
// which may need to run some OS-dependent authentication code before
|
||||
// revealing the saved passwords.
|
||||
bool defaultAction = true;
|
||||
nsContentUtils::DispatchEventOnlyToChrome(
|
||||
doc, ToSupports(this), u"MozWillToggleReveal"_ns, CanBubble::eYes,
|
||||
Cancelable::eYes, &defaultAction);
|
||||
if (NS_WARN_IF(!defaultAction)) {
|
||||
return;
|
||||
}
|
||||
if (aValue) {
|
||||
AddStates(ElementState::REVEALED);
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user