Bug 1739957 - Clear event listener. r=smaug

Differential Revision: https://phabricator.services.mozilla.com/D134713
This commit is contained in:
Peter Van der Beken 2022-01-13 19:56:56 +00:00
parent 22c350103d
commit 789bd2360a

View File

@ -1007,6 +1007,8 @@ nsresult EventListenerManager::SetEventHandler(nsAtom* aName,
bool aDeferCompilation,
bool aPermitUntrustedEvents,
Element* aElement) {
auto removeEventHandler = MakeScopeExit([&] { RemoveEventHandler(aName); });
nsCOMPtr<Document> doc;
nsCOMPtr<nsIScriptGlobalObject> global =
GetScriptGlobalAndDocument(getter_AddRefs(doc));
@ -1066,6 +1068,8 @@ nsresult EventListenerManager::SetEventHandler(nsAtom* aName,
NS_ENSURE_TRUE(context, NS_ERROR_FAILURE);
NS_ENSURE_STATE(global->HasJSGlobal());
removeEventHandler.release();
Listener* listener = SetEventHandlerInternal(aName, TypedEventHandler(),
aPermitUntrustedEvents);