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

@ -910,12 +910,7 @@ nsDocumentViewer::InitInternal(nsIWidget* aParentWidget,
nsCOMPtr<nsIInterfaceRequestor> requestor(mContainer);
if (requestor) {
if (mPresContext) {
nsCOMPtr<nsILinkHandler> linkHandler;
requestor->GetInterface(NS_GET_IID(nsILinkHandler),
getter_AddRefs(linkHandler));
mPresContext->SetContainer(mContainer);
mPresContext->SetLinkHandler(linkHandler);
}
// Set script-context-owner in the document
@ -1421,8 +1416,6 @@ AttachContainerRecurse(nsIDocShell* aShell)
viewer->GetPresContext(getter_AddRefs(pc));
if (pc) {
pc->SetContainer(static_cast<nsDocShell*>(aShell));
nsCOMPtr<nsILinkHandler> handler = do_QueryInterface(aShell);
pc->SetLinkHandler(handler);
}
nsCOMPtr<nsIPresShell> presShell;
viewer->GetPresShell(getter_AddRefs(presShell));
@ -2146,12 +2139,6 @@ nsDocumentViewer::Show(void)
return rv;
if (mPresContext && base_win) {
nsCOMPtr<nsILinkHandler> linkHandler(do_GetInterface(base_win));
if (linkHandler) {
mPresContext->SetLinkHandler(linkHandler);
}
mPresContext->SetContainer(mContainer);
}