mirror of
https://github.com/EchoSixHIYA/WebSpeak-client-for-TeamSpeak.git
synced 2026-12-03 20:12:52 +08:00
feat(skin): dock recovery as host-owned toolbar buttons
Add chrome.json slot mode "toolbar" with grouped and per-action recovery buttons, page-specific anchor candidates and sanitized toolbar style tokens. Keep the floating capsule as the bad-anchor fallback, hide the duplicate plugin launcher, and preserve legacy capsule slots. Document the full contract, add a minimal toolbar example package, and cover the new behavior in unit and browser tests.
This commit is contained in:
1 parent
9a12e2ee7b
commit
881354e283
33 files changed
+2016
-113
No files matched your search
@@ -197,7 +197,11 @@ test("chrome.json declares hidden parts and icon bitmaps, with path and size val
|
||||
});
|
||||
|
||||
test("chrome.json slots accept skin-owned anchors and reject trusted host UI", () => {
|
||||
assert.deepEqual([...HOST_SLOTTABLE_PART_IDS], ["host.recovery"]);
|
||||
assert.deepEqual([...HOST_SLOTTABLE_PART_IDS], [
|
||||
"host.recovery",
|
||||
"host.recovery.built-in",
|
||||
"host.recovery.library",
|
||||
]);
|
||||
|
||||
const explicit = parseSkinChromeDocument(JSON.stringify({
|
||||
schemaVersion: 1,
|
||||
@@ -209,10 +213,11 @@ test("chrome.json slots accept skin-owned anchors and reject trusted host UI", (
|
||||
anchor: "voice.audio-dock",
|
||||
align: "start",
|
||||
compact: true,
|
||||
mode: "capsule",
|
||||
});
|
||||
|
||||
// Defaults: align "end", compact off. Component and runtime-plugin parts are
|
||||
// ordinary anchors; only host/trusted parts are off limits.
|
||||
// Old slots without `mode` keep the docked capsule: the presentation is
|
||||
// explicit, never inferred from compact or any other field.
|
||||
const defaults = parseSkinChromeDocument(JSON.stringify({
|
||||
schemaVersion: 1,
|
||||
slots: {
|
||||
@@ -223,6 +228,7 @@ test("chrome.json slots accept skin-owned anchors and reject trusted host UI", (
|
||||
anchor: "skin.voice.harbor-dock.part-anchor",
|
||||
align: "end",
|
||||
compact: false,
|
||||
mode: "capsule",
|
||||
});
|
||||
assert.doesNotThrow(() => parseSkinChromeDocument(JSON.stringify({
|
||||
schemaVersion: 1,
|
||||
@@ -246,6 +252,70 @@ test("chrome.json slots accept skin-owned anchors and reject trusted host UI", (
|
||||
[{ schemaVersion: 1, slots: { "host.recovery": { anchor: "../escape" } } }, /not a valid part name/],
|
||||
[{ schemaVersion: 1, slots: { "host.recovery": { anchor: "Voice Audio Dock" } } }, /not a valid part name/],
|
||||
[{ schemaVersion: 1, slots: { "host.recovery": { anchor: "" } } }, /at most 240 characters/],
|
||||
[{ schemaVersion: 1, slots: { "host.recovery": { anchor: "voice.audio-dock", mode: "float" } } }, /invalid mode/],
|
||||
[{ schemaVersion: 1, slots: { "host.recovery": { anchor: "voice.audio-dock", mode: "toolbar", compact: true } } }, /compact is only valid in capsule mode/],
|
||||
[{ schemaVersion: 1, slots: { "host.recovery.built-in": { anchor: "voice.audio-dock", mode: "capsule" } } }, /only supports toolbar mode/],
|
||||
[{ schemaVersion: 1, slots: { "host.recovery.built-in": { anchor: "voice.audio-dock", compact: true } } }, /compact is only valid in capsule mode/],
|
||||
];
|
||||
for (const [value, message] of invalidDocuments) {
|
||||
assert.throws(() => parseSkinChromeDocument(JSON.stringify(value)), message, JSON.stringify(value));
|
||||
}
|
||||
});
|
||||
|
||||
test("chrome.json toolbar slots support page candidates and separate action buttons", () => {
|
||||
const toolbar = parseSkinChromeDocument(JSON.stringify({
|
||||
schemaVersion: 1,
|
||||
slots: {
|
||||
"host.recovery": {
|
||||
mode: "toolbar",
|
||||
anchor: [
|
||||
"skin.home.topbar.part-host-actions",
|
||||
"skin.voice.topbar.part-host-actions",
|
||||
"skin.home.topbar.part-host-actions",
|
||||
],
|
||||
align: "end",
|
||||
},
|
||||
},
|
||||
}));
|
||||
assert.deepEqual(toolbar.slots?.["host.recovery"], {
|
||||
anchor: [
|
||||
"skin.home.topbar.part-host-actions",
|
||||
"skin.voice.topbar.part-host-actions",
|
||||
],
|
||||
align: "end",
|
||||
compact: false,
|
||||
mode: "toolbar",
|
||||
});
|
||||
|
||||
const perAction = parseSkinChromeDocument(JSON.stringify({
|
||||
schemaVersion: 1,
|
||||
slots: {
|
||||
"host.recovery.built-in": {
|
||||
mode: "toolbar",
|
||||
anchor: "skin.voice.topbar.part-built-in",
|
||||
align: "start",
|
||||
},
|
||||
"host.recovery.library": {
|
||||
mode: "toolbar",
|
||||
anchor: "skin.voice.topbar.part-library",
|
||||
},
|
||||
},
|
||||
}));
|
||||
assert.deepEqual(perAction.slots?.["host.recovery.built-in"], {
|
||||
anchor: "skin.voice.topbar.part-built-in",
|
||||
align: "start",
|
||||
compact: false,
|
||||
mode: "toolbar",
|
||||
});
|
||||
// Single-action slots are toolbar-only and default to toolbar mode.
|
||||
assert.equal(perAction.slots?.["host.recovery.library"]?.mode, "toolbar");
|
||||
assert.equal(perAction.slots?.["host.recovery.library"]?.align, "end");
|
||||
|
||||
const invalidDocuments: Array<[unknown, RegExp]> = [
|
||||
[{ schemaVersion: 1, slots: { "host.recovery": { mode: "toolbar", anchor: [] } } }, /between 1 and 8/],
|
||||
[{ schemaVersion: 1, slots: { "host.recovery": { mode: "toolbar", anchor: Array.from({ length: 9 }, (_, index) => `part-${index}`) } } }, /between 1 and 8/],
|
||||
[{ schemaVersion: 1, slots: { "host.recovery": { mode: "toolbar", anchor: ["voice.audio-dock", "host.plugins.launcher"] } } }, /trusted host UI/],
|
||||
[{ schemaVersion: 1, slots: { "host.recovery": { mode: "toolbar", anchor: "voice.audio-dock" }, "host.recovery.built-in": { mode: "toolbar", anchor: "voice.audio-dock" } } }, /either host.recovery or its per-action slots/],
|
||||
];
|
||||
for (const [value, message] of invalidDocuments) {
|
||||
assert.throws(() => parseSkinChromeDocument(JSON.stringify(value)), message, JSON.stringify(value));
|
||||
|
||||
Reference in new issue
Block a user