import {test, expect} from '../../fixtures/test' // Content that looks like HTML but is entity-escaped text (tutorials, // documentation, coding examples) uses <, >, & so the text // literally reads "
" on screen. TinyMCE must not parse this as markup. // A refactor that accidentally un-escapes entities in text nodes would corrupt // all code tutorial content in Canvas. test.describe('entity-escaped HTML shown as literal text', () => { test.beforeEach(async ({page, rcePage}) => { await page.goto('/scenarios/basic') await rcePage.waitForEditor() }) async function setAndGet(page: any, html: string): Promise { return page.evaluate((content: string) => { // @ts-expect-error -- TinyMCE global window.tinymce.activeEditor.setContent(content) // @ts-expect-error -- TinyMCE global return window.tinymce.activeEditor.getContent() }, html) } test('<div> as text — not parsed as HTML', async ({page}) => { const content = await setAndGet(page, '

Use the <div> element for blocks.

') expect(content).toContain('div') expect(content).toContain('element for blocks') }) test('<script> as escaped text — not executed', async ({page}) => { const content = await setAndGet( page, '

Never use <script>alert(1)</script> in HTML.

', ) expect(content).toContain('Never use') expect(content).toContain('in HTML') // The literal text of script tag (encoded) should survive // but not an actual script tag expect(content).not.toContain('