* Install a minimal document.startViewTransition mock. `window.__vtLog` records * lifecycle events (start, skipped, finished) so tests can assert escape-path * behavior on the view transition itself rather than the surrounding DOM.
(evaluate)
| 6 | * behavior on the view transition itself rather than the surrounding DOM. |
| 7 | */ |
| 8 | async function installVTMock(evaluate) { |
| 9 | await evaluate(() => { |
| 10 | window.__vtLog = [] |
| 11 | document.startViewTransition = function (arg) { |
| 12 | window.__vtLog.push('start') |
| 13 | var skipped = false |
| 14 | var updateFn = typeof arg === 'function' ? arg : arg.update |
| 15 | var updateP |
| 16 | try { updateP = updateFn() } catch (e) { updateP = Promise.reject(e) } |
| 17 | var finished = Promise.resolve(updateP).then( |
| 18 | function () { window.__vtLog.push('finished'); }, |
| 19 | function () { window.__vtLog.push('finished-err'); } |
| 20 | ) |
| 21 | return { |
| 22 | finished: finished, |
| 23 | updateCallbackDone: Promise.resolve(updateP), |
| 24 | ready: Promise.resolve(), |
| 25 | skipTransition: function () { skipped = true; window.__vtLog.push('skipped') }, |
| 26 | } |
| 27 | } |
| 28 | }) |
| 29 | } |
| 30 | |
| 31 | test.describe("the start view transition command", () => { |
| 32 |
no test coverage detected