Issue #2721 - Create special case exception for <A>.Click() outside of DOM

This removes the requirement for there to be a non-null PresShell to
dispatch `Click()` events on `<A>` elements (only), since the exception
to the rule has propagated to the spec.

With these changes it should now be possible do create an anchor and
`Click()` on it from JS without actually first attaching it to the DOM
of the presented document, as abused by scripted downloads in pages
(instead of using the A attribute to custom-name downloads).
This commit is contained in:
Moonchild 2025-06-09 23:45:31 +02:00 • committed by roytam1
commit 37de431ac0
15 changed files with 79 additions and 94 deletions

View file

@ -412,6 +412,14 @@ public:
virtual void RemoveIDTargetObserver(nsIAtom* aID, IDTargetObserver aObserver,
void* aData, bool aForImage) override;
virtual void SetLinkHandlingEnabled(bool aValue) override {
mLinksEnabled = aValue;
}
virtual bool LinkHandlingEnabled() override {
return mLinksEnabled;
}
/**
* Access HTTP header data (this may also get set from other sources, like
* HTML META tags).
@ -1223,6 +1231,10 @@ public:
// Recorded time of change to 'loading' state.
mozilla::TimeStamp mLoadingTimeStamp;
// False if we've disabled link handling for elements inside this document,
// true otherwise.
bool mLinksEnabled : 1;
// True if the document has been detached from its content viewer.
bool mIsGoingAway:1;
// True if the document is being destroyed.