tests/test_static_headers.py (962 bytes)
1 """The headers on the static files: cross-origin isolation, and how long a 2 browser may keep each file.""" 3 4 from __future__ import annotations 5 6 7 def test_page_is_cross_origin_isolated(client): 8 r = client.get("/") 9 assert r.headers["cross-origin-opener-policy"] == "same-origin" 10 assert r.headers["cross-origin-embedder-policy"] == "credentialless" 11 12 13 def test_engine_modules_are_revalidated_every_time(client): 14 # engine/job.js imports ./asr.js by bare path. A kept copy of one with a 15 # new copy of the other is a broken engine, so each must ask the server. 16 for path in ("/", "/app.js", "/engine/asr.js", "/engine/job.js"): 17 r = client.get(path) 18 assert r.status_code == 200, path 19 assert r.headers["cache-control"] == "no-cache", path 20 21 22 def test_vendor_files_may_be_kept(client): 23 r = client.get("/vendor/versions.json") 24 assert r.status_code == 200 25 assert r.headers["cache-control"] == "public, max-age=86400"