mirror of
https://github.com/zhw2590582/ArtPlayer.git
synced 2026-10-18 10:41:20 -08:00
docs(site): [SITE-07] ship selected font notice references
This commit is contained in:
1 parent
01f3d00e4c
commit
4545c43679
29 files changed
+3508
-12
No files matched your search
@@ -27,6 +27,7 @@ test('mobile vConsole shows logs and upstream site notice texts are served uncha
|
||||
{ path: '/licenses/monaco-editor/core-origins/ATTRIBUTION.md', count: 3 },
|
||||
{ path: '/licenses/monaco-editor/core-path/ATTRIBUTION.md', count: 1 },
|
||||
{ path: '/licenses/monaco-editor/core-dom/ATTRIBUTION.md', count: 1 },
|
||||
{ path: '/licenses/jassub-fonts/ATTRIBUTION.md', count: 4 },
|
||||
]) {
|
||||
const attribution = await request.get(path)
|
||||
expect(attribution.status()).toBe(200)
|
||||
@@ -69,3 +70,39 @@ test('mobile vConsole shows logs and upstream site notice texts are served uncha
|
||||
})
|
||||
await expect(page.locator('#__vconsole')).toHaveCount(0)
|
||||
})
|
||||
|
||||
test('selected JASSUB font URLs preserve bytes and decode with native font loading', async ({ page, request }, testInfo) => {
|
||||
await page.goto('/test/player.html?core=published')
|
||||
const record = JSON.parse(fs.readFileSync('refactor/baselines/site-font-notices-provenance.json', 'utf8'))
|
||||
const results = []
|
||||
for (const [index, file] of record.group.files.entries()) {
|
||||
const url = `/${file.path.slice('docs/'.length)}`
|
||||
const response = await request.get(url)
|
||||
expect(response.status()).toBe(200)
|
||||
expect(createHash('sha256').update(await response.body()).digest('hex')).toBe(file.sha256)
|
||||
const rendered = await page.evaluate(async ({ url, index }) => {
|
||||
const family = `notice-font-${index}`
|
||||
const font = new FontFace(family, `url(${JSON.stringify(url)})`)
|
||||
await font.load()
|
||||
document.fonts.add(font)
|
||||
try {
|
||||
const canvas = document.createElement('canvas')
|
||||
canvas.width = 320
|
||||
canvas.height = 80
|
||||
const context = canvas.getContext('2d')
|
||||
context.font = `32px ${family}`
|
||||
context.fillText('ArtPlayer ABC 123', 4, 45)
|
||||
const pixels = context.getImageData(0, 0, 320, 80).data
|
||||
return { status: font.status, inkPixels: pixels.filter((value, offset) => offset % 4 === 3 && value > 0).length, width: context.measureText('ArtPlayer ABC 123').width }
|
||||
}
|
||||
finally {
|
||||
document.fonts.delete(font)
|
||||
}
|
||||
}, { url, index })
|
||||
expect(rendered.status).toBe('loaded')
|
||||
expect(rendered.inkPixels).toBeGreaterThan(100)
|
||||
expect(rendered.width).toBeGreaterThan(50)
|
||||
results.push({ url, sha256: file.sha256, ...rendered })
|
||||
}
|
||||
await testInfo.attach('selected-font-http-and-native-load', { contentType: 'application/json', body: JSON.stringify(results) })
|
||||
})
|
||||
@@ -8,6 +8,7 @@ import process from 'node:process'
|
||||
// eslint-disable-next-line test/no-import-node-test -- Verify real notice bytes and failure-before-write behavior.
|
||||
import test from 'node:test'
|
||||
import { verifyConsoleNoticeSources } from '../scripts/site-vendor/console/notices.ts'
|
||||
import { verifyFontNotices } from '../scripts/site-vendor/fonts/notices.ts'
|
||||
import { verifyMonacoCoreNotices } from '../scripts/site-vendor/monaco/core-origins.ts'
|
||||
import { domOriginFragments, verifyMonacoDomNotices } from '../scripts/site-vendor/monaco/dom-origins.ts'
|
||||
import { verifyMonacoPathNotices } from '../scripts/site-vendor/monaco/node-path.ts'
|
||||
@@ -16,6 +17,25 @@ import { generateNotices, writeOrCheckNotices } from '../scripts/site-vendor/not
|
||||
|
||||
const hash = bytes => createHash('sha256').update(bytes).digest('hex')
|
||||
|
||||
test('Font notices preserve exact family/source bindings and do not promote unresolved fonts', () => {
|
||||
const original = JSON.parse(fs.readFileSync('scripts/site-vendor/manifest.json', 'utf8'))
|
||||
assert.doesNotThrow(() => verifyFontNotices(process.cwd(), original))
|
||||
const wrongLicense = structuredClone(original)
|
||||
const group = wrongLicense.groups.find(group => group.name === 'jassub-fonts')
|
||||
group.components[0].notices = group.components[1].notices
|
||||
assert.doesNotThrow(() => generateNotices(process.cwd(), wrongLicense))
|
||||
assert.throws(() => verifyFontNotices(process.cwd(), wrongLicense), /Font notice\/source binding/)
|
||||
const missing = structuredClone(original)
|
||||
missing.groups.find(group => group.name === 'jassub-fonts').notices.pop()
|
||||
assert.throws(() => verifyFontNotices(process.cwd(), missing), /Font notice\/source binding/)
|
||||
const promoted = structuredClone(original)
|
||||
promoted.groups.find(group => group.name === 'jassub-fonts').components[0].assets.push('docs/assets/jassub/fonts/arial.ttf')
|
||||
assert.throws(() => verifyFontNotices(process.cwd(), promoted), /Font notice\/source binding/)
|
||||
const record = JSON.parse(fs.readFileSync('refactor/baselines/site-font-notices-provenance.json', 'utf8'))
|
||||
assert(record.unresolved.includes('docs/assets/jassub/fonts/Averia Serif Simple Light.ttf'))
|
||||
assert.notEqual(record.negativeComparison.outlineHashes[0], record.negativeComparison.outlineHashes[1])
|
||||
})
|
||||
|
||||
test('WinJS-derived DOM helpers keep reference terms without claiming an exact original version', () => {
|
||||
const original = JSON.parse(fs.readFileSync('scripts/site-vendor/manifest.json', 'utf8'))
|
||||
assert.doesNotThrow(() => verifyMonacoDomNotices(process.cwd(), original))
|
||||
|
||||
Reference in new issue
Block a user