Files
Peter EvansandJeremie Pardou 5a62c876e4 fix: align custom code in builder Preview with the editor on shared hostnames (#6881)
* fix: restrict editor-written code in the builder editor and on the editor hostname

* fix: simplify builder author code restrictions by hostname

* refactor: remove redundant backend custom code hostname checks

* refactor: unify builder HTML element rendering restrictions

* refactor: clarify builder web frontend hostname terminology

* fix: distinguish untrusted builder content in preview notices

* refactor: remove unused backend preview security setting

* docs: shorten builder code restriction changelog

* fix: restrict iframe cookie access across frontend ports

* refactor: share web frontend hostname matching

* fix: preserve protected HTML interactions and bound iframe height

---------

Co-authored-by: Jeremie Pardou <571533+jrmi@users.noreply.github.com>
2026-11-26 17:20:44 +00:00

53 lines
1.5 KiB
JavaScript

// The test app is served on the editor's hostname, like a default install.
describe('author code plugin', () => {
let publicConfig
let original
beforeEach(() => {
publicConfig = useRuntimeConfig().public
original = {
builderPreviewUrl: publicConfig.builderPreviewUrl,
publicWebFrontendUrl: publicConfig.publicWebFrontendUrl,
builderDangerousRelaxPreviewSecurity:
publicConfig.builderDangerousRelaxPreviewSecurity,
}
})
afterEach(() => {
Object.assign(publicConfig, original)
})
test.each([
['editing', false, true],
['editing', true, false],
['preview', false, true],
['preview', true, false],
['public', false, true],
['public', true, false],
])(
'in %s mode with relaxed security %s, author code is restricted: %s',
(mode, relaxed, expected) => {
publicConfig.builderDangerousRelaxPreviewSecurity = relaxed
expect(useNuxtApp().$isAuthorCodeRestricted()).toBe(expected)
}
)
test.each([
['http://localhost:3001', false, true],
['http://localhost:3001', true, false],
['http://preview.localhost:3000', false, false],
])(
'with Preview at %s and relaxed security %s, Preview restricts author code: %s',
(builderPreviewUrl, relaxed, expected) => {
Object.assign(publicConfig, {
builderPreviewUrl,
publicWebFrontendUrl: 'http://localhost:3000',
builderDangerousRelaxPreviewSecurity: relaxed,
})
expect(useNuxtApp().$previewRestrictsAuthorCode()).toBe(expected)
}
)
})