DEV: Use performance timings to as a baseline for the splash take 2 (#17284)

We previously relied on CSS animation-delay for the splash. This means that we can get inconsistent results based on device/network conditions.

This PR moves us to a more consistent timing based on {request time + 2 seconds}

Internal topic: /t/65378/65
This commit is contained in:
Joe
2022-06-30 21:22:00 +08:00
committed by GitHub
parent 7343cb9f73
commit 49905a4e6c
6 changed files with 87 additions and 18 deletions
@@ -665,6 +665,19 @@ RSpec.describe ApplicationController do
expect(response.body).to include(nonce)
end
it 'when splash screen is enabled it adds the same nonce to the policy and the inline splash script' do
SiteSetting.content_security_policy = true
SiteSetting.splash_screen = true
get '/latest'
nonce = ApplicationHelper.splash_screen_nonce
expect(response.headers).to include('Content-Security-Policy')
script_src = parse(response.headers['Content-Security-Policy'])['script-src']
expect(script_src.to_s).to include(nonce)
expect(response.body).to include(nonce)
end
def parse(csp_string)
csp_string.split(';').map do |policy|
directive, *sources = policy.split