import {test, expect} from '../../fixtures/test' // HTML entities in attribute values are a common source of encoding bugs. // title="A & B", alt="<diagram>", href="?q=a&b=c" all use // entity encoding to embed special characters. TinyMCE must not double-encode // or corrupt these values — tests check that text content relying on these // attributes survives round-trips correctly. test.describe('HTML entities in attribute values', () => { 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('alt attribute with < and > — image survives', async ({page}) => { const content = await setAndGet( page, '

Value <10>After image

', ) expect(content).toContain('After image') expect(content).toContain('alt') }) test('title attribute with & — surrounding text preserved', async ({page}) => { const content = await setAndGet(page, '

Music genre

') expect(content).toContain('Music genre') }) test('href with & query string — link text preserved', async ({page}) => { const content = await setAndGet( page, '

Search link

', ) expect(content).toContain('Search link') }) test('data attribute with entity-encoded JSON — text preserved', async ({page}) => { const content = await setAndGet( page, '

Tagged span

', ) expect(content).toContain('Tagged span') }) test('aria-label with & — accessible text preserved', async ({page}) => { const content = await setAndGet( page, '

', ) expect(content).toContain('Save') }) test('class attribute is not entity-encoded — text preserved', async ({page}) => { const content = await setAndGet( page, '

Highlighted text

', ) expect(content).toContain('Highlighted text') }) })