完成40%

This commit is contained in:
rain
2026-07-14 17:36:39 +08:00
parent 1015e60ff7
commit 8c98936da5
151 changed files with 5132 additions and 351 deletions
+46
View File
@@ -0,0 +1,46 @@
$ErrorActionPreference = 'Stop'
$root = Split-Path -Parent $PSScriptRoot
$captureScriptPath = Join-Path $root 'scripts/capture-chrome-page.js'
if (-not (Test-Path -LiteralPath $captureScriptPath)) {
throw 'Missing Chrome capture script'
}
$captureScript = Get-Content -LiteralPath $captureScriptPath -Raw -Encoding utf8
if ($captureScript -notmatch "const renderSettleMilliseconds = 900") {
throw 'Chrome capture must define a 900ms render-settle delay after the target selector appears'
}
if ($captureScript -notmatch 'await sleep\(renderSettleMilliseconds\)') {
throw 'Chrome capture must wait for the render-settle delay before taking a screenshot'
}
if ($captureScript -match 'await sleep\(300\)') {
throw 'Chrome capture must not retain the unstable 300ms post-selector delay'
}
if ($captureScript -notmatch 'const waitForLoadedImages = async \(send\) =>') {
throw 'Chrome capture must define an image-load wait before a visual screenshot'
}
if ($captureScript -notmatch 'Array\.from\(document\.images\)\.every') {
throw 'Chrome capture must wait until every document image has loaded'
}
if ($captureScript -notmatch 'await waitForLoadedImages\(send\)') {
throw 'Chrome capture must wait for document images after the target selector renders'
}
if ($captureScript -notmatch "await send\('Page.reload'\)") {
throw 'Chrome capture must reload after navigation so route screenshots do not inherit a prior Vue state'
}
if ($captureScript.IndexOf("await send('Page.navigate'") -ge $captureScript.IndexOf("await send('Page.reload')")) {
throw 'Chrome capture must reload only after it has navigated to the requested URL'
}
if ($captureScript -notmatch 'const waitForFreshDocument = async \(send, documentTimeOrigin\) =>') {
throw 'Chrome capture must define a fresh-document wait after reloading'
}
if ($captureScript -notmatch 'performance\.timeOrigin') {
throw 'Chrome capture must distinguish a fresh document from a reused Vue route state'
}
if ($captureScript -notmatch 'await waitForFreshDocument\(send, documentTimeOrigin\)') {
throw 'Chrome capture must wait for a fresh document before checking the target selector'
}
Write-Output 'CAPTURE-CHROME-PAGE-CONTRACT PASS'