New issue
Advanced search Search tips
Note: Color blocks (like or ) mean that a user may not be available. Tooltip shows the reason.

Issue 782194 link

Starred by 1 user

Issue metadata

Status: Assigned
Owner:
Last visit > 30 days ago
Cc:
Components:
EstimatedDays: ----
NextAction: ----
OS: Mac
Pri: 2
Type: Bug



Sign in to add a comment

Timing issue using preload with Content-Security-Policy (CSP)

Reported by matt...@mysociety.org, Nov 7 2017

Issue description

UserAgent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/62.0.3202.75 Safari/537.36

Steps to reproduce the problem:
1. Have a page with a Content-Security-Policy banning inline style, with a nonce.
2. Add a <link rel="preload" href="style.css" as="style">
3. Have some script after that to set the onload handler of the link to set rel="stylesheet". See attachment.

What is the expected behavior?
The stylesheet is always activated when loaded.

What went wrong?
If there is any delay in the setting of the handler, and the file is cached/loads very quickly, then the link's load event fires before the handler is attached and the stylesheet isn't activated. I am assuming this can't happen with an inline event handler? But I can't use an inline event handler due to the Content-Security-Policy header.

If it can be guaranteed that an immediate setting of the handler after the link will be attached in time, then that is fine, but I couldn't find any documentation as to whether this would be the case or not; any users of rel=preload on stylesheets appears to use an inline event handler.

Did this work before? No 

Does this work in other browsers? N/A

Chrome version: 62.0.3202.75  Channel: stable
OS Version: OS X 10.12.6
Flash Version:
 
csp-preload.html
476 bytes View Download
Components: Blink>SecurityFeature
Cc: susanjuniab@chromium.org
Labels: Needs-Triage-M62 Needs-Feedback
matthew@ Thank you for the issue.

Tested this issue on Mac OS 10.12.6 using the latest Stable 62.0.3202.89, Canary 64.0.3262.0 and on the reported version 62.0.3202.7 by following the below steps.

1. launched Chrome and opened the given html page.
2. Opened Devtools -> Console and could see some errors on the console.
Attached is the screen cast for reference.

Can you please check and confirm is we have tested this issue with the correct steps. Also request you to please provide us the expected behavior and steps to reproduce this issue and a screen cast will be helpful for the better understanding.
Thanks
++ Attaching the screen cast
782194.webm
1.6 MB View Download
Hi Susan, Thanks for the screencast. I didn't include an empty style.css file, as that seemed superfluous to the actual issue, but perhaps I wasn't clear enough, sorry.

I have provided a new HTML file and associated style.css that will show the issue, with an artificial delay of a few milliseconds. I have also attached a screencast to confirm this. My question is how can you attach an onload event handler to a link and guarantee that it will be run, without using an inline event handler. I hope that makes things clear.

style.css
20 bytes View Download
csp-preload.html
539 bytes View Download
csp.gif
397 KB View Download
Project Member

Comment 5 by sheriffbot@chromium.org, Nov 9 2017

Labels: -Needs-Feedback
Thank you for providing more feedback. Adding requester "susanjuniab@chromium.org" to the cc list and removing "Needs-Feedback" label.

For more details visit https://www.chromium.org/issue-tracking/autotriage - Your friendly Sheriffbot

Comment 6 by est...@chromium.org, Nov 10 2017

Labels: Hotlist-EnamelAndFriendsFixIt

Comment 7 by jochen@chromium.org, Nov 10 2017

Cc: y...@yoav.ws mkwst@chromium.org
Components: -Blink>SecurityFeature Blink>SecurityFeature>ContentSecurityPolicy
Owner: andypaicu@chromium.org
Status: Assigned (was: Unconfirmed)

Comment 8 by est...@chromium.org, Feb 18 2018

Labels: -Hotlist-EnamelAndFriendsFixIt

Sign in to add a comment