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

Progress Bar Won't Render if CSP is Turned On #501

Merged
merged 2 commits into from
Dec 19, 2021

Conversation

rience
Copy link
Contributor

@rience rience commented Dec 18, 2021

Progress Bar injects inline <style /> element to page. However, when Content Security Policy is turned on and nonce is generated - Progress Bar element ignores that.

This PR fixes that and checks if csp-nonce is set in meta tags. Then it uses it to create inline style.

Update: I don't know why test is failing and is generating <style /> without nonce being set. However, when testing manually - this fix works. I might need some help here from someone more experienced in writing JS tests.

@dhh dhh merged commit 201f8b3 into hotwired:main Dec 19, 2021
@rience rience deleted the progress-bar-nonce-fix branch December 19, 2021 16:05
seanpdoyle added a commit to seanpdoyle/turbo that referenced this pull request Feb 13, 2022
Merging [hotwired#501][] into `main` introduced a [consistent
failure to the test suite][ci-failure]:

```
× firefox on linux 5.11.0-1022-azure - RenderingTests - progress bar inline style has nonce (0.32s)
458
    AssertionError: displays progress bar: expected false to be truthy
459
      at RenderingTests.test progress bar inline style has nonce @ src/tests/functional/rendering_tests.ts:24:16
460
      at processTicksAndRejections @ internal/process/task_queues.js:97:5
461
      at async RenderingTests.runTest @ src/tests/helpers/intern_test_case.ts:43:6
```

This commit re-structures the test to make the same assertion (replacing
the [script][] tagname with [style][]).

[script]: https://developer.mozilla.org/en-US/docs/Web/HTML/Element/script
[style]: https://developer.mozilla.org/en-US/docs/Web/HTML/Element/style
[ci-failure]: https://github.com/hotwired/turbo/runs/4574673552?check_suite_focus=true#step:7:457
[hotwired#501]: hotwired#501
seanpdoyle added a commit to seanpdoyle/turbo that referenced this pull request Feb 13, 2022
Merging [hotwired#501][] into `main` introduced a [consistent
failure to the test suite][ci-failure]:

```
× firefox on linux 5.11.0-1022-azure - RenderingTests - progress bar inline style has nonce (0.32s)
458
    AssertionError: displays progress bar: expected false to be truthy
459
      at RenderingTests.test progress bar inline style has nonce @ src/tests/functional/rendering_tests.ts:24:16
460
      at processTicksAndRejections @ internal/process/task_queues.js:97:5
461
      at async RenderingTests.runTest @ src/tests/helpers/intern_test_case.ts:43:6
```

This commit re-structures the test to make the same assertion (replacing
the [script][] tagname with [style][]).

[script]: https://developer.mozilla.org/en-US/docs/Web/HTML/Element/script
[style]: https://developer.mozilla.org/en-US/docs/Web/HTML/Element/style
[ci-failure]: https://github.com/hotwired/turbo/runs/4574673552?check_suite_focus=true#step:7:457
[hotwired#501]: hotwired#501
dhh pushed a commit that referenced this pull request Mar 30, 2022
Merging [#501][] into `main` introduced a [consistent
failure to the test suite][ci-failure]:

```
× firefox on linux 5.11.0-1022-azure - RenderingTests - progress bar inline style has nonce (0.32s)
458
    AssertionError: displays progress bar: expected false to be truthy
459
      at RenderingTests.test progress bar inline style has nonce @ src/tests/functional/rendering_tests.ts:24:16
460
      at processTicksAndRejections @ internal/process/task_queues.js:97:5
461
      at async RenderingTests.runTest @ src/tests/helpers/intern_test_case.ts:43:6
```

This commit re-structures the test to make the same assertion (replacing
the [script][] tagname with [style][]).

[script]: https://developer.mozilla.org/en-US/docs/Web/HTML/Element/script
[style]: https://developer.mozilla.org/en-US/docs/Web/HTML/Element/style
[ci-failure]: https://github.com/hotwired/turbo/runs/4574673552?check_suite_focus=true#step:7:457
[#501]: #501
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants