Bug 265065

Summary: Window scrolls back to URL hash when adding <style> element to page with Safari extension <link> stylesheet
Product: WebKit Reporter: Jeff Johnson <opendarwin>
Component: CSSAssignee: Nobody <webkit-unassigned>
Status: NEW ---    
Severity: Normal CC: simon.fraser, webkit-bug-importer
Priority: P2 Keywords: InRadar
Version: Safari 17   
Hardware: Mac (Apple Silicon)   
OS: macOS 13   
Attachments:
Description Flags
Sample Xcode project none

Description Jeff Johnson 2023-11-17 13:33:47 PST
Created attachment 468658 [details]
Sample Xcode project

Steps to reproduce:
1. Unzip attached sample Safari extension project HashBug
2. Open HashBug in Xcode 15
3. Build and run
4. Open Safari Developer Settings
5. Allow unsigned extensions
6. Open Safari Extensions Settings
7. Enable HashBug Extension
8. Always Allow on Every Website
9. Open https://www.webkit.org/#posts
10. Scroll down the page to the bottom
11. Open the Safari web inspector
12. In the web inspector console, add an Inspector Style Sheet, or enter the following in the console: document.head.append(document.createElement("style"));

Expected results: The page does not scroll.

Actual results: The page scrolls back to #posts from the URL hash.
Comment 1 Radar WebKit Bug Importer 2023-11-24 13:34:15 PST
<rdar://problem/118777589>