mirror of
https://github.com/zhw2590582/ArtPlayer.git
synced 2026-10-23 22:01:20 -08:00
build(site): [SITE-07] restore Monaco Markdown component notices
This commit is contained in:
1 parent
426fee8faa
commit
244695e726
36 files changed
+6943
-9
No files matched your search
@@ -1,5 +1,10 @@
|
||||
# Browser regression entry
|
||||
|
||||
`editor-markdown.spec.js` runs the bundled DOMPurify/marked renderer, verifies
|
||||
formatting, selected filtering and temporary-hook cleanup. `site-vendor.spec.js`
|
||||
also checks all 85 notice files and the core-origin attribution links over HTTP.
|
||||
These checks do not constitute exhaustive sanitizer or physical-device validation.
|
||||
|
||||
`editor-modes.spec.js` exercises Monaco's actual automatic mode/provider registration
|
||||
through a real editor. It switches CSS/JSON/TypeScript/HTML models, checks diagnostic
|
||||
arrival/removal and document formatting, verifies all four mode bundle responses,
|
||||
|
||||
@@ -0,0 +1,46 @@
|
||||
import { expect, test } from './fixtures.js'
|
||||
|
||||
test('docs Monaco renders Markdown with its bundled parser and sanitizer', async ({ page }, testInfo) => {
|
||||
await page.goto('/test/player.html?core=candidate&chapter=published')
|
||||
await page.addScriptTag({ url: '/assets/js/vs/loader.js' })
|
||||
const result = await page.evaluate(async () => {
|
||||
window.require.config({ paths: { vs: '/assets/js/vs' } })
|
||||
const load = ids => new Promise((resolve, reject) => window.require(ids, (...modules) => resolve(modules), reject))
|
||||
await load(['vs/editor/editor.main'])
|
||||
const [renderer, purify] = await load(['vs/base/browser/markdownRenderer', 'vs/base/browser/dompurify/dompurify'])
|
||||
const rendered = renderer.renderMarkdown({
|
||||
value: '**Player** and `art.play()`\n\n| API | Result |\n| --- | --- |\n| play | Promise |\n\n[Docs](https://artplayer.org/document/)\n\n<span onclick="window.markdownExecuted=true">safe text</span><script>window.markdownExecuted=true</script>',
|
||||
supportHtml: true,
|
||||
isTrusted: false,
|
||||
})
|
||||
document.body.appendChild(rendered.element)
|
||||
const element = rendered.element
|
||||
const output = {
|
||||
version: purify.version,
|
||||
strong: element.querySelector('strong')?.textContent,
|
||||
code: element.querySelector('code')?.textContent,
|
||||
cells: [...element.querySelectorAll('td')].map(cell => cell.textContent),
|
||||
link: element.querySelector('a')?.getAttribute('data-href'),
|
||||
text: element.textContent,
|
||||
scripts: element.querySelectorAll('script').length,
|
||||
handlers: element.querySelectorAll('[onclick]').length,
|
||||
executed: window.markdownExecuted === true,
|
||||
}
|
||||
rendered.dispose()
|
||||
element.remove()
|
||||
// Renderer hooks must not leak into a later consumer of the same singleton.
|
||||
output.afterDispose = purify.sanitize('<div style="color:red">next</div>')
|
||||
return output
|
||||
})
|
||||
await testInfo.attach('monaco-markdown-result', { contentType: 'application/json', body: JSON.stringify(result, null, 2) })
|
||||
expect(result.version).toBe('2.3.1')
|
||||
expect(result.strong).toBe('Player')
|
||||
expect(result.code).toBe('art.play()')
|
||||
expect(result.cells).toEqual(['play', 'Promise'])
|
||||
expect(result.link).toBe('https://artplayer.org/document/')
|
||||
expect(result.text).toContain('safe text')
|
||||
expect(result.scripts).toBe(0)
|
||||
expect(result.handlers).toBe(0)
|
||||
expect(result.executed).toBe(false)
|
||||
expect(result.afterDispose).toBe('<div style="color:red">next</div>')
|
||||
})
|
||||
@@ -24,6 +24,7 @@ test('mobile vConsole shows logs and upstream site notice texts are served uncha
|
||||
for (const { path, count } of [
|
||||
{ path: '/licenses/console/react-pure-render/ATTRIBUTION.md', count: 2 },
|
||||
{ path: '/licenses/monaco-editor/language-services/ATTRIBUTION.md', count: 12 },
|
||||
{ path: '/licenses/monaco-editor/core-origins/ATTRIBUTION.md', count: 3 },
|
||||
]) {
|
||||
const attribution = await request.get(path)
|
||||
expect(attribution.status()).toBe(200)
|
||||
@@ -41,6 +42,8 @@ test('mobile vConsole shows logs and upstream site notice texts are served uncha
|
||||
expect(index.status()).toBe(200)
|
||||
expect(await index.text()).toContain('Included component: @vscode/codicons 0.0.26')
|
||||
expect(await index.text()).toContain('Included component: typescript (Monaco worker) 4.4.4')
|
||||
expect(await index.text()).toContain('Included component: dompurify (Monaco core) 2.3.1')
|
||||
expect(await index.text()).toContain('Included component: marked (Monaco core) 3.0.2')
|
||||
expect(await index.text()).toContain('Included component: vscode-html-languageservice 4.1.1')
|
||||
expect(await index.text()).toContain('Included component: vscode-json-languageservice 4.1.9')
|
||||
expect(await index.text()).toContain('Included component: js-beautify (Monaco HTML embedded)')
|
||||
|
||||
Reference in new issue
Block a user