Bug 1864379 - P1. Don't dispatch LoginManager DOM events for disconnected input elements. r=dimi,emilio
Differential Revision: https://phabricator.services.mozilla.com/D194768
This commit is contained in:
@@ -52,7 +52,6 @@
|
||||
#include "mozilla/Telemetry.h"
|
||||
#include "mozilla/StaticPrefs_dom.h"
|
||||
#include "mozilla/StaticPrefs_prompts.h"
|
||||
#include "mozilla/StaticPrefs_signon.h"
|
||||
#include "nsCategoryManagerUtils.h"
|
||||
#include "nsIContentInlines.h"
|
||||
#include "nsISimpleEnumerator.h"
|
||||
@@ -163,10 +162,10 @@ NS_IMPL_ISUPPORTS_CYCLE_COLLECTION_INHERITED_0(HTMLFormElement,
|
||||
|
||||
// EventTarget
|
||||
void HTMLFormElement::AsyncEventRunning(AsyncEventDispatcher* aEvent) {
|
||||
if (mFormPasswordEventDispatcher == aEvent) {
|
||||
mFormPasswordEventDispatcher = nullptr;
|
||||
} else if (mFormPossibleUsernameEventDispatcher == aEvent) {
|
||||
mFormPossibleUsernameEventDispatcher = nullptr;
|
||||
if (aEvent->mEventType == u"DOMFormHasPassword"_ns) {
|
||||
mHasPendingPasswordEvent = false;
|
||||
} else if (aEvent->mEventType == u"DOMFormHasPossibleUsername"_ns) {
|
||||
mHasPendingPossibleUsernameEvent = false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1173,34 +1172,6 @@ void HTMLFormElement::AssertDocumentOrder(
|
||||
}
|
||||
#endif
|
||||
|
||||
void HTMLFormElement::PostPasswordEvent() {
|
||||
// Don't fire another add event if we have a pending add event.
|
||||
if (mFormPasswordEventDispatcher.get()) {
|
||||
return;
|
||||
}
|
||||
|
||||
mFormPasswordEventDispatcher =
|
||||
new AsyncEventDispatcher(this, u"DOMFormHasPassword"_ns, CanBubble::eYes,
|
||||
ChromeOnlyDispatch::eYes);
|
||||
mFormPasswordEventDispatcher->PostDOMEvent();
|
||||
}
|
||||
|
||||
void HTMLFormElement::PostPossibleUsernameEvent() {
|
||||
if (!StaticPrefs::signon_usernameOnlyForm_enabled()) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Don't fire another event if we have a pending event.
|
||||
if (mFormPossibleUsernameEventDispatcher) {
|
||||
return;
|
||||
}
|
||||
|
||||
mFormPossibleUsernameEventDispatcher =
|
||||
new AsyncEventDispatcher(this, u"DOMFormHasPossibleUsername"_ns,
|
||||
CanBubble::eYes, ChromeOnlyDispatch::eYes);
|
||||
mFormPossibleUsernameEventDispatcher->PostDOMEvent();
|
||||
}
|
||||
|
||||
nsresult HTMLFormElement::AddElement(nsGenericHTMLFormElement* aChild,
|
||||
bool aUpdateValidity, bool aNotify) {
|
||||
// If an element has a @form, we can assume it *might* be able to not have
|
||||
@@ -1224,16 +1195,6 @@ nsresult HTMLFormElement::AddElement(nsGenericHTMLFormElement* aChild,
|
||||
|
||||
auto type = fc->ControlType();
|
||||
|
||||
// If it is a password control, inform the password manager.
|
||||
if (type == FormControlType::InputPassword) {
|
||||
PostPasswordEvent();
|
||||
// If the type is email or text, it is a username compatible input,
|
||||
// inform the password manager.
|
||||
} else if (type == FormControlType::InputEmail ||
|
||||
type == FormControlType::InputText) {
|
||||
PostPossibleUsernameEvent();
|
||||
}
|
||||
|
||||
// Default submit element handling
|
||||
if (fc->IsSubmitControl()) {
|
||||
// Update mDefaultSubmitElement, mFirstSubmitInElements,
|
||||
|
||||
Reference in New Issue
Block a user