Bug 265158

Summary: Regression: Safari 17.1 blocking JS reading nonce for <style> and <link>
Product: WebKit Reporter: Chris J. Shull <chrisjshull>
Component: New BugsAssignee: Nobody <webkit-unassigned>
Status: RESOLVED FIXED    
Severity: Normal CC: mike
Priority: P2    
Version: Safari 17   
Hardware: Unspecified   
OS: Unspecified   
Attachments:
Description Flags
Safari 17.0 (working)
none
Safari 17.1 (not working) none

Description Chris J. Shull 2023-11-20 14:16:21 PST
Created attachment 468689 [details]
Safari 17.0 (working)

The Google Maps JavaScript API reads the nonce value of an existing <style> or <link rel="stylesheet"> in order to inject more stylesheets with the same nonce. This worked in Safari 17.0

Starting in Safari 17.1, we are unable to read the nonce value in JS anymore, causing the Google Maps JavaScript API to render incorrectly on websites. Here is a test page reported by one of our customers: https://maps-bug-1a422.web.app/index.html

(We do the same thing for <script> elements, and that still works.)
Comment 1 Chris J. Shull 2023-11-20 14:16:45 PST
Created attachment 468690 [details]
Safari 17.1 (not working)
Comment 2 Chris J. Shull 2023-11-20 14:20:23 PST
test JS snippet:

document.querySelector('style[nonce],link[rel="stylesheet"][nonce]').nonce

should return he nonce value
Comment 3 Chris J. Shull 2023-11-20 14:48:02 PST
Apologies, I think something went pinky in my Safari 17.0 tests. Now I *can repro* it there. I'm going to close this and open anew bug that is clearer.