Bug 251857

Summary: Context menu shows wrong URL and preview when mousedown changes anchor href
Product: WebKit Reporter: Chris Dumez <cdumez>
Component: WebKit2Assignee: Nobody <webkit-unassigned>
Status: NEW ---    
Severity: Normal CC: kkinnunen, thorton, webkit-bug-importer, wenson_hsieh
Priority: P2 Keywords: InRadar
Version: WebKit Nightly Build   
Hardware: Unspecified   
OS: Unspecified   
Attachments:
Description Flags
demo none

Description Chris Dumez 2023-02-07 09:11:29 PST
Steps to reproduce:
1. Open the attached sample "index.html" in Safari
2. Hold down "context menu here" to open the contextual menu

Expected results: It shows the URL and preview of https://www.apple.com/

Actual results: It shows the URL and preview of https://www.webkit.org/

Note that if you copy or tap the link, you'll get https://www.apple.com/ rather than https://www.webkit.org/.

Here's the relevant HTML source:

```
<p><a href="https://www.webkit.org/">context menu here</a></p>
<script>document.querySelector("a").addEventListener("mousedown", (event) => {
    event.target.href = "https://www.apple.com/";
});</script>
```
Comment 1 Chris Dumez 2023-02-07 09:11:37 PST
<rdar://104512680>
Comment 2 Chris Dumez 2023-02-07 09:12:08 PST
Created attachment 464887 [details]
demo