import {test, expect} from '../../fixtures/test' // Canvas LMS embeds LTI tools, media objects, and widgets using data-* attributes // on content elements. These attributes carry launch URLs, resource IDs, and // preview metadata. canvas-rce must not strip data-* attributes from safe elements // or LTI tool embeds will stop working after an edit. test.describe('Canvas-specific data-* attributes', () => { 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('data-canvas-id on span is handled', async ({page}) => { const content = await setAndGet( page, 'Embedded file', ) expect(content).toContain('Embedded file') }) test('iframe with data-lti-launch attributes preserves surrounding content', async ({page}) => { const content = await setAndGet( page, '

Before LTI

After LTI

', ) expect(content).toContain('Before LTI') expect(content).toContain('After LTI') }) test('img with data-api-endpoint attribute content survives', async ({page}) => { const content = await setAndGet( page, 'course image', ) if (content.includes(' { const content = await setAndGet( page, 'x²+y²=r²', ) expect(content).toContain('x') }) test('div with data-media-id for media embeds preserves content', async ({page}) => { const content = await setAndGet( page, '

Video placeholder

', ) expect(content).toContain('Video placeholder') }) test('multiple data-* attributes on same element, content preserved', async ({page}) => { const content = await setAndGet( page, 'File link', ) expect(content).toContain('File link') }) test('data-* attributes do not introduce XSS', async ({page}) => { const content = await setAndGet( page, 'safe text', ) expect(content).toContain('safe text') expect(content).not.toContain('