Closed RobinDaugherty closed 3 years ago
Changes Missing Coverage | Covered Lines | Changed/Added Lines | % | ||
---|---|---|---|---|---|
lib/better_errors/error_page.rb | 15 | 17 | 88.24% | ||
<!-- | Total: | 21 | 23 | 91.3% | --> |
Totals | |
---|---|
Change from base Build 396793693: | 0.06% |
Covered Lines: | 500 |
Relevant Lines: | 516 |
Add our own Content Security Policy headers when Better Errors responds, which heavily restricts the resources that can be used/referenced, but allows our scripts and styles. It uses a nonce for the script blocks, but currently we rely on inline style because of the way syntax highlighting works (which will change someday, for example in #423).
Turbolinks (of course)
When Turbolinks is in use, our headers are not evaluated by the browser when loading the console page. If the CSP headers sent by the application restrict inline CSS and JS, the console will not function or be presented correctly.
So we also provide fallback modes, where the user is informed of the reason and given a link to open Better Errors in a new tab. This fallback includes the topmost frame infomation, so essentially the same information as the "text" version is available on the page, even if not well-formatted.
When inline style is available but inline script is not:![Screen Shot 2020-12-11 at 1 43 21 PM](https://user-images.githubusercontent.com/1005280/101942530-a77d6900-3bb7-11eb-9ca7-a8ecab34f01e.png)
When inline style is not available but script is:![Screen Shot 2020-12-11 at 1 48 54 PM](https://user-images.githubusercontent.com/1005280/101942592-c7149180-3bb7-11eb-9eaf-82fa751f4bf2.png)
When both are not available:![Screen Shot 2020-12-11 at 1 42 40 PM](https://user-images.githubusercontent.com/1005280/101942625-d72c7100-3bb7-11eb-82b0-e80729b1394d.png)