Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(firefox): throw error when added script blocked by CSP #1841

Merged
merged 1 commit into from
Apr 17, 2020

Conversation

yury-s
Copy link
Member

@yury-s yury-s commented Apr 17, 2020

No description provided.

return (await context.evaluateHandleInternal(addScriptContent, { content: content!, type })).asElement()!;
// Another round trip to the browser to ensure that we receive CSP error messages
// (if any) logged asynchronously in a separate task on the content main thread.
if (this._page._delegate.cspErrorsAsynchronousForInlineScipts)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should probably do the same for inline styles and test it.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, styles are different. I thought the same but the styles seem to be handled asynchronously and they support onload/error events. We already have a test for this.

// Another round trip to the browser to ensure that we receive CSP error messages
// (if any) logged asynchronously in a separate task on the content main thread.
if (this._page._delegate.cspErrorsAsynchronousForInlineScipts)
await context.evaluateInternal(() => true);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Have you found the source of this? Are we sure it is a single task?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The console logging happens in a separate task on the main thread. My assumption here is that the second evaluate is handled in its own task after the logging, so there is still a room for false positives. I could add some hooks in the native part to report the error synchronously via juggler but I felt like the problem we are fixing doesn't warrant it.

@yury-s yury-s merged commit 2b96b85 into microsoft:master Apr 17, 2020
@yury-s yury-s deleted the script-tag-csp branch April 17, 2020 15:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants