fix(skin): verify real launcher dedup and keep split recovery tappable at 320px

- Fall back an overlapping docked recovery toolbar to the visible capsule so
  split built-in/library buttons never cover each other on narrow screens.
- Add browser fixtures mounting real HostChrome + real PluginPanel for group,
  split and legacy capsule modes, including a genuine 320px iframe viewport.
- Assert the real launcher is suppressed by toolbar slots and never duplicated
  after a bad-anchor fallback, with both split toolbars observable and clickable.
This commit is contained in:
OddTurtleHead committed 2026-11-26 23:06:43 +08:00
1 parent cfbf488f75
commit e5c891fc94
6 files changed
+543 -1

No files matched your search

+26 -1
View File
@@ -161,7 +161,7 @@ import {
type FloatingAvoidance,
type FloatingPosition,
} from "../services/host-floating-placement.js";
import { shouldShowRecovery } from "../services/host-chrome-visibility.js";
import { shouldShowRecovery, type HostPartRect } from "../services/host-chrome-visibility.js";
import { thirdPartyAllowed } from "../services/instance-authorization.js";
import {
RECOVERY_CONTROL_DEFAULTS,
@@ -474,6 +474,30 @@ function syncToolbarPopovers() {
);
}
/** A toolbar that is currently displayed (top layer or display fallback). */
function isToolbarShown(control: HTMLElement | null): boolean {
if (!control) return false;
if (control.matches?.(":popover-open")) return true;
const rect = control.getBoundingClientRect();
return getComputedStyle(control).display !== "none" && rect.width > 0 && rect.height > 0;
}
function rectOf(control: HTMLElement): HostPartRect {
const rect = control.getBoundingClientRect();
return {
left: rect.left, top: rect.top, width: rect.width, height: rect.height,
right: rect.right, bottom: rect.bottom,
};
}
/** Other docked recovery toolbars this entry must not cover on a narrow screen. */
function otherToolbarRects(control: HTMLElement): HostPartRect[] {
return [groupToolbarElement.value, builtInToolbarElement.value, libraryToolbarElement.value]
.filter((element): element is HTMLElement => Boolean(element)
&& element !== control && isToolbarShown(element))
.map(rectOf);
}
function bindToolbarEntry(
control: HTMLElement | null,
config: SkinChromeSlot | undefined,
@@ -487,6 +511,7 @@ function bindToolbarEntry(
skinId: hostChromeActiveSkinId.value,
align: config.align,
presentation: "toolbar",
otherControls: () => otherToolbarRects(control),
// A floating toolbar is a closed popover (display:none). Show it for the
// synchronous measurement/hit test and hide it again unless it docked.
prepare: () => syncRecoveryPopover(control, true),
@@ -161,6 +161,28 @@ test("a slotted capsule that would cover a protected control falls back", () =>
assert.deepEqual(evaluateSlottedControl({ ...baseEvaluation, coversProtected: false }), { ok: true });
});
test("a toolbar that would cover another docked host control falls back", () => {
assert.deepEqual(
evaluateSlottedControl({
...baseEvaluation,
otherControls: [rect(160, 105, 120, 30)],
}),
{ ok: false, reason: "covers-host-control" },
);
// Edge contact is not a collision; both toolbars can still dock side by side.
assert.deepEqual(
evaluateSlottedControl({
...baseEvaluation,
otherControls: [rect(60, 105, 120, 30)],
}),
{ ok: true },
);
assert.deepEqual(
evaluateSlottedControl({ ...baseEvaluation, otherControls: [] }),
{ ok: true },
);
});
test("rect overlap ignores edge contact and sub-pixel slivers", () => {
assert.equal(rectsOverlap(rect(0, 0, 100, 40), rect(50, 10, 100, 40)), true);
assert.equal(rectsOverlap(rect(0, 0, 100, 40), rect(100, 0, 50, 40)), false);
+13
View File
@@ -83,6 +83,7 @@ export type SlotFailureReason =
| "control-too-small"
| "control-offscreen"
| "covers-protected"
| "covers-host-control"
| "hit-test";
export interface SlotAnchorSnapshot {
@@ -109,6 +110,8 @@ export interface SlotEvaluationInput {
* capsule is top layer, so it would block those controls for the pointer.
*/
coversProtected?: boolean;
/** Footprints of other docked host controls this one must not cover. */
otherControls?: readonly HostPartRect[];
}
export type SlotEvaluation = { ok: true } | { ok: false; reason: SlotFailureReason };
@@ -163,6 +166,13 @@ export function evaluateSlottedControl(input: SlotEvaluationInput): SlotEvaluati
return { ok: false, reason: "control-too-small" };
}
if (!fullyInsideViewport(controlRect, viewport)) return { ok: false, reason: "control-offscreen" };
// Two independently anchored recovery toolbars can converge on the same
// narrow anchor (for example at 320px). Covering a sibling host control
// would make one of the buttons unreachable, so that action returns to the
// visible floating capsule instead of pretending to be docked.
if (input.otherControls?.some((rect) => rectsOverlap(controlRect, rect))) {
return { ok: false, reason: "covers-host-control" };
}
if (input.coversProtected) return { ok: false, reason: "covers-protected" };
if (!hitTestOk) return { ok: false, reason: "hit-test" };
return { ok: true };
@@ -332,6 +342,8 @@ export interface HostSlotBindingOptions {
/** Called after each evaluation with the resulting docked state. */
settle?: (slotted: boolean) => void;
resolveAnchor?: (anchor: string | readonly string[]) => HTMLElement | null;
/** Live footprints of other docked host controls; overlaps force a fallback. */
otherControls?: () => readonly HostPartRect[];
onModeChange?: (change: HostSlotModeChange) => void;
}
@@ -512,6 +524,7 @@ export function bindHostSlot(options: HostSlotBindingOptions): HostSlotBinding {
viewport,
minHitTarget: tokens.hitTarget,
coversProtected,
otherControls: options.otherControls?.(),
hitTestOk: placement
? hitTestAt(placement.left, placement.top, { width: controlBox.width, height: controlBox.height })
: false,
@@ -0,0 +1,290 @@
<!doctype html>
<html lang="en" data-ws-route="webclient" data-ws-page="home" data-ws-host-skin="community.plugin-panel-fixture">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width,initial-scale=1" />
<title>Host recovery toolbar + real PluginPanel fixture</title>
<script>
// Authorize third-party skins before instance-authorization.ts is evaluated.
try { localStorage.setItem("webspeak:instance-authorization:v1", JSON.stringify({ schemaVersion: 1, allowed: true })); } catch {}
</script>
<style>
html, body { margin: 0; width: 100%; height: 100%; font: 12px/1.5 system-ui, sans-serif; }
.ws-skin-root { position: relative; width: 100vw; height: 100vh; }
.topbar { position: absolute; left: 0; top: 0; right: 0; height: 56px; background: #f4f7fb; }
.anchor { position: absolute; top: 4px; width: min(420px, calc(100vw - 40px)); height: 48px; }
#home-anchor { left: 20px; }
#voice-anchor { left: 20px; display: none; }
#dock { position: absolute; left: 12px; bottom: 12px; display: flex; gap: 8px; }
</style>
</head>
<body>
<!-- Unlike host-recovery-toolbar.html, there is deliberately NO fake
`data-ws-part="host.plugins.launcher"` button here. The launcher is the
real one rendered by PluginPanel.vue, so dedup is observed at the actual
product v-if path and cannot be faked by hiding a static placeholder. -->
<div class="ws-skin-root" data-ws-skin="community.plugin-panel-fixture" data-ws-page="home" data-ws-part="app">
<div class="topbar" data-ws-part="home.header">
<span id="home-anchor" class="anchor" data-ws-part="skin.home.topbar.part-host-actions"
style="--skin-recovery-toolbar-background:#102030;--skin-recovery-toolbar-foreground:#ffffff;--skin-recovery-toolbar-border:#47dcc4;--skin-recovery-toolbar-radius:8px;--skin-recovery-toolbar-font-size:14px;--skin-recovery-toolbar-padding:6px 14px;--skin-recovery-toolbar-height:36px;--skin-recovery-toolbar-shadow:none"></span>
</div>
<div class="topbar" data-ws-part="voice.header">
<span id="voice-anchor" class="anchor" data-ws-part="skin.voice.topbar.part-host-actions"
style="--skin-recovery-toolbar-background:#102030;--skin-recovery-toolbar-foreground:#ffffff;--skin-recovery-toolbar-border:#47dcc4;--skin-recovery-toolbar-radius:8px;--skin-recovery-toolbar-font-size:14px;--skin-recovery-toolbar-padding:6px 14px;--skin-recovery-toolbar-height:36px;--skin-recovery-toolbar-shadow:none"></span>
</div>
<div id="dock" data-ws-part="voice.audio-dock">
<button type="button" data-ws-part="voice.audio-dock.microphone">Mic</button>
</div>
</div>
<div id="app"></div>
<div id="plugin-app"></div>
<pre id="result" style="position:relative;z-index:5;background:#fff">pending</pre>
<script type="module">
import { createApp, h, nextTick, ref } from "vue";
import HostChrome from "/src/components/HostChrome.vue";
import PluginPanel from "/src/components/PluginPanel.vue";
import {
hostBuiltInSkinRequests,
isInlineLibraryEntryVisible,
pluginLibraryRequests,
setHostChromeActiveSkin,
setSkinHostChromeParts,
} from "/src/services/host-chrome.ts";
import { parseSkinChromeDocument } from "../../../src/shared/skin-chrome.ts";
import { hostOwnedLayers } from "/src/services/host-owned-layer.ts";
import { resolveSkinAnchor } from "/src/services/host-slot-placement.ts";
const output = document.getElementById("result");
const sleep = (ms) => new Promise((resolve) => setTimeout(resolve, ms));
const round = (value) => Math.round(value * 10) / 10;
const rectOf = (element) => {
const rect = element.getBoundingClientRect();
return { left: round(rect.left), top: round(rect.top), width: round(rect.width), height: round(rect.height), right: round(rect.right), bottom: round(rect.bottom) };
};
const withinViewport = (rect) => rect.left >= -0.5 && rect.top >= -0.5
&& rect.right <= innerWidth + 0.5 && rect.bottom <= innerHeight + 0.5;
const withinRect = (inner, outer) => inner.left >= outer.left - 0.5 && inner.right <= outer.right + 0.5
&& inner.top >= outer.top - 0.5 && inner.bottom <= outer.bottom + 0.5;
const rectsOverlap = (a, b) => Math.min(a.right, b.right) - Math.max(a.left, b.left) > 1
&& Math.min(a.bottom, b.bottom) - Math.max(a.top, b.top) > 1;
const isOpen = (element) => Boolean(element?.matches?.(":popover-open"))
|| (element ? getComputedStyle(element).display !== "none" && element.getBoundingClientRect().width > 0 : false);
const isVisible = (element) => {
if (!element) return false;
const style = getComputedStyle(element);
const rect = element.getBoundingClientRect();
return style.display !== "none" && style.visibility !== "hidden" && rect.width > 0 && rect.height > 0;
};
// The real PluginPanel calls createPluginAppClient().list() on mount. Keep it
// entirely local and deterministic: no production gateway, no external fetch.
const nativeFetch = window.fetch.bind(window);
window.fetch = (input, init) => {
const url = typeof input === "string" ? input : input?.url ?? "";
if (url.includes("/api/plugins")) {
return Promise.resolve(new Response(JSON.stringify({ plugins: [] }), {
status: 200, headers: { "content-type": "application/json" },
}));
}
return nativeFetch(input, init);
};
const mode = location.hash.slice(1) || "group";
const anchorList = ["skin.home.topbar.part-host-actions", "skin.voice.topbar.part-host-actions"];
const slots = mode === "split"
? {
"host.recovery.built-in": { mode: "toolbar", anchor: anchorList, align: "start" },
"host.recovery.library": { mode: "toolbar", anchor: anchorList, align: "end" },
}
: mode === "capsule"
? { "host.recovery": { anchor: anchorList, align: "end" } }
: { "host.recovery": { mode: "toolbar", anchor: anchorList, align: "end" } };
try {
setSkinHostChromeParts(parseSkinChromeDocument(JSON.stringify({ schemaVersion: 1, slots })));
setHostChromeActiveSkin("community.plugin-panel-fixture");
const hostLanguage = ref("de");
const pluginLanguage = ref("de");
createApp({
render: () => h(HostChrome, {
language: hostLanguage.value,
connected: true,
pluginLibraryAvailable: true,
}),
}).mount("#app");
createApp({
render: () => h(PluginPanel, {
sessionToken: "a".repeat(43),
gatewayUrl: location.origin,
connected: true,
language: pluginLanguage.value,
toolbarTarget: null,
presentation: "dialog",
}),
}).mount("#plugin-app");
const layer = hostOwnedLayers().find((entry) => entry.name === "recovery");
if (!layer) throw new Error("recovery layer was not created");
const toolbars = () => [...layer.container.querySelectorAll("[data-ws-host-recovery-toolbar]")];
const capsule = () => layer.container.querySelector("[data-ws-host-recovery]");
const launcher = () => document.querySelector('[data-ws-part="host.plugins.launcher"]');
const actions = (element) => [...(element?.querySelectorAll("[data-ws-recovery-action]") ?? [])]
.map((button) => button.getAttribute("data-ws-recovery-action"));
const openToolbars = () => toolbars().filter(isOpen);
// Observe only buttons that are actually displayed. A floating toolbar is a
// closed popover (display:none), so its buttons must not be reported as if
// the user could see or click them; the fallback capsule owns them instead.
const visibleButtons = () => [
...openToolbars().flatMap((toolbar) => [...toolbar.querySelectorAll("button")]),
...(isOpen(capsule()) ? [...(capsule()?.querySelectorAll("button") ?? [])] : []),
];
await nextTick();
await sleep(400);
const snapshot = () => {
const bars = toolbars();
const cap = capsule();
const lch = launcher();
const capActions = isOpen(cap) ? actions(cap) : [];
const shown = visibleButtons();
const barRects = openToolbars().map(rectOf);
const buttonRects = shown.map(rectOf);
return {
viewport: innerWidth,
toolbarCount: bars.length,
toolbars: bars.map((bar) => ({
open: isOpen(bar),
visible: isVisible(bar),
rect: rectOf(bar),
inViewport: withinViewport(rectOf(bar)),
labels: [...bar.querySelectorAll("button")].map((button) => button.textContent?.trim()),
actions: actions(bar),
})),
toolbarOverlap: barRects.length === 2 ? rectsOverlap(barRects[0], barRects[1]) : false,
buttonOverlap: buttonRects.length === 2 ? rectsOverlap(buttonRects[0], buttonRects[1]) : false,
visibleActions: shown.map((button) => ({
action: button.getAttribute("data-ws-recovery-action"),
text: button.textContent?.trim(),
rect: rectOf(button),
height: rectOf(button).height,
visible: isVisible(button),
inViewport: withinViewport(rectOf(button)),
})),
capsuleOpen: isOpen(cap),
capsuleVisible: isVisible(cap),
capsuleActions: capActions,
launcherPresent: Boolean(lch),
launcherVisible: isVisible(lch),
launcherCount: document.querySelectorAll('[data-ws-part="host.plugins.launcher"]').length,
inlineFlag: isInlineLibraryEntryVisible(),
visibleLibraryEntries: shown.filter((button) => button.getAttribute("data-ws-recovery-action") === "library").length
+ (isVisible(lch) ? 1 : 0),
};
};
const initial = snapshot();
// Both split toolbars must be individually clickable, not just observable.
const builtInBefore = hostBuiltInSkinRequests.value;
const libraryBefore = pluginLibraryRequests.value;
const builtInButton = visibleButtons().find((button) => button.getAttribute("data-ws-recovery-action") === "built-in");
const libraryButton = visibleButtons().find((button) => button.getAttribute("data-ws-recovery-action") === "library");
builtInButton?.click();
libraryButton?.click();
const clicks = {
builtIn: hostBuiltInSkinRequests.value === builtInBefore + 1,
library: pluginLibraryRequests.value === libraryBefore + 1,
};
// Long labels in de/ru/ja have to remain readable, inside the viewport and
// above the host hit-target floor, without the two toolbars covering each
// other. This runs at both 1280px and 320px real viewports.
const languages = {};
for (const lang of ["de", "ru", "ja"]) {
hostLanguage.value = lang;
pluginLanguage.value = lang;
await nextTick();
await sleep(900);
languages[lang] = visibleButtons().map((button) => ({
action: button.getAttribute("data-ws-recovery-action"),
text: button.textContent?.trim(),
rect: rectOf(button),
height: rectOf(button).height,
visible: isVisible(button),
inViewport: withinViewport(rectOf(button)),
}));
}
hostLanguage.value = "de";
pluginLanguage.value = "de";
await nextTick();
await sleep(900);
// Page switch: the home anchor disappears and the voice anchor appears.
const root = document.querySelector(".ws-skin-root");
document.getElementById("home-anchor").style.display = "none";
document.getElementById("voice-anchor").style.display = "block";
root.dataset.wsPage = "voice";
await sleep(350);
const voiceAnchorRect = rectOf(document.getElementById("voice-anchor"));
const afterSwitch = {
...snapshot(),
insideVoiceAnchor: openToolbars().every((bar) => withinRect(rectOf(bar), voiceAnchorRect)),
resolvedVoice: resolveSkinAnchor(anchorList, document, "community.plugin-panel-fixture")?.id,
};
// A bad anchor must return a visible floating capsule, still with exactly
// one library entry (real PluginPanel launcher stays suppressed for toolbar
// modes even while the fallback capsule shows the library action).
document.getElementById("voice-anchor").style.display = "none";
await sleep(1100);
const fallback = snapshot();
// Restoring the anchor re-docks after the anti-flap streak.
document.getElementById("voice-anchor").style.display = "block";
await sleep(2300);
const redocked = snapshot();
// A narrow split layout must settle on one docked toolbar instead of
// swapping the two actions between the anchor and the capsule every tick.
const redockSamples = [];
for (let sample = 0; sample < 4; sample += 1) {
redockSamples.push(openToolbars().map((bar) => actions(bar).join("+")).join("|"));
await sleep(250);
}
redocked.stable = redockSamples.every((value) => value === redockSamples[0]);
redocked.samples = redockSamples;
// The chord summons the complete capsule and focuses its first button; Esc
// returns to the docked toolbar while the anchor is still valid.
window.dispatchEvent(new KeyboardEvent("keydown", {
key: "r", ctrlKey: true, altKey: true, shiftKey: true, bubbles: true, cancelable: true,
}));
await nextTick();
await sleep(120);
const shortcut = {
...snapshot(),
focusedAction: layer.shadow.activeElement?.getAttribute?.("data-ws-recovery-action") ?? null,
};
capsule()?.dispatchEvent(new KeyboardEvent("keydown", { key: "Escape", bubbles: true }));
await nextTick();
await sleep(220);
const afterEscape = snapshot();
output.textContent = JSON.stringify({
mode,
initial,
clicks,
languages,
afterSwitch,
fallback,
redocked,
shortcut,
afterEscape,
});
} catch (error) {
output.textContent = JSON.stringify({ mode, error: String(error?.stack ?? error) });
}
</script>
</body>
</html>
+35
View File
@@ -0,0 +1,35 @@
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8" />
<title>Real viewport wrapper for host recovery toolbar fixtures</title>
<style>
html, body { margin: 0; background: #fff; }
/* Headless Chrome clamps --window-size=320 to a 500px viewport. A real
320px iframe is a genuine CSS viewport: window.innerWidth, 100vw,
flex-wrap and the host slot's viewport checks all see 320px. */
iframe { display: block; width: 320px; height: 640px; border: 0; }
</style>
</head>
<body>
<iframe id="frame" title="320px viewport fixture"></iframe>
<pre id="result" style="position:relative;z-index:5;background:#fff">pending</pre>
<script>
const mode = location.hash.slice(1) || "group";
const frame = document.getElementById("frame");
const output = document.getElementById("result");
frame.src = `/test/fixtures/host-recovery-toolbar-plugin-panel.html#${encodeURIComponent(mode)}`;
const poll = () => {
try {
const text = frame.contentDocument?.getElementById("result")?.textContent;
if (text && text !== "pending") {
output.textContent = text;
return;
}
} catch { /* same-origin fixture still loading */ }
setTimeout(poll, 100);
};
setTimeout(poll, 100);
</script>
</body>
</html>
+157
View File
@@ -114,6 +114,9 @@ test("host chrome renders recovery and authorization in a closed-shadow top laye
assert.match(slotPlacement, /querySelectorAll\("\.ws-skin-root"\)/);
assert.match(slotPlacement, /isHostPartReachable\(/);
assert.match(slotPlacement, /evaluateSlottedControl/);
// Two split recovery toolbars must not cover each other on a narrow screen.
assert.match(slotPlacement, /covers-host-control/);
assert.match(hostChrome, /otherControls:/);
assert.match(hostChromeService, /export function activeHostSlot/);
assert.match(hostChromeService, /HOST_SLOTTABLE_PART_IDS\.has\(part\)/);
assert.match(hostChromeService, /isThirdPartySkinActive\(\)/);
@@ -621,6 +624,160 @@ test("toolbar-mode recovery docks plain host buttons, de-duplicates the library
}
});
test("real PluginPanel launcher is de-duplicated by group and split toolbars on desktop and a real 320px viewport", { skip: !CHROME && "google-chrome is not installed" }, async (t) => {
const server = await createServer({
root: webRoot,
configFile: path.join(webRoot, "vite.config.ts"),
logLevel: "silent",
server: { host: "127.0.0.1", port: 0, strictPort: false, hmr: false, ws: false },
});
t.after(() => server.close());
await server.listen();
const address = server.httpServer?.address();
const port = address && typeof address === "object" ? address.port : 0;
assert.ok(port, "Vite did not expose a listening port");
const base = `http://127.0.0.1:${port}/test/fixtures`;
const run = async (mode, real320 = false) => {
// Headless Chrome clamps --window-size=320 to a 500px viewport. The
// wrapper opens the fixture inside a genuine 320px iframe so window.innerWidth,
// 100vw, flex-wrap and the slot viewport checks all see 320px.
const url = real320
? `${base}/host-recovery-toolbar-viewport.html#${mode}`
: `${base}/host-recovery-toolbar-plugin-panel.html#${mode}`;
const dom = await dumpDom(url, ["--virtual-time-budget=30000", "--window-size=1280,800"]);
const match = dom.match(/<pre id="result"[^>]*>([\s\S]*?)<\/pre>/);
assert.ok(match, `${mode} @ ${real320 ? 320 : 1280}: the fixture did not emit a result block`);
return JSON.parse(match[1].replace(/&quot;/g, '"').replace(/&amp;/g, "&"));
};
const overlaps = (a, b) => Math.min(a.right, b.right) - Math.max(a.left, b.left) > 1
&& Math.min(a.bottom, b.bottom) - Math.max(a.top, b.top) > 1;
const observableButtons = (snapshot, context, count = 2) => {
const entries = snapshot.visibleActions;
assert.equal(entries.length, count, `${context}: expected ${count} visible buttons, got ${JSON.stringify(entries)}`);
for (let i = 0; i < entries.length; i += 1) {
for (let j = i + 1; j < entries.length; j += 1) {
assert.equal(overlaps(entries[i].rect, entries[j].rect), false, `${context}: buttons overlap each other`);
}
}
for (const entry of entries) {
assert.ok(entry.text && entry.text.length > 0, `${context}: button lost its label`);
assert.equal(entry.visible, true, `${context}: button is not visible`);
assert.equal(entry.inViewport, true, `${context}: button escaped the viewport: ${JSON.stringify(entry.rect)}`);
assert.ok(entry.height >= 28, `${context}: button fell below the host hit target (${entry.height})`);
}
};
const group = await run("group");
assert.equal(group.error, undefined, group.error);
assert.equal(group.initial.toolbarCount, 1);
assert.equal(group.initial.toolbars[0].open, true, "the group toolbar did not dock");
assert.deepEqual(group.initial.toolbars[0].labels, ["Integrierten Skin verwenden", "Anwendungsbibliothek"]);
assert.equal(group.initial.launcherPresent, false, "the real PluginPanel launcher was not suppressed");
assert.equal(group.initial.launcherCount, 0);
assert.equal(group.initial.inlineFlag, true);
assert.equal(group.initial.capsuleOpen, false);
assert.equal(group.initial.visibleLibraryEntries, 1);
observableButtons(group.initial, "group desktop");
assert.equal(group.clicks.builtIn, true);
assert.equal(group.clicks.library, true);
assert.equal(group.afterSwitch.toolbars[0].open, true, "the toolbar did not survive the page switch");
assert.equal(group.afterSwitch.insideVoiceAnchor, true);
assert.equal(group.afterSwitch.resolvedVoice, "voice-anchor");
assert.equal(group.fallback.toolbars[0].open, false, "the toolbar stayed docked with a broken anchor");
assert.equal(group.fallback.capsuleVisible, true);
assert.deepEqual(group.fallback.capsuleActions, ["built-in", "library"]);
assert.equal(group.fallback.launcherPresent, false, "the fallback added a second real library entry");
assert.equal(group.fallback.visibleLibraryEntries, 1);
assert.equal(group.redocked.toolbars[0].open, true);
assert.equal(group.shortcut.capsuleOpen, true);
assert.equal(group.shortcut.toolbars[0].open, false);
assert.equal(group.shortcut.focusedAction, "built-in");
assert.equal(group.afterEscape.capsuleOpen, false);
assert.equal(group.afterEscape.toolbars[0].open, true);
assert.equal(group.redocked.stable, true, "the docked toolbar flapped between the anchor and the capsule");
const split = await run("split");
assert.equal(split.error, undefined, split.error);
assert.equal(split.initial.toolbarCount, 2, "split mode must render two separately observable toolbars");
assert.deepEqual(split.initial.toolbars.map((bar) => bar.labels), [["Integrierten Skin verwenden"], ["Anwendungsbibliothek"]]);
assert.equal(split.initial.toolbars[0].open, true);
assert.equal(split.initial.toolbars[1].open, true);
assert.equal(split.initial.toolbarOverlap, false);
assert.equal(split.initial.launcherPresent, false, "the real launcher survived the split toolbar");
assert.equal(split.initial.visibleLibraryEntries, 1);
observableButtons(split.initial, "split desktop");
assert.equal(split.clicks.builtIn, true, "the built-in split toolbar button was not clickable");
assert.equal(split.clicks.library, true, "the library split toolbar button was not clickable");
assert.equal(split.afterSwitch.toolbars[0].open, true);
assert.equal(split.afterSwitch.toolbars[1].open, true);
assert.equal(split.afterSwitch.insideVoiceAnchor, true);
for (const lang of ["de", "ru", "ja"]) {
observableButtons({ visibleActions: split.languages[lang] }, `${lang} split desktop`);
}
assert.equal(split.fallback.toolbars.every((bar) => !bar.open), true);
assert.equal(split.fallback.capsuleVisible, true);
assert.deepEqual(split.fallback.capsuleActions, ["built-in", "library"]);
assert.equal(split.fallback.launcherPresent, false, "the bad-anchor fallback restored a second library entry");
assert.equal(split.fallback.visibleLibraryEntries, 1);
assert.equal(split.redocked.toolbars.filter((bar) => bar.open).length, 2);
assert.equal(split.redocked.stable, true, "split toolbars flapped between the anchor and the capsule");
assert.equal(split.shortcut.capsuleOpen, true);
assert.equal(split.shortcut.toolbars.every((bar) => !bar.open), true);
assert.equal(split.shortcut.focusedAction, "built-in");
assert.equal(split.afterEscape.capsuleOpen, false);
assert.equal(split.afterEscape.toolbars.filter((bar) => bar.open).length, 2);
// Legacy capsule mode is the control: the real launcher must be able to
// render at all, otherwise "suppressed" above would be a false positive.
const capsule = await run("capsule");
assert.equal(capsule.error, undefined, capsule.error);
assert.equal(capsule.initial.toolbarCount, 0);
assert.equal(capsule.initial.capsuleOpen, true);
assert.equal(capsule.initial.launcherPresent, true, "the real PluginPanel launcher never rendered");
assert.equal(capsule.initial.launcherVisible, true);
assert.equal(capsule.initial.launcherCount, 1);
assert.equal(capsule.initial.inlineFlag, false);
// Real 320px viewport: group labels wrap and stay tappable; split falls back
// to a visible capsule for the action that would cover its sibling toolbar.
const narrowGroup = await run("group", true);
assert.equal(narrowGroup.error, undefined, narrowGroup.error);
assert.equal(narrowGroup.initial.viewport, 320, "the iframe did not provide a real 320px viewport");
assert.equal(narrowGroup.initial.toolbars[0].open, true);
assert.equal(narrowGroup.initial.toolbarOverlap, false);
assert.equal(narrowGroup.initial.launcherPresent, false);
assert.equal(narrowGroup.initial.visibleLibraryEntries, 1);
observableButtons(narrowGroup.initial, "group 320px");
assert.equal(narrowGroup.clicks.builtIn, true);
assert.equal(narrowGroup.clicks.library, true);
for (const lang of ["de", "ru", "ja"]) {
observableButtons({ visibleActions: narrowGroup.languages[lang] }, `${lang} group 320px`);
}
assert.equal(narrowGroup.redocked.stable, true);
const narrowSplit = await run("split", true);
assert.equal(narrowSplit.error, undefined, narrowSplit.error);
assert.equal(narrowSplit.initial.viewport, 320, "the iframe did not provide a real 320px viewport");
assert.equal(narrowSplit.initial.toolbarCount, 2);
assert.equal(narrowSplit.initial.toolbarOverlap, false, "docked split toolbars still cover each other at 320px");
assert.equal(narrowSplit.initial.launcherPresent, false, "the real launcher reappeared at 320px");
assert.equal(narrowSplit.initial.visibleLibraryEntries, 1, "the narrow fallback added a duplicate library entry");
observableButtons(narrowSplit.initial, "split 320px");
assert.equal(narrowSplit.clicks.builtIn, true, "the docked split button was not clickable at 320px");
assert.equal(narrowSplit.clicks.library, true, "the fallback capsule button was not clickable at 320px");
for (const lang of ["de", "ru", "ja"]) {
observableButtons({ visibleActions: narrowSplit.languages[lang] }, `${lang} split 320px`);
}
assert.equal(narrowSplit.fallback.capsuleVisible, true);
assert.equal(narrowSplit.fallback.visibleLibraryEntries, 1);
assert.equal(narrowSplit.redocked.stable, true, "the narrow split fallback flapped between controls");
assert.equal(narrowSplit.shortcut.capsuleOpen, true);
assert.equal(narrowSplit.shortcut.toolbars.every((bar) => !bar.open), true);
assert.equal(narrowSplit.afterEscape.toolbars.filter((bar) => bar.open).length, 1);
assert.equal(narrowSplit.afterEscape.capsuleOpen, true, "the fallback entry vanished after Esc at 320px");
});
test("legacy slots without a mode still dock the capsule", { skip: !CHROME && "google-chrome is not installed" }, async (t) => {
const server = await createServer({
root: webRoot,