fix: correct recovery placement and quoted skin animations

This commit is contained in:
illusia committed 2026-11-22 17:16:36 +08:00
1 parent 9812a28e5f
commit ae6788a796
7 files changed
+102 -1

No files matched your search

+19 -1
View File
@@ -134,10 +134,28 @@ try {
movesWhileHeld: moves.length - heldFrom,
sinceFreezeMs: Math.round(performance.now() - pinnedAt),
});
// A different screen must not inherit the old screen's exhausted freeze
// escape or move history. Its microphone now occupies the parked spot.
const frozenPosition = binding.position;
document.getElementById("walls").remove();
hopper.setAttribute("data-ws-part", "voice.audio-dock.microphone");
chase(lib);
const coveredBeforeScreenChange = coveredByLib(hopper);
binding.screenChanged();
await sleep(200);
binding.revalidate();
results.push({
name: "screen-change-during-freeze",
frozenPosition,
position: binding.position,
coveredBeforeScreenChange,
microphoneCovered: coveredByLib(hopper),
sinceFreezeMs: Math.round(performance.now() - pinnedAt),
});
binding.dispose();
lib.remove();
hopper.remove();
document.getElementById("walls").remove();
accompaniment.style.display = "";
}
+16
View File
@@ -34,6 +34,8 @@ const CSS = `
background: var(--ws-control-background, #fff);
color: var(--ws-control-foreground, #31524f);
}
.cap[data-ws-float^="middle"] { bottom: auto; top: 50%; translate: 0 -50%; }
.cap[data-ws-float$="center"] { left: 50%; translate: -50% 0; }
.cap button { min-height: var(--ws-control-hit, 28px); padding: 0 8px; }
`;
try {
@@ -80,6 +82,20 @@ try {
const results = [];
results.push(snap("initial"));
// A floating fallback may have moved to a centred position. Its CSS
// translation must not offset the slot's fixed coordinates or hit test.
for (const position of ["middle-left", "middle-right", "top-center", "bottom-center"]) {
anchor.style.display = "none";
binding.revalidate();
control.dataset.wsFloat = position;
results.push({ ...snap(`fallback-${position}`), translated: getComputedStyle(control).translate !== "none" });
anchor.style.display = "";
binding.revalidate();
binding.revalidate();
results.push({ ...snap(`redocked-${position}`), translate: getComputedStyle(control).translate });
}
delete control.dataset.wsFloat;
anchor.style.display = "none";
binding.revalidate();
results.push(snap("anchor-hidden"));
+38
View File
@@ -275,6 +275,17 @@ test("a declared slot docks the capsule and falls back at runtime", { skip: !CHR
assert.equal(initial.color, "rgb(255, 255, 255)", "skin foreground token was not applied");
assert.ok(initial.buttonHeight >= 36, "the large size tier minimum was not enforced");
for (const position of ["middle-left", "middle-right", "top-center", "bottom-center"]) {
const fallback = byName[`fallback-${position}`];
assert.equal(fallback.mode, "floating", JSON.stringify(fallback));
assert.equal(fallback.translated, true, "floating CSS translation was not restored");
const docked = byName[`redocked-${position}`];
assert.equal(docked.mode, "slotted", JSON.stringify(docked));
assert.equal(docked.insideAnchor, true, JSON.stringify(docked));
assert.equal(docked.hitIsLayerHost, true, JSON.stringify(docked));
assert.equal(docked.translate, "none", JSON.stringify(docked));
}
assert.equal(byName["anchor-hidden"].mode, "floating");
assert.equal(byName["anchor-hidden"].reason, "anchor-missing");
assert.equal(byName["anchor-hidden"].inlineLeft, "");
@@ -417,6 +428,33 @@ test("floating host controls see through toasts and still step off a control whi
assert.notEqual(freeze.escapes[0].position, "bottom-right", JSON.stringify(freeze));
assert.ok(freeze.escapes[0].afterPinMs < 3000, JSON.stringify(freeze));
assert.equal(freeze.movesWhileHeld, 0, JSON.stringify(freeze));
const screen = byName["screen-change-during-freeze"];
assert.ok(screen.sinceFreezeMs < 10000, "the test must switch screens before the old freeze expires");
assert.equal(screen.coveredBeforeScreenChange, true, JSON.stringify(screen));
assert.notEqual(screen.position, screen.frozenPosition, JSON.stringify(screen));
assert.equal(screen.microphoneCovered, false, JSON.stringify(screen));
});
test("compiled quoted keyword animations still run in the browser", { skip: !CHROME && "google-chrome is not installed" }, async () => {
const raw = '@keyframes linear { from { opacity: .5; } to { opacity: 1; } } [data-ws-part="home.feature"] { animation: "linear" 10s ease-in-out infinite; }';
const compiled = compileSkinCss(raw, "community.animation-fixture", {}, 3).css;
const html = `<!doctype html><html><head><style id="css"></style></head><body>
<div class="ws-skin-root" data-ws-skin="community.animation-fixture"><div data-ws-part="home.feature">Feature</div></div>
<pre id="result"></pre><script>
const target = document.querySelector('[data-ws-part="home.feature"]');
const style = document.getElementById('css');
style.textContent = ${JSON.stringify(raw)};
const before = target.getAnimations().length;
style.textContent = ${JSON.stringify(compiled)};
document.getElementById('result').textContent = JSON.stringify({ before, after: target.getAnimations().length });
</script></body></html>`;
const dom = await dumpDom(`data:text/html;base64,${Buffer.from(html).toString("base64")}`);
const match = dom.match(/<pre id="result"[^>]*>([\s\S]*?)<\/pre>/);
assert.ok(match, "the animation fixture did not emit a result block");
const payload = JSON.parse(match[1]);
assert.equal(payload.before, 1, JSON.stringify(payload));
assert.equal(payload.after, 1, JSON.stringify(payload));
});
test("host control tokens follow late skin CSS, resolve modern colours and refuse skin fonts", { skip: !CHROME && "google-chrome is not installed" }, async (t) => {