overleaf/services/web/test/acceptance/src/HttpPermissionsPolicyTests.js
David dcb7944b05 Merge pull request #18895 from overleaf/dp-presentation-mode
Add pdf presentation mode

GitOrigin-RevId: e6ac1ae339e9690a733a110c6f0a33149e869dd6
2024-06-17 08:04:30 +00:00

29 lines
1.5 KiB
JavaScript

const { expect } = require('chai')
const fetch = require('node-fetch')
const Settings = require('@overleaf/settings')
const BASE_URL = `http://${process.env.HTTP_TEST_HOST || '127.0.0.1'}:23000`
describe('HttpPermissionsPolicy', function () {
it('should have permissions-policy header on user-facing pages', async function () {
const response = await fetch(BASE_URL)
expect(response.headers.get('permissions-policy')).to.equal(
'accelerometer=(), attribution-reporting=(), browsing-topics=(), camera=(), display-capture=(), encrypted-media=(), gamepad=(), geolocation=(), gyroscope=(), hid=(), identity-credentials-get=(), idle-detection=(), local-fonts=(), magnetometer=(), microphone=(), midi=(), otp-credentials=(), payment=(), picture-in-picture=(), screen-wake-lock=(), serial=(), storage-access=(), usb=(), window-management=(), xr-spatial-tracking=(), autoplay=(self "https://videos.ctfassets.net"), fullscreen=(self)'
)
})
it('should not have permissions-policy header on requests for non-rendered content', async function () {
const response = await fetch(`${BASE_URL}/dev/csrf`)
expect(response.headers.get('permissions-policy')).to.be.null
})
describe('when permissions policy is disabled', function () {
it('it adds no additional headers', async function () {
Settings.useHttpPermissionsPolicy = false
const response = await fetch(BASE_URL)
expect(response.headers.get('permissions-policy')).to.be.null
})
})
})