claim page: live progress animation; heading focus on refused links
Paul's two review fixes. Progress: the current step shows a visible arc spinning about the ring's own centre, a pulsing dot and dashes marching toward the server while copying and starting; under reduced motion the current dot breathes (2 s) instead of everything going still. Refused links focus the heading (tabindex=-1); the message keeps role=alert; script-focused elements draw no ring. Inline console stylesheet only, CSP unchanged, no layout shift. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Squashed from claim-spent-focus into main. Co-Authored-By: codex <codex~paul@keymail.dev>
6 files changed,
+187
−14
internal/console/demo_claim_choice_test.go+1 −1internal/console/demo_claim_ux_test.go+18 −2internal/console/static/demo_claim.js+3 −1internal/console/templates/demo_claim.html+17 −8internal/console/testdata/demo_claim_browser.mjs+10 −2internal/console/testdata/demo_claim_motion.mjs+138 −0
CI passed — run details
diff --git a/internal/console/demo_claim_choice_test.go b/internal/console/demo_claim_choice_test.go| index 6e94cb44b..4b3a8842a 100644 |
| --- a/internal/console/demo_claim_choice_test.go |
| +++ b/internal/console/demo_claim_choice_test.go |
| @@ -398,7 +398,7 @@ func TestDemoClaimProgressAndOutcome(t *testing.T) { |
| t.Error("current step is not marked") |
| } |
| } else { |
| - if !strings.Contains(body, `<h1 id="claim-heading">example is yours</h1>`) || strings.Contains(body, demoClaimComplete) { |
| + if !strings.Contains(body, `<h1 id="claim-heading" tabindex="-1">example is yours</h1>`) || strings.Contains(body, demoClaimComplete) { |
| t.Error("outcome must appear once, as the heading") |
| } |
| link := regexp.MustCompile(`<a class="btn claim-open" href="([^"]+)" rel="noreferrer">([^<]+)</a>`).FindStringSubmatch(body) |
diff --git a/internal/console/demo_claim_ux_test.go b/internal/console/demo_claim_ux_test.go| index cef83bb9f..4973fd63d 100644 |
| --- a/internal/console/demo_claim_ux_test.go |
| +++ b/internal/console/demo_claim_ux_test.go |
| @@ -120,7 +120,7 @@ func TestDemoClaimUXHeadless(t *testing.T) { |
| } |
| type scene struct{ Name, URL, Cookie, Session, State, Text string } |
| var scenes []scene |
| - for _, name := range []string{"email", "code", "one", "many", "no-accounts", "new-account", "missing", "missing-link", "disabled", "copying", "starting", "unknown", "stopping", "aborted", "done", "fast", "expired", "kept", "taken-down", "invalid"} { |
| + for _, name := range []string{"email", "code", "one", "many", "no-accounts", "new-account", "missing", "missing-link", "disabled", "copying", "starting", "unknown", "stopping", "aborted", "done", "fast", "motion", "expired", "kept", "taken-down", "invalid"} { |
| s, _, b := claimSigninFixture(t) |
| s.consoleMail = &fakeConsoleMail{ready: true} |
| state := "proof" |
| @@ -129,7 +129,7 @@ func TestDemoClaimUXHeadless(t *testing.T) { |
| t.Fatal(w.Code) |
| } |
| } |
| - phase := map[string]string{"copying": "copying", "starting": "verifying", "unknown": "future-phase", "stopping": "aborting", "aborted": "aborted", "done": "done", "fast": "copying"}[name] |
| + phase := map[string]string{"copying": "copying", "starting": "verifying", "unknown": "future-phase", "stopping": "aborting", "aborted": "aborted", "done": "done", "fast": "copying", "motion": "future-phase"}[name] |
| if phase != "" || name == "one" || name == "many" || name == "no-accounts" { |
| b.login("shop@example.com", MethodEmail, true) |
| role := RoleOwner |
| @@ -191,6 +191,22 @@ func TestDemoClaimUXHeadless(t *testing.T) { |
| } |
| fast := name == "fast" |
| ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { |
| + if name == "motion" && r.Method == http.MethodPost && r.URL.Path == "/__test_claim_phase" { |
| + phase := r.URL.Query().Get("phase") |
| + switch phase { |
| + case "future-phase", "copying", "verifying", "aborting": |
| + default: |
| + w.WriteHeader(http.StatusBadRequest) |
| + return |
| + } |
| + if _, err := s.store.db.Exec(`UPDATE demo_claim_ops SET phase=?`, phase); err != nil { |
| + t.Error(err) |
| + w.WriteHeader(http.StatusInternalServerError) |
| + return |
| + } |
| + w.WriteHeader(http.StatusNoContent) |
| + return |
| + } |
| if fast && r.URL.Path == "/demo/claim" && r.URL.Query().Has("replay") { |
| if _, err := s.store.db.Exec(`UPDATE demo_claim_ops SET phase='copying'`); err != nil { |
| t.Error(err) |
diff --git a/internal/console/static/demo_claim.js b/internal/console/static/demo_claim.js| index d0239811b..a2edb27cb 100644 |
| --- a/internal/console/static/demo_claim.js |
| +++ b/internal/console/static/demo_claim.js |
| @@ -259,7 +259,9 @@ |
| const error = document.getElementById("claim-error"); |
| error.textContent = messages.get(reason) || copy.failed; |
| error.hidden = false; |
| - error.focus(); |
| + // The heading takes focus (tabindex=-1); the message is announced by its |
| + // alert role, and plain text never shows a focus ring. |
| + heading.focus(); |
| }; |
| const visible = paint().then(() => wait(minimum)); |
| fetch(kept ? "/demo/claim/kept" : "/demo/claim/intent", { |
diff --git a/internal/console/templates/demo_claim.html b/internal/console/templates/demo_claim.html| index a22f78dab..6428e7768 100644 |
| --- a/internal/console/templates/demo_claim.html |
| +++ b/internal/console/templates/demo_claim.html |
| @@ -15,6 +15,7 @@ |
| #claim .claim-card { display: flex; align-items: flex-start; gap: 0.75rem; border: 1px solid var(--rule); border-radius: var(--rst-radius-sm); padding: 1rem; margin: 0 0 0.65rem; cursor: pointer; } |
| #claim .claim-card:has(:checked) { background: var(--accent-soft); border-color: var(--accent); } |
| #claim .claim-card:has(:focus-visible) { outline: 2px solid var(--accent); outline-offset: 2px; } |
| +#claim [tabindex="-1"]:focus { outline: none; } |
| #claim .claim-card:has(:disabled) { color: var(--muted); background: var(--rst-surface-2); cursor: not-allowed; } |
| #claim .claim-card input { flex: none; width: 1.1rem; height: 1.1rem; margin-top: 0.25rem; accent-color: var(--accent); } |
| #claim .claim-card strong, #claim .claim-card .claim-detail { display: block; } |
| @@ -76,7 +77,8 @@ |
| #claim .claim-transit > span:not(.claim-track) { display: grid; place-items: center; height: 3.25rem; border: 1px dashed var(--muted); border-radius: 12px; } |
| #claim .claim-transit svg { width: 24px; height: 24px; } |
| #claim .claim-transit .claim-home { color: white; background: var(--rst-accent-fill); border-style: solid; } |
| -#claim .claim-track { position: relative; height: 2px; border-top: 2px dashed var(--rule); } |
| +#claim .claim-track { position: relative; height: 2px; background: repeating-linear-gradient(90deg, var(--rule) 0 6px, transparent 6px 12px); background-size: 12px 2px; } |
| +#claim [data-stage="1"] .claim-track, #claim [data-stage="2"] .claim-track { background-image: repeating-linear-gradient(90deg, var(--accent) 0 6px, transparent 6px 12px); animation: claim-flow .8s linear infinite; } |
| #claim .claim-track i { position: absolute; top: -5px; left: 0; width: 7px; height: 7px; border-radius: 2px; background: var(--accent); opacity: 0; } |
| #claim [data-stage="1"] .claim-track i { animation: claim-travel 1.8s ease-in-out infinite; } |
| #claim .claim-track i:nth-child(2) { animation-delay: .25s; } |
| @@ -85,11 +87,13 @@ |
| #claim .claim-steps { list-style: none; padding: 0; } |
| #claim .claim-steps li { position: relative; min-height: 3rem; padding: 0 0 1.5rem 2.5rem; } |
| #claim .claim-step-detail { display: block; font-weight: 400; font-size: .95rem; margin-top: .25rem; } |
| -#claim .claim-node { position: absolute; left: 0; top: 0; width: 26px; height: 26px; border: 2px solid var(--muted); border-radius: 50%; display: grid; place-items: center; } |
| -#claim .claim-node svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 2; opacity: 0; } |
| -#claim [aria-current=step] .claim-node { border-color: var(--accent); } |
| -#claim [aria-current=step] .claim-node::before { content: ""; position: absolute; inset: -2px; border: 2px solid transparent; border-top-color: var(--accent); border-radius: 50%; animation: claim-spin .7s linear infinite; } |
| -#claim [aria-current=step] .claim-node::after { content: ""; position: absolute; inset: 7px; background: var(--accent); border-radius: 50%; } |
| +#claim .claim-node { position: absolute; left: 0; top: 0; box-sizing: border-box; width: 26px; height: 26px; border: 2px solid var(--muted); border-radius: 50%; } |
| +#claim .claim-node::before { content: ""; position: absolute; inset: -2px; box-sizing: border-box; width: 26px; height: 26px; border: 2px solid transparent; border-radius: 50%; transform-origin: center; } |
| +#claim .claim-node::after { content: ""; position: absolute; inset: 0; margin: auto; width: 8px; height: 8px; background: var(--accent); border-radius: 50%; opacity: 0; } |
| +#claim .claim-node svg { position: absolute; inset: 0; margin: auto; width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 2; opacity: 0; } |
| +#claim [aria-current=step] .claim-node { border-color: var(--accent-soft); } |
| +#claim [aria-current=step] .claim-node::before { border-top-color: var(--accent); border-right-color: var(--accent); animation: claim-spin .9s linear infinite; } |
| +#claim [aria-current=step] .claim-node::after { animation: claim-dot-breathe 1.2s ease-in-out infinite; } |
| #claim .claim-steps .is-done .claim-node { color: var(--claim-good); border-color: var(--claim-good); } |
| #claim .claim-steps .is-done svg { opacity: 1; } |
| #claim .claim-steps .is-failed { color: var(--claim-warn); } |
| @@ -121,6 +125,8 @@ |
| #claim.is-celebrating .claim-tick { stroke-dasharray: 20; animation: claim-tick .45s ease-out .55s both; } |
| #claim.is-celebrating #claim-finished { animation: claim-fade .5s ease .8s both; } |
| @keyframes claim-spin { to { transform: rotate(1turn); } } |
| +@keyframes claim-flow { to { background-position: 12px 0; } } |
| +@keyframes claim-dot-breathe { 0%,100% { opacity: 1; } 50% { opacity: .4; } } |
| @keyframes claim-travel { 0% { left: 0; opacity: 0; } 20%,80% { opacity: 1; } 100% { left: 100%; opacity: 0; } } |
| @keyframes claim-breathe { 50% { box-shadow: 0 0 0 6px var(--accent-soft); } } |
| @keyframes claim-wipe-in { from { clip-path: inset(0 100% 0 0); } to { clip-path: inset(0); } } |
| @@ -130,6 +136,9 @@ |
| @keyframes claim-burst { 0% { opacity: 1; transform: rotate(var(--a)) translateX(6px) scale(.4); } 70% { opacity: 1; } 100% { opacity: 0; transform: rotate(var(--a)) translateX(var(--d)) rotate(90deg); } } |
| @media (prefers-reduced-motion: reduce) { |
| #claim *, #claim *::before, #claim *::after { animation: none !important; transition: none !important; } |
| + #claim [aria-current=step] .claim-node { border-color: var(--accent); } |
| + #claim [aria-current=step] .claim-node::before { border-color: transparent; } |
| + #claim [aria-current=step] .claim-node::after { animation: claim-dot-breathe 2s ease-in-out infinite !important; } |
| #claim .claim-track i, #claim .claim-burst, #claim.is-celebrating .claim-address .claim-old { display: none; } |
| #claim.is-celebrating #claim-finished { animation: claim-fade .2s ease both !important; } |
| } |
| @@ -145,13 +154,13 @@ |
| <span class="claim-life"><svg class="claim-clock" viewBox="0 0 16 16" aria-hidden="true"><circle cx="8" cy="8" r="6"/><path class="claim-hands" d="M8 4v4l3 2"/><path class="claim-tick" d="M4 8l3 3 5-6"/></svg><time class="claim-old" datetime="{{.EndTime}}" title="{{.EndTime}}"><span aria-hidden="true">{{.TimeLeft}}</span><span class="claim-sr-only">{{.TimeLeftAccessible}}</span></time><span class="claim-new">{{.Copy.done}}</span></span></div> |
| <span class="claim-burst" aria-hidden="true"><i></i><i></i><i></i><i></i><i></i><i></i><i></i><i></i></span> |
| </div>{{end}} |
| -<h1 id="claim-heading">{{if eq .State "claimed"}}{{.Copy.completeHeading}}{{else if or (eq .State "stopping") (eq .State "aborted")}}{{.Copy.failureHeading}}{{else if .EmailPending}}{{.Copy.codeHeading}}{{else if and .Address (gt .Eligible 1)}}{{.Copy.accountsHeading}}{{else if eq .State "proof"}}{{.Copy.heading}}{{else}}{{.Copy.title}}{{end}}</h1> |
| +<h1 id="claim-heading" tabindex="-1">{{if eq .State "claimed"}}{{.Copy.completeHeading}}{{else if or (eq .State "stopping") (eq .State "aborted")}}{{.Copy.failureHeading}}{{else if .EmailPending}}{{.Copy.codeHeading}}{{else if and .Address (gt .Eligible 1)}}{{.Copy.accountsHeading}}{{else if eq .State "proof"}}{{.Copy.heading}}{{else}}{{.Copy.title}}{{end}}</h1> |
| {{if .Error}}<p role="alert">{{.Error}}</p><p><a href="/demo/claim">{{.Copy.back}}</a></p>{{end}} |
| {{if eq .State "no_accounts"}}<p>{{.Copy.identity}} <strong>{{.Address}}</strong></p><p>{{.Copy.noAccounts}}</p> |
| <fieldset class="claim-unavailable"><legend>{{.Copy.accountsLabel}}</legend>{{range .Accounts}}{{template "claim_card" .}}{{end}}</fieldset>{{end}} |
| <input type="hidden" name="nonce" value="{{.Nonce}}"> |
| <input type="hidden" name="csrf" value="{{.CSRF}}"> |
| -<p id="claim-error" role="alert" tabindex="-1" hidden></p> |
| +<p id="claim-error" role="alert" hidden></p> |
| <p id="claim-opening" role="status"{{if ne .State "missing"}} hidden{{end}}><span class="claim-spinner" aria-hidden="true"></span>{{.Copy.opening}}</p>{{if eq .State "missing"}}<p id="claim-missing" hidden>{{.Copy.missing}}</p>{{end}} |
| <div id="claim-expired-next" hidden><p>{{.Copy.newDemo}}</p><div class="claim-paste"><code id="claim-new-demo">{{.Copy.newDemoLine}}</code><button class="btn-sm btn-secondary" type="button" data-copy-target="claim-new-demo" data-copy="{{.Copy.copy}}" data-copied="{{.Copy.copied}}" hidden>{{.Copy.copy}}</button></div></div> |
| <p id="claim-kept-next" hidden><a href="/?next=%2Fdemo%2Fclaim">{{.Copy.consoleSignin}}</a></p> |
diff --git a/internal/console/testdata/demo_claim_browser.mjs b/internal/console/testdata/demo_claim_browser.mjs| index 91953663a..14657805c 100644 |
| --- a/internal/console/testdata/demo_claim_browser.mjs |
| +++ b/internal/console/testdata/demo_claim_browser.mjs |
| @@ -2,6 +2,7 @@ import {spawn} from 'node:child_process'; |
| import assert from 'node:assert/strict'; |
| import {writeFile} from 'node:fs/promises'; |
| import {captureClaim, watchClaimCSP} from './demo_claim_layout.mjs'; |
| +import {checkClaimMotion} from './demo_claim_motion.mjs'; |
| const [binary, profile, target, screenshots, expectedError] = process.argv.slice(2); |
| const chrome = spawn(binary, ['--headless', '--no-sandbox', '--disable-gpu', |
| @@ -58,7 +59,9 @@ try { |
| if (expectedError) { |
| await until('location.hash === "" && document.getElementById("claim-error")?.hidden === false'); |
| assert.equal(await evaluate('document.getElementById("claim-error").textContent'), expectedError); |
| - assert.equal(await evaluate('document.activeElement.id'), 'claim-error'); |
| + assert.equal(await evaluate('document.activeElement.id'), 'claim-heading'); |
| + assert.equal(await evaluate('getComputedStyle(document.activeElement).outlineStyle'), 'none'); |
| + assert.equal(await evaluate('document.getElementById("claim-error").hasAttribute("tabindex")'), false); |
| assert.deepEqual(await evaluate('window.claimCSPViolations'), []); |
| const history = await call('Page.getNavigationHistory'); |
| assert(history.entries.every(entry => !entry.url.includes('#'))); |
| @@ -135,6 +138,11 @@ async function runUX(scenes) { |
| await call('Page.navigate',{url:scene.URL}); |
| await until('document.readyState === "complete" && !!document.getElementById("claim")'); |
| assert.equal(await evaluate('document.getElementById("claim").dataset.state'),scene.State,scene.Name); |
| + if (scene.Name === 'motion') { |
| + await checkClaimMotion(call, evaluate, until, screenshots, scene.URL); |
| + process.stdout.write('live progress: centred rings/dots/ticks, spin, flowing path, calm breathe, zero CSP violations; 390/1280 light/dark passed\n'); |
| + continue; |
| + } |
| if (scene.Text) { |
| await until('document.getElementById("claim-error").hidden === false'); |
| assert.equal(await evaluate('document.getElementById("claim-error").textContent'),scene.Text); |
| @@ -170,7 +178,7 @@ async function runUX(scenes) { |
| } |
| await captureClaim(call,evaluate,screenshots,scene.Name,[390,1280]); |
| if (scene.Name === 'fast') await liveMotion(scene); |
| - assert.equal(await evaluate(`Array.from(document.getAnimations()).some(a => a.playState === 'running' && a.animationName !== 'claim-fade')`),false,'reduced motion travels'); |
| + assert.equal(await evaluate(`Array.from(document.getAnimations()).some(a => a.playState === 'running' && !['claim-fade','claim-dot-breathe'].includes(a.animationName))`),false,'reduced motion travels'); |
| if (['email','code','one','many'].includes(scene.Name)) { |
| await evaluate(`(() => { |
| const form = document.querySelector('#claim form'); |
diff --git a/internal/console/testdata/demo_claim_motion.mjs b/internal/console/testdata/demo_claim_motion.mjs| new file mode 100644 |
| index 000000000..13785b3f5 |
| --- /dev/null |
| +++ b/internal/console/testdata/demo_claim_motion.mjs |
| @@ -0,0 +1,138 @@ |
| +import assert from 'node:assert/strict'; |
| +import {writeFile} from 'node:fs/promises'; |
| + |
| +const wait = ms => new Promise(resolve => setTimeout(resolve, ms)); |
| +const near = (actual, expected, message) => assert(Math.abs(actual - expected) < .05, `${message}: ${actual} != ${expected}`); |
| + |
| +// Chromium's box model includes generated content; measuring only the parent |
| +// would miss a dot or arc orbiting outside an otherwise stationary ring. |
| +async function indicatorBoxes(call) { |
| + const {root} = await call('DOM.getDocument'); |
| + const {nodeIds} = await call('DOM.querySelectorAll', {nodeId:root.nodeId, selector:'.claim-node'}); |
| + const box = async nodeId => { |
| + const {model} = await call('DOM.getBoxModel', {nodeId}); |
| + const q = model.border; |
| + return {x:(q[0]+q[2]+q[4]+q[6])/4, y:(q[1]+q[3]+q[5]+q[7])/4, |
| + width:Math.max(q[0],q[2],q[4],q[6])-Math.min(q[0],q[2],q[4],q[6]), |
| + height:Math.max(q[1],q[3],q[5],q[7])-Math.min(q[1],q[3],q[5],q[7])}; |
| + }; |
| + const result = []; |
| + for (const nodeId of nodeIds) { |
| + const {node} = await call('DOM.describeNode', {nodeId, depth:1}); |
| + const {nodeId:tick} = await call('DOM.querySelector', {nodeId, selector:'svg'}); |
| + const pseudo = type => node.pseudoElements.find(p => p.pseudoType === type).nodeId; |
| + result.push({ring:await box(nodeId), arc:await box(pseudo('before')), dot:await box(pseudo('after')), tick:await box(tick)}); |
| + } |
| + return result; |
| +} |
| + |
| +const motionState = `(() => { |
| + const current = document.querySelectorAll('.claim-steps [aria-current="step"]'); |
| + const node = current[0]?.querySelector('.claim-node'); |
| + const before = getComputedStyle(node, '::before'); |
| + const after = getComputedStyle(node, '::after'); |
| + const path = getComputedStyle(document.querySelector('.claim-track')); |
| + return { |
| + time:performance.now(), stage:document.getElementById('claim-progress').dataset.stage, |
| + current:[...current].map(li => li.dataset.step), |
| + spin:before.animationName, spinState:before.animationPlayState, transform:before.transform, |
| + arcWidth:before.width, arcHeight:before.height, origin:before.transformOrigin, |
| + arcColor:before.borderTopColor, ringColor:getComputedStyle(node).borderTopColor, |
| + dot:after.animationName, dotState:after.animationPlayState, duration:after.animationDuration, |
| + opacity:Number(after.opacity), dotTransform:after.transform, |
| + path:path.animationName, pathState:path.animationPlayState, position:path.backgroundPositionX, |
| + running:document.getAnimations().filter(a => a.playState === 'running').map(a => a.animationName) |
| + }; |
| +})()`; |
| + |
| +export async function checkClaimMotion(call, evaluate, until, screenshots, url) { |
| + // Change the fixture's operation, then let the real status endpoint and page |
| + // script advance the UI. Never manufacture the state attributes in the test. |
| + const phase = async value => { |
| + const response = await fetch(new URL('/__test_claim_phase?phase='+value, url), {method:'POST'}); |
| + assert.equal(response.status, 204); |
| + }; |
| + for (const width of [390,1280]) for (const theme of ['light','dark']) for (const motion of ['no-preference','reduce']) { |
| + await call('Page.navigate', {url:'about:blank'}); |
| + await phase('future-phase'); |
| + await call('Emulation.setDeviceMetricsOverride', {width,height:900,deviceScaleFactor:1,mobile:false}); |
| + await call('Emulation.setEmulatedMedia', {features:[ |
| + {name:'prefers-color-scheme',value:theme}, {name:'prefers-reduced-motion',value:motion} |
| + ]}); |
| + await call('Page.navigate', {url}); |
| + await until('document.readyState === "complete" && document.getElementById("claim-progress")?.dataset.stage === "0"'); |
| + assert.equal(await evaluate('document.querySelectorAll(".claim-steps [aria-current]").length'), 0); |
| + let baseline; |
| + for (const [stage, serverPhase, label] of [[1,'copying','copying'],[2,'verifying','starting']]) { |
| + await phase(serverPhase); |
| + await until(`document.getElementById('claim-progress').dataset.stage === '${stage}'`); |
| + const name = `live-${label}-${motion}-${theme}-${width}`; |
| + const sequence = width === 1280 && theme === 'dark'; |
| + const count = sequence ? (motion === 'reduce' ? 4 : 8) : 3; |
| + const duration = sequence ? 2000 : 400; |
| + const samples = []; |
| + const start = performance.now(); |
| + for (let frame = 0; frame < count; frame++) { |
| + await wait(Math.max(0, start + frame*duration/(count-1) - performance.now())); |
| + const state = await evaluate(motionState); |
| + const boxes = await indicatorBoxes(call); |
| + baseline ??= boxes; |
| + assert.equal(state.stage, String(stage), name); |
| + assert.deepEqual(state.current, [String(stage)], name); |
| + assert.equal(state.dot, 'claim-dot-breathe', name); |
| + assert.equal(state.dotState, 'running', name); |
| + assert(state.running.includes('claim-dot-breathe'), name); |
| + assert.equal(state.dotTransform, 'none', name+' dot must not travel'); |
| + assert.equal(state.duration, motion === 'reduce' ? '2s' : '1.2s', name); |
| + assert.equal(state.arcWidth, '26px', name); |
| + assert.equal(state.arcHeight, '26px', name); |
| + assert.equal(state.origin, '13px 13px', name); |
| + if (motion === 'reduce') { |
| + assert.equal(state.spin, 'none', name); |
| + assert.equal(state.transform, 'none', name); |
| + assert.equal(state.path, 'none', name); |
| + assert.deepEqual(state.running, ['claim-dot-breathe'], name+' only opacity may animate'); |
| + } else { |
| + assert.equal(state.spin, 'claim-spin', name); |
| + assert.equal(state.spinState, 'running', name); |
| + assert.equal(state.path, 'claim-flow', name); |
| + assert.equal(state.pathState, 'running', name); |
| + assert(state.running.includes('claim-spin') && state.running.includes('claim-flow'), name); |
| + assert.notEqual(state.arcColor, state.ringColor, name+' arc disappears into ring'); |
| + } |
| + boxes.forEach((parts, i) => { |
| + for (const part of ['arc','dot','tick']) { |
| + near(parts[part].x, parts.ring.x, name+' '+part+' horizontal centre'); |
| + near(parts[part].y, parts.ring.y, name+' '+part+' vertical centre'); |
| + } |
| + for (const [part, size] of [['ring',26],['dot',8],['tick',16]]) { |
| + near(parts[part].width, size, name+' '+part+' width'); |
| + near(parts[part].height, size, name+' '+part+' height'); |
| + for (const key of ['x','y','width','height']) near(parts[part][key], baseline[i][part][key], name+' '+part+' moved across frames/states'); |
| + } |
| + }); |
| + samples.push({...state, boxes}); |
| + assert.equal(await evaluate('document.documentElement.scrollWidth <= innerWidth'), true, name+' overflow'); |
| + assert.deepEqual(await evaluate('window.claimCSPViolations'), [], name+' CSP'); |
| + if (screenshots && (sequence || frame === 0)) { |
| + const shot = await call('Page.captureScreenshot', {format:'png',captureBeyondViewport:true}); |
| + const suffix = sequence ? '-frame-'+String(frame+1).padStart(2,'0') : ''; |
| + await writeFile(`${screenshots}/${name}${suffix}.png`, Buffer.from(shot.data,'base64')); |
| + } |
| + } |
| + assert(Math.max(...samples.map(s => s.opacity))-Math.min(...samples.map(s => s.opacity)) > .05, name+' dot opacity is static'); |
| + if (motion === 'no-preference') { |
| + assert(new Set(samples.map(s => s.transform)).size > 1, name+' arc is static'); |
| + assert(new Set(samples.map(s => s.position)).size > 1, name+' path is static'); |
| + const frames = await evaluate(`document.querySelector('.claim-track').getAnimations()[0].effect.getKeyframes().map(f => [f.backgroundPositionX, f.backgroundPositionY])`); |
| + assert.deepEqual(frames, [['0%','0%'], ['12px','0px']], name+' dashes must travel right toward server'); |
| + } |
| + if (screenshots) await writeFile(`${screenshots}/${name}.json`, JSON.stringify(samples,null,2)+'\n'); |
| + } |
| + await phase('aborting'); |
| + await until('document.getElementById("claim-progress").dataset.stage === "0" && !!document.querySelector(".is-failed")'); |
| + assert.equal(await evaluate('document.querySelectorAll(".claim-steps [aria-current]").length'), 0); |
| + assert.equal(await evaluate('document.getAnimations().length'), 0, 'failure still animates'); |
| + assert.deepEqual(await evaluate('window.claimCSPViolations'), []); |
| + } |
| +} |