diff --git a/AGENTS.md b/AGENTS.md
index 59b36167..31b0df4a 100644
--- a/AGENTS.md
+++ b/AGENTS.md
@@ -804,7 +804,9 @@ element, and the element acts. That relay is why `frame-document.ts` has a `mess
Embed adds a separate origin on top.
`tests/browser/untrusted.test.ts` plays `untrusted.h5p`, whose own copy of the fixture content
type marks the frame, against the bundle and then trusted, checks each content type and the
- header, injects scripts, reads the policy, and refuses `untrusted-newer.h5p` with `carried`. It
+ header, injects scripts, reads the policy, plays `untrusted-newer.h5p` on the bundle's older
+ minor (see *Content written for a newer minor than any source has*) and, with
+ `downgrade-libraries="off"`, refuses it with `carried`. It
plays `untrusted-markup.h5p`, a form, a script, a handler, a `javascript:` link and a field the
semantics do not name, at the top and in sub-content, through the fixture content type's
`.html()`, untrusted and trusted, and refuses it against `libraries-without-semantics.h5p`; the
@@ -1206,6 +1208,59 @@ element, and the element acts. That relay is why `frame-document.ts` has a `mess
the demo's bundled page), or the element's `pack` on a site built with `--no-libraries` where
jsDelivr is allowed. A source that fails outright is passed over while another remains; only
the last one's failure is the load's.
+- **Content written for a newer minor than any source has plays at the newest older one**
+ (2026-10-29, #85). H5P Group's October release put library minors on h5p.com weeks before the
+ hub served them, and the pack follows the hub, so content made there can name a version nothing
+ here has. Measured that day with the demo's quiz relabelled: a content-only export was refused
+ naming its main library; one whose sub-content was newer booted and died with "Cannot read
+ properties of undefined (reading 'on')", nothing drawn and no library named, since nothing checks
+ sub-content before the boot; an untrusted export carrying its own newer copy was refused with
+ `carried`. The owner's rule: what can play, plays. So `resolveLibraryFolder` takes `downgrade`,
+ and with it a dependency nothing satisfies is served from the newest older minor of the same
+ major, never across a major. Four choices in it. **Strict first**: `index()` in the element tries
+ every source for the version named, as before, and only when the last leaves something missing
+ does it switch the load, with an `attach-libraries` carrying `downgrade: true`, and index again,
+ offering the pack with `downgrade` so that `planPack` supplies its older part (unless the package
+ carries, or a source provides, one at least as new). So a later source with the version named
+ wins over an earlier one with an older version, which `pack.test.ts` holds with a bundle at 1.0
+ before the pack at 1.2. **Kept with the load**: the switch is `LoadSettings.downgrade`, so a
+ worker started again serves the folders the frame booted with; the next load starts strict.
+ **Never while arriving**: a partial reader ignores it (`downgrades`), since a package on a host
+ without `Range` may still be bringing its own copy, and a frame booted early on the older one
+ would keep it. **From the parameters too**: the deep index's walk (`checkDependencies`) starts
+ from the sub-content `content.json` names as well as from the manifest, wherever a source has
+ that library's major: an attached archive, or the pack on offer. A stripped export's `h5p.json`
+ names its main library alone and the merged manifest drops what nothing answers for, so the
+ first cut, which walked the manifest only, never saw a question newer than the pack. It played
+ the main library and left the question's library unloaded: the demo's formulas quiz with
+ MultiChoice 1.17 still died as above, which the player page's check by hand found. Missing there
+ now, it goes to the next source and then to the older minor; `newer-child.h5p` in
+ `pack.test.ts` is that shape. A library no source has at its major still plays as before,
+ dropped from the manifest, its sub-content removed by the content check when untrusted, so an
+ old export's retired question type is not refused for it. The walk names each dependency
+ served from a versioned folder below the minor asked. The element keeps them as the load's
+ `downgradedLibraries`, in the `ready` detail too, and warns in the console; the verifier makes
+ each a warning and `report.downgraded` (`--no-downgrade-libraries` refuses instead), the
+ player page and the VS Code extension's bar show them, the player page with an Older if needed
+ switch, and the embed page passes `&downgrade-libraries=off` through and posts the list in its
+ report. The list is the load's because the older copy may be the package's own, with no bundle
+ attached: an export whose `h5p.json` names a newer minor than its folder, or h5p.org's
+ Impressive Presentation, whose libraries ask for Font Awesome 4.5 beside the 4.3 it carries.
+ The first cut put it on `libraryBundle`, which is `null` there, so only the console said so,
+ and the verifier passed such a package without a warning where it had failed before; the
+ branch's own review found it. One thing follows for the
+ pages that ask before a package's own code runs: untrusted, a package carrying a newer minor than
+ the pack's now plays on the pack's, so they ask only for a library no source has at its major, or
+ with the switch off. The embed's `site.test.ts` plays its Question Set 1.99 package both ways.
+ The runtime needed nothing: the content upgrade runs steps only upward (`isUpgrade`), so the
+ parameters play as written, the main library is named at the version served, and a
+ sub-content's string keeps the version it names, which the worker answers from the older folder.
+ What it costs, counted over the pack the same day: 119 of the 469 minor bumps in its libraries'
+ history came with an upgrade step, a change of shape the older code does not read; the others
+ only add. Not done: the SCORM writer stays strict, refusing such a package when the zip is
+ written; and a sub-content library no source has at any minor of its major still fails at
+ runtime, unnamed, when played trusted. `downgrade-libraries="off"` refuses as before, and now
+ names a newer question's library too, where it booted without it.
- **The element says what it is playing: `source`, `metadata`, `libraryBundle`.** Added on
2026-10-09 for the package check an embedding site shows under its preview: the probe's classification and
size (`currentSource`, exposed as a copy), the manifest's metadata plus `mainLibrary` (new on
@@ -2043,8 +2098,9 @@ ours runs a server.
for a part the zip lacks. What neither the package nor the pack supplies is refused when the zip
is written, by the walk the player makes (`servingFolder` mirrors `reachableFolder`, the walk
`missingDependencies`), run over the package without the folders a part replaces and over the
- parts. The walk starts from the sub-content the parameters name as well, which the player would
- find missing only when the runtime reached it. So a gap shows up when the teacher writes the zip,
+ parts. The walk starts from the sub-content the parameters name as well, which the player found
+ missing only when the runtime reached it until #85, and since then finds at index only where a
+ source has the library's major. So a gap shows up when the teacher writes the zip,
not when a learner opens it. Measured: the demo's formulas quiz, a stripped export, took 11 parts,
4 MB, 2.8 MB of it MathDisplay; its full exports took none. In Moodle 4.5 the formulas zip
reached `ready`, fetched exactly those 11 parts and the index, and typeset its LaTeX.
@@ -3094,6 +3150,8 @@ deliberate additions to it, not drift:
at all (`hub` meant the pack until it went before 1.0). Since 0.10 the pack is split, a package downloads only
the parts it needs, and the pack's newer versions play in place of the older ones a package
carries: the design plays what a package carries.
+- Content written for a newer minor than any source has plays at the newest older one, once every
+ source has been tried. The design refuses what is not reachable.
- Content written for an older minor than the one served is upgraded in the frame with the
libraries' own steps. The design serves what a package carries; a bundle that serves newer
minors needs the step the platforms take when they install one.
diff --git a/apps/demo/demo/player-page.js b/apps/demo/demo/player-page.js
index 2932b49a..6b8b5e86 100644
--- a/apps/demo/demo/player-page.js
+++ b/apps/demo/demo/player-page.js
@@ -18,6 +18,7 @@ const bar = document.querySelector('#progress')
const message = document.querySelector('#message')
const log = document.querySelector('#log')
const refreshToggle = document.querySelector('#refresh')
+const downgradeToggle = document.querySelector('#downgrade')
const confirmBox = document.querySelector('#confirm-src')
const modeNote = document.querySelector('#mode-note')
const modeTag = document.querySelector('#mode-tag')
@@ -119,15 +120,29 @@ player.addEventListener('progress', (event) => {
player.addEventListener('ready', () => {
bar.hidden = true
const refreshed = player.libraryBundle?.refreshed ?? []
- modeTag.textContent = player.untrusted
- ? "Untrusted · libraries from this site's pack · content checked"
- : refreshed.length > 0
- ? `Trusted · ${refreshed.length === 1 ? 'one library' : `${refreshed.length} libraries`} at the pack's newer version`
- : player.libraryBundle
- ? "Trusted · its own libraries, the rest from this site's pack"
- : 'Trusted · its own libraries'
+ const downgraded = player.downgradedLibraries
+ const libraries = (count) => (count === 1 ? 'one library' : `${count} libraries`)
+ modeTag.textContent =
+ (player.untrusted
+ ? "Untrusted · libraries from this site's pack · content checked"
+ : refreshed.length > 0
+ ? `Trusted · ${libraries(refreshed.length)} at the pack's newer version`
+ : player.libraryBundle
+ ? "Trusted · its own libraries, the rest from this site's pack"
+ : 'Trusted · its own libraries') + (downgraded.length > 0 ? ` · ${libraries(downgraded.length)} older than the content` : '')
write(`mode ${modeTag.textContent}`)
for (const { library, from, to } of refreshed) write(`refreshed ${library} ${from} → ${to}`)
+ for (const { library, from, to } of downgraded) write(`older ${library} ${to}, made for ${from}`)
+ // Made for a version this site's pack has not got yet, and played at its older one: most of the
+ // time all of it works, but what the newer version added is not there, so the visitor is told.
+ if (downgraded.length > 0) {
+ show(
+ "Made for newer library versions than this site's pack has, so it plays at older ones: " +
+ `${downgraded.map(({ library, from, to }) => `${library} ${from} at ${to}`).join(', ')}. ` +
+ 'What the newer versions added is left out. Turn off Older if needed to refuse such packages instead.',
+ 'warning'
+ )
+ }
// The build every statement will name in `context.revision`. On a host without Range the frame
// can boot before the index that yields it, and the statements wait for it instead.
if (player.revision) write(`revision ${player.revision}`)
@@ -241,10 +256,15 @@ const REFRESH_NOTES = {
on: ' Where the pack has a newer version of a library the package carries, that version plays.',
off: ' The libraries the package carries play as exported.'
}
+const DOWNGRADE_NOTES = {
+ on: ' Content made for a newer version than anything here has plays at the newest older one, without what the newer version added.',
+ off: ' Content made for a newer version than anything here has is refused.'
+}
const playsUntrusted = () => form.elements.mode.value === 'untrusted'
const describeMode = () => {
const mode = form.elements.mode.value
- modeNote.textContent = NOTES[mode] + (mode === 'trusted' ? REFRESH_NOTES[refreshToggle.checked ? 'on' : 'off'] : '')
+ modeNote.textContent =
+ NOTES[mode] + (mode === 'trusted' ? REFRESH_NOTES[refreshToggle.checked ? 'on' : 'off'] : '') + DOWNGRADE_NOTES[downgradeToggle.checked ? 'on' : 'off']
// Untrusted, none of the package's own libraries play, so there is nothing to refresh.
refreshToggle.disabled = mode === 'untrusted'
}
@@ -259,7 +279,12 @@ const applyMode = () => {
player.untrusted = untrusted
if (refreshToggle.checked) player.removeAttribute('refresh-libraries')
else player.setAttribute('refresh-libraries', 'off')
- return untrusted ? ' (untrusted: none of its own code runs)' : refreshToggle.checked ? '' : ' (libraries as exported)'
+ if (downgradeToggle.checked) player.removeAttribute('downgrade-libraries')
+ else player.setAttribute('downgrade-libraries', 'off')
+ return (
+ (untrusted ? ' (untrusted: none of its own code runs)' : refreshToggle.checked ? '' : ' (libraries as exported)') +
+ (downgradeToggle.checked ? '' : ' (no older versions)')
+ )
}
/** Plays a package at a URL, in the switch's mode. */
@@ -322,6 +347,12 @@ refreshToggle.addEventListener('change', () => {
reload?.()
})
+// And content made for a newer version than the pack has: played at its older one, or refused.
+downgradeToggle.addEventListener('change', () => {
+ describeMode()
+ reload?.()
+})
+
// A sample marked `data-untrusted` plays as data against this site's bundle: a content-only
// export, as h5p.com and h5p.org make them, the way a site plays a package it did not make. The
// others play in whichever mode the switch is in.
diff --git a/apps/demo/index.html b/apps/demo/index.html
index 1f8e3270..e673630d 100644
--- a/apps/demo/index.html
+++ b/apps/demo/index.html
@@ -114,9 +114,10 @@
Self-hosted H5P in one web component
Choose file
-
+
@@ -125,6 +126,9 @@
Self-hosted H5P in one web component
+
+
+
The package's own scripts run on this site. What it lacks comes from this site's library pack.
if (settings.libraries) player.setAttribute('libraries', settings.libraries)
if (settings.packBase) player.setAttribute('pack-base', settings.packBase)
if (!settings.refreshLibraries) player.setAttribute('refresh-libraries', 'off')
+ // `false` only: a preview page from before the option said nothing, and the element's default is on.
+ if (settings.downgradeLibraries === false) player.setAttribute('downgrade-libraries', 'off')
if (settings.untrusted) player.untrusted = true
// Set once its server has gone. A load still under way changes state after that, and its
// "Opening…" or the error of a request that failed would write over the page saying so.
diff --git a/packages/verify/lib/preview.mjs b/packages/verify/lib/preview.mjs
index ac58b792..a12e3cc1 100644
--- a/packages/verify/lib/preview.mjs
+++ b/packages/verify/lib/preview.mjs
@@ -39,6 +39,8 @@ const HEARTBEAT_MS = 15_000
* @property {boolean} [untrusted] play it as a site that did not make it plays it
* @property {boolean} [refreshLibraries] with the pack, play its newer versions of the libraries the
* package carries; default true
+ * @property {boolean} [downgradeLibraries] play a library the content names at a newer minor than any
+ * source has at the newest older one; default true
* @property {{ dist: string, runtime: string }} [roots] the player's `dist/` and the runtime's, for a host
* that ships them itself, as the VS Code extension does; the installed packages' otherwise
* @property {number} [port] the port to take; default 4645, and any free one when that is taken
@@ -67,6 +69,7 @@ export async function previewPackage(options) {
libraries: sources.attribute,
packBase: sources.packBase,
refreshLibraries: options.refreshLibraries !== false,
+ downgradeLibraries: options.downgradeLibraries !== false,
untrusted: options.untrusted === true
}
// `<` as an escape, so that no file name can end the script block it is written into.
diff --git a/packages/verify/lib/verify.mjs b/packages/verify/lib/verify.mjs
index ffdc61ef..4549dd80 100644
--- a/packages/verify/lib/verify.mjs
+++ b/packages/verify/lib/verify.mjs
@@ -7,7 +7,7 @@ import { VerifyError, librarySources, packageFile, playerDist, sendFile, serve }
export { VerifyError }
-/** @import { H5PPlayerElement, PlayerErrorDetail, PlayerState, RefreshedLibrary } from '@missing-elements/h5p-offline-player' */
+/** @import { DowngradedLibrary, H5PPlayerElement, PlayerErrorDetail, PlayerState, RefreshedLibrary } from '@missing-elements/h5p-offline-player' */
/**
* Plays a package the way a learner would — the real element, the real Service Worker, a real
@@ -44,6 +44,8 @@ const CONTENT_CHECK_HEADER = 'X-H5P-Content-Check'
* @property {boolean} [untrusted] play the package `untrusted`, as a site that did not make it plays it
* @property {boolean} [refreshLibraries] with the pack, play its newer versions of the libraries the
* package carries, as the element does unless told otherwise; default true
+ * @property {boolean} [downgradeLibraries] play a library the content names at a newer minor than
+ * any source has at the newest older one, as the element does unless told otherwise; default true
* @property {string} [out] where `report.json` and `screenshot.png` go; nothing is written without it
* @property {string} [browser] a Chromium-based browser executable; found automatically otherwise
* @property {number} [readyTimeout] ms allowed to reach `ready`; default 60 000
@@ -60,6 +62,8 @@ const CONTENT_CHECK_HEADER = 'X-H5P-Content-Check'
* @property {string | null} libraries the libraries asked for; `pack` when played untrusted and none were named
* @property {boolean} untrusted whether the element played it untrusted, read back from it
* @property {RefreshedLibrary[]} refreshed the libraries the package carries that played at the pack's newer version
+ * @property {DowngradedLibrary[]} downgraded the libraries the content names at a newer minor than any
+ * source has, which played at the newest older one; each is also a warning
* @property {'pass' | 'fail'} verdict
* @property {string[]} reasons why it failed; empty on a pass
* @property {string[]} warnings what is worth reading either way
@@ -187,6 +191,7 @@ export async function verifyPackage(options) {
if (sources.attribute) query.set('libraries', sources.attribute)
if (sources.packBase) query.set('pack-base', sources.packBase)
if (options.refreshLibraries === false) query.set('refresh-libraries', 'off')
+ if (options.downgradeLibraries === false) query.set('downgrade-libraries', 'off')
if (untrusted) query.set('untrusted', '')
await page.goto(`${server.url}/${query.size ? `?${query}` : ''}`)
await page.setInputFiles('#file', file)
@@ -211,7 +216,8 @@ export async function verifyPackage(options) {
state: player.state,
revision: player.revision,
untrusted: player.untrusted === true,
- libraryBundle: player.libraryBundle
+ libraryBundle: player.libraryBundle,
+ downgradedLibraries: player.downgradedLibraries
}
})
const frame = page.frames().find((candidate) => candidate.url().includes('/h5p/frame/'))
@@ -269,6 +275,10 @@ export async function verifyPackage(options) {
// The libraries the package carries that played at the pack's newer version: what a site
// with the pack shows, and a sign the export is older than the pack.
refreshed: collected.libraryBundle?.refreshed ?? [],
+ // Made for a newer minor than any source has, and played at an older one: what the newer
+ // version added is left out, which only a person playing it can judge.
+ // The load's, not the bundle's: a package that carries an older minor itself has no bundle.
+ downgraded: collected.downgradedLibraries ?? [],
verdict: 'pass',
reasons: [],
warnings: [],
@@ -307,6 +317,9 @@ export async function verifyPackage(options) {
report.verdict = 'fail'
report.reasons.push(`${booting.length} uncaught error${booting.length === 1 ? '' : 's'} while booting: ${dedupe(booting.map((e) => e.message)).join('; ')}`)
}
+ for (const { library, from, to } of report.downgraded) {
+ report.warnings.push(`${library} played at ${to}, older than the ${from} the content was made for, since no library source has ${from}: what ${from} added is left out`)
+ }
for (const message of dedupe(report.errors.filter((e) => e.afterReady).map((e) => e.message))) report.warnings.push(`runtime error after ready: ${message}`)
for (const { url, status, error } of failedRequests) report.warnings.push(`request failed: ${url} (${status ?? error})`)
for (const { directive, blocked } of csp) report.warnings.push(`blocked by the frame's CSP: ${blocked} (${directive})`)
diff --git a/packages/verify/tests/verify.test.ts b/packages/verify/tests/verify.test.ts
index 70b1998a..2cd31c2d 100644
--- a/packages/verify/tests/verify.test.ts
+++ b/packages/verify/tests/verify.test.ts
@@ -99,6 +99,21 @@ const quizNeedingNewerLibrary = () =>
await writer.add(folder ? entry.filename.replace(folder[0], 'H5P.QuestionSet-1.99/') : entry.filename, new Uint8ArrayReader(bytes))
})
+/**
+ * The quiz whose `h5p.json` names Question Set 1.99 while its folder stays at the version it was
+ * built with, as an export whose manifest and folders disagree: nothing has 1.99, and its own
+ * older copy plays it, with no library source attached.
+ */
+const quizNamingNewerThanItCarries = () =>
+ rewrittenQuiz('names-newer.h5p', async (entry, bytes, writer) => {
+ if (entry.filename === 'h5p.json') {
+ const json = JSON.parse(new TextDecoder().decode(bytes))
+ for (const dependency of json.preloadedDependencies) if (dependency.machineName === 'H5P.QuestionSet') dependency.minorVersion = 99
+ bytes = new TextEncoder().encode(JSON.stringify(json))
+ }
+ await writer.add(entry.filename, new Uint8ArrayReader(bytes))
+ })
+
/** The quiz built against an older patch of Question Set than the pack has: its own `library.json` says patch 0. */
const quizWithOlderPatch = () =>
rewrittenQuiz('older-patch.h5p', async (entry, bytes, writer) => {
@@ -230,9 +245,28 @@ describe('h5p-verify', () => {
expect(report.warnings).toEqual([])
}, 120_000)
- it('played untrusted, refuses a package that needs its own copy of a library, and says what to do', async () => {
+ it('played untrusted, plays a package made for a newer minor than the pack has at the pack\'s, with a warning (#85)', async () => {
const report = await verifyPackage({ file: await quizNeedingNewerLibrary(), untrusted: true, libraries: pack })
+ expect(report.verdict).toBe('pass')
+ expect(report.downgraded).toEqual([{ library: 'H5P.QuestionSet', from: '1.99', to: expect.stringMatching(/^1\.21\.\d+$/) }])
+ expect(report.warnings.some((warning) => warning.startsWith('H5P.QuestionSet played at 1.21.') && warning.includes('1.99'))).toBe(true)
+ expect(summarize(report)).toContain('warning: H5P.QuestionSet played at 1.21.')
+ }, 120_000)
+
+ it('played trusted with no library source, warns of a library played at the older minor the package carries (#85)', async () => {
+ // Nothing supplied anything, so there is no library bundle. The report took the list from it
+ // once, and this passed with no warning, where before the fallback it failed naming 1.99.
+ const report = await verifyPackage({ file: await quizNamingNewerThanItCarries() })
+
+ expect(report.verdict).toBe('pass')
+ expect(report.downgraded).toEqual([{ library: 'H5P.QuestionSet', from: '1.99', to: expect.stringMatching(/^1\.\d+\.\d+$/) }])
+ expect(report.warnings.some((warning) => warning.startsWith('H5P.QuestionSet played at 1.') && warning.includes('1.99'))).toBe(true)
+ }, 120_000)
+
+ it('played untrusted with --no-downgrade-libraries, refuses a package that needs its own copy of a library, and says what to do', async () => {
+ const report = await verifyPackage({ file: await quizNeedingNewerLibrary(), untrusted: true, libraries: pack, downgradeLibraries: false })
+
expect(report.verdict).toBe('fail')
expect(report.errors[0]?.missingLibraries?.carried).toBe(true)
expect(report.errors[0]?.missingLibraries?.folders).toContain('H5P.QuestionSet-1.99')
diff --git a/packages/vscode/src/page.mjs b/packages/vscode/src/page.mjs
index bcba8794..0b423b43 100644
--- a/packages/vscode/src/page.mjs
+++ b/packages/vscode/src/page.mjs
@@ -49,13 +49,15 @@ export function viewPage(settings) {
player.addEventListener('statechange', (event) => tell({ type: 'state', state: event.detail.state }))
player.addEventListener('ready', (event) => {
- const { metadata, libraryBundle } = event.detail
+ const { metadata, libraryBundle, downgradedLibraries } = event.detail
tell({
type: 'ready',
title: (metadata && metadata.title) || null,
mainLibrary: (metadata && metadata.mainLibrary) || null,
license: metadata && metadata.license ? [metadata.license, metadata.licenseVersion].filter(Boolean).join(' ') : null,
refreshed: (libraryBundle && libraryBundle.refreshed) || [],
+ // Made for a newer version than the pack the extension carries, and played at an older one.
+ downgraded: downgradedLibraries || [],
// The attribute, which is what the element plays by.
untrusted: player.hasAttribute('untrusted')
})
diff --git a/packages/vscode/src/webview.mjs b/packages/vscode/src/webview.mjs
index bd7c6c2b..5055acdb 100644
--- a/packages/vscode/src/webview.mjs
+++ b/packages/vscode/src/webview.mjs
@@ -116,15 +116,19 @@ export function webviewHtml({ nonce, config }) {
const name = document.createElement('strong')
name.textContent = message.title || config.name
const parts = [message.mainLibrary, message.license, message.untrusted ? 'untrusted' : null]
- if (message.refreshed.length > 0) {
- parts.push((message.refreshed.length === 1 ? 'one library' : message.refreshed.length + ' libraries') + " at the pack's newer version")
- }
+ const libraries = (count) => (count === 1 ? 'one library' : count + ' libraries')
+ const downgraded = message.downgraded || []
+ if (message.refreshed.length > 0) parts.push(libraries(message.refreshed.length) + " at the pack's newer version")
+ if (downgraded.length > 0) parts.push(libraries(downgraded.length) + ' older than the content')
const detail = document.createElement('span')
detail.className = 'detail'
detail.textContent = parts.filter(Boolean).map((part) => ' · ' + part).join('')
status.className = ''
status.replaceChildren(name, detail)
- status.title = message.refreshed.map((library) => library.library + ' ' + library.from + ' → ' + library.to).join('\\n')
+ status.title = [
+ ...message.refreshed.map((library) => library.library + ' ' + library.from + ' → ' + library.to),
+ ...downgraded.map((library) => library.library + ' made for ' + library.from + ', played at ' + library.to)
+ ].join('\\n')
}
function showError(message) {
diff --git a/packages/vscode/tests/html.test.ts b/packages/vscode/tests/html.test.ts
index 0189f67f..31d32ef6 100644
--- a/packages/vscode/tests/html.test.ts
+++ b/packages/vscode/tests/html.test.ts
@@ -167,6 +167,15 @@ describe('the webview', () => {
expect((status.children[0] as StandIn).textContent).toBe('Quiz')
})
+ it('says in the bar how many libraries played older than the content, and which in its tooltip', () => {
+ const { receive, fromPage, status } = runWebview()
+ const refreshed = [{ library: 'H5P.Question', from: '1.5.9', to: '1.5.12' }]
+ const downgraded = [{ library: 'H5P.MultiChoice', from: '1.17', to: '1.16.27' }]
+ receive({ source: 'h5p-preview', type: 'ready', title: 'Quiz', mainLibrary: 'H5P.QuestionSet', license: null, refreshed, downgraded, untrusted: false }, fromPage)
+ expect((status.children[1] as StandIn).textContent).toBe(" · H5P.QuestionSet · one library at the pack's newer version · one library older than the content")
+ expect(status.title).toBe('H5P.Question 1.5.9 → 1.5.12\nH5P.MultiChoice made for 1.17, played at 1.16.27')
+ })
+
it('takes the page’s messages from the server’s origin only', () => {
const { posted, receive, frame } = runWebview()
posted.length = 0
@@ -215,9 +224,13 @@ describe('the page a preview frames', () => {
it('tells what the element reached to the webview around it, and to no other window', () => {
const { player, told } = runPage({ untrusted: true })
const ready = player.listeners.get('ready') as Listener
- ready({ detail: { metadata: { title: 'Quiz', mainLibrary: 'H5P.QuestionSet', license: 'CC BY', licenseVersion: '4.0' }, libraryBundle: { refreshed: [] } } })
+ const downgradedLibraries = [{ library: 'H5P.MultiChoice', from: '1.17', to: '1.16.27' }]
+ ready({ detail: { metadata: { title: 'Quiz', mainLibrary: 'H5P.QuestionSet', license: 'CC BY', licenseVersion: '4.0' }, libraryBundle: { refreshed: [] }, downgradedLibraries } })
expect(told).toEqual([
- [{ source: 'h5p-preview', type: 'ready', title: 'Quiz', mainLibrary: 'H5P.QuestionSet', license: 'CC BY 4.0', refreshed: [], untrusted: true }, WEBVIEW_ORIGIN]
+ [
+ { source: 'h5p-preview', type: 'ready', title: 'Quiz', mainLibrary: 'H5P.QuestionSet', license: 'CC BY 4.0', refreshed: [], downgraded: downgradedLibraries, untrusted: true },
+ WEBVIEW_ORIGIN
+ ]
])
const alone = runPage({}, [])