mirror of
https://github.com/EchoSixHIYA/WebSpeak-client-for-TeamSpeak.git
synced 2026-12-02 19:42:51 +08:00
fix: close keyframe bypasses on protected controls without policing skin layout
Hold @keyframes to the same hide/yeet checks as regular declarations, including escaped and namespaced animation names. Loosen decorative host-chrome layout locks so open skins can restyle layout freely. Listen for the recovery shortcut in the capture phase, move the load-failure banner into the host-owned layer, and fix recovery aria-labels.
This commit is contained in:
1 parent
a84f66b47d
commit
a4ae4de82f
9 files changed
+286
-57
No files matched your search
@@ -435,7 +435,7 @@ Wasm 每轮最多读取一次输入并提交一个 UI 输出;首版宿主动
|
||||
|
||||
- 皮肤激活时,宿主在 `documentElement` 上设置 `data-ws-host-skin="<皮肤 ID>"`;停用或回退到内置皮肤时立即移除。
|
||||
- 编译 `skin.css` 时,**只**命中下列宿主部件的单个选择器会被限定到 `:root[data-ws-host-skin="<皮肤 ID>"] …`,其余规则仍限定到 `.ws-skin-root[data-ws-skin="…"]`。宿主部件的选择器必须**以可主题化的 `[data-ws-part="host.…"]` 开头**,不能把 `:root`、`html`、`body` 或 `*:has(…)` 作为规则主体;`:root:has([data-ws-part="host.watermark"])` 一类写法会被拒绝。皮肤作者不能自己写 `html`、`body`、`data-ws-host-skin`、`data-ws-route`、`data-theme` 或 `data-ws-skin` 选择器,也不能在同一选择器里混用宿主部件与页面部件;宿主部件只对 schema v3/v4 开放皮肤生效。
|
||||
- 宿主外壳的布局与层级由 WebSpeak 拥有:皮肤可改颜色、边框、圆角、阴影和素材,但不能用 `position`、`inset`、`z-index`、`transform` 等把 `host.plugins.overlay` 之类控件变成全屏遮罩。
|
||||
- 宿主外壳的布局与层级:应用库外壳 `host.plugins.overlay` 仍由 WebSpeak 拥有——皮肤可改颜色、边框、圆角、阴影和素材,但不能用 `position`、`inset`、`z-index`、`transform`、尺寸等把它或其子元素变成全屏遮罩。装饰性宿主部件(`host.watermark`、`host.hint`、`host.voice-status-decoration`、`host.plugins.launcher`)可以被重定位、改变尺寸和动画化;恢复路径不依赖它们。
|
||||
- 自定义变量仍必须使用 `--skin-` 前缀(不能覆盖宿主内部令牌),`@import`、脚本、`expression()`、`javascript:` 等仍被拒绝。
|
||||
- 皮肤根作用域只在根内部向下生效。编译器会拒绝任何以 `:root` 开头、紧跟兄弟组合符(`+` / `~`)的选择器,例如 `:root ~ *`、`:root ~ [data-ws-host-layer]` 或 `:root:hover + div`;这类规则会被改写为皮肤根的兄弟选择器,从而够到 body 上的宿主层。`:root [data-ws-part="home.header"]`、`:root > [data-ws-part=…]` 这类后代/子代写法仍然可用。
|
||||
- 宿主自有层的属性 `data-ws-host-layer`、`data-ws-host-recovery`、`data-ws-host-layer-content` 与 `data-ws-recovery-action` **不是皮肤钩子**:它们不在公开部件表中,编译器会按名称拒绝引用它们的皮肤选择器(包括 `:root [data-ws-host-layer]` 这类带公开钩子的混合写法)。
|
||||
@@ -461,9 +461,9 @@ Wasm 每轮最多读取一次输入并提交一个 UI 输出;首版宿主动
|
||||
|
||||
**显示规则**:只要当前是第三方(非内置/非官方)皮肤,恢复入口就作为小型常驻胶囊显示在左下角;它不是水印或装饰条,官方 Day、Night、ILLUSIA 与 KAAK 皮肤不会自动出现它。对内置/官方皮肤,它只在 `host.plugins.launcher` 被实例配置或 `chrome.json` 声明隐藏、或宿主在已连接状态下检测到启动器被 CSS 隐藏/移出视口/不可点击时作为兜底出现。
|
||||
|
||||
**键盘快捷键**:第三方皮肤被允许时,`Ctrl+Alt+Shift+R`(macOS 为 `⌘+⌥+⇧+R`)随时把同一宿主层恢复入口召唤到顶层并聚焦第一个按钮;它不与 WebSpeak 现有快捷键或浏览器常用快捷键冲突。
|
||||
**键盘快捷键**:第三方皮肤被允许时,`Ctrl+Alt+Shift+R`(macOS 为 `⌘+⌥+⇧+R`)随时把同一宿主层恢复入口召唤到顶层并聚焦第一个按钮;它不与 WebSpeak 现有快捷键或浏览器常用快捷键冲突。监听器运行在捕获阶段,皮肤或插件脚本提前调用 `preventDefault()` 不会吞掉该组合键。
|
||||
|
||||
`host.recovery` 与 `host.permission` 这两个名称仅保留为文档/布局元数据中的概念标识,**不再对应可被皮肤命中的 DOM 钩子**。皮肤加载失败的横幅使用独立部件 `app.skin-load-recovery`(「切换到内置皮肤」),与恢复胶囊不是同一个钩子。`skin.library` 是皮肤菜单里的应用库快捷入口,可作辅助路径,但**不是**兜底。
|
||||
`host.recovery` 与 `host.permission` 这两个名称仅保留为文档/布局元数据中的概念标识,**不再对应可被皮肤命中的 DOM 钩子**。皮肤加载失败的横幅保留 `app.skin-load-recovery` 部件标识(「切换到内置皮肤」),但它和恢复胶囊一样运行在闭合 Shadow DOM 宿主层中,编译后的皮肤 CSS 无法命中或改写它。`skin.library` 是皮肤菜单里的应用库快捷入口,可作辅助路径,但**不是**兜底。
|
||||
|
||||
恢复入口的宿主层与授权对话框的宿主层各自独立;两者都不与装饰同父,因此 `[data-ws-part="host.watermark"] ~ *` 一类兄弟选择器也碰不到它们。
|
||||
|
||||
@@ -618,9 +618,11 @@ v1/v2 校验器会阻止隐藏必要操作控件和其容器。v3 可改变显
|
||||
[data-ws-part="host.plugins.launcher"]
|
||||
```
|
||||
|
||||
上面必须使用单独的精确属性选择器;不能通过父容器、组合选择器或子元素间接隐藏/重置内容。`host.watermark`、`host.hint`、`host.voice-status-decoration` 默认不渲染,`chrome.json#visibleParts` 才是它们的开启开关。关键帧只有在其动画仅被这些可选部件引用时,才可使用透明度归零;若关键帧也被必要控件引用或动画名通过变量指定,则会被拒绝。`clip`、`clip-path` 和 `mask` 一律不允许,避免视觉裁切误伤真实控件。校验器是防止布局回归的边界,不是视觉质量证明;自定义字体、复杂背景和高对比特效仍需人工检查文字可读性与控件辨识度。
|
||||
上面必须使用单独的精确属性选择器;不能通过父容器、组合选择器或子元素间接隐藏/重置内容。`host.watermark`、`host.hint`、`host.voice-status-decoration` 默认不渲染,`chrome.json#visibleParts` 才是它们的开启开关。
|
||||
|
||||
皮肤可以重画控制外观。v1/v2 不能重新布置必要操作;v3 可以,因此须人工实测加入/退出、麦克风状态、设置、菜单、屏幕共享退出、音量、全屏等操作的可达性。v3 也不能用大的负 `margin*`、`inset`/`translate` 等把受保护控件移出视口,或把 `host.plugins.overlay` 及其后代改成定位全屏、放大到覆盖视口(`zoom` 等);这些写法会在导入时被拒绝。校验成功不代表设计质量合格;提交前要逐页实测窄屏和桌面尺寸、所有界面语言、键盘焦点与减少动效设置。
|
||||
关键帧与普通声明遵循同一套受保护控件检查:如果关键帧被受保护控件(例如 `voice.audio-dock`)引用,则其中的 `display: none`、`opacity: 0`、把控件移出视口的 `transform`/`inset`/`margin`,以及 `filter: opacity(0)` / `brightness(0)` 等视觉移除写法都会被拒绝;受保护控件上的 `animation` / `animation-name` 也不能用 `var()` / `attr()` 间接指定动画名。只被可选/装饰部件引用的关键帧仍可隐藏它们,v3 对非受保护部件的隐藏只给出警告。`clip`、`clip-path` 和 `mask` 并非一律禁止:它们仅在受保护控件主体上(以及作为 `host.plugins.overlay` 的既有锁定属性)被拒绝;官方示例皮肤(harbor、kaak)已经使用 `clip-path`。校验器是恢复路径的最后一道安全网,不是布局或视觉质量检查;自定义字体、复杂背景和高对比特效仍需人工检查文字可读性与控件辨识度。
|
||||
|
||||
皮肤可以重画控制外观。v1/v2 不能重新布置必要操作;v3 可以,因此须人工实测加入/退出、麦克风状态、设置、菜单、屏幕共享退出、音量、全屏等操作的可达性。v3 也不能用大的负 `margin*`、`inset`/`translate` 等把受保护控件移出视口,或把 `host.plugins.overlay` 及其后代改成定位全屏、放大到覆盖视口(`zoom` 等);这些写法会在导入时被拒绝。装饰性宿主外壳(`host.watermark`、`host.hint`、`host.voice-status-decoration`、`host.plugins.launcher`)和普通页面部件不受布局锁限制,可以自由使用 flex/grid、重定位、自定义尺寸、大背景和动画;固定定位或极端 `z-index` 只会给出提示。开放皮肤(v3/v4)的布局与视觉质量由官方库的人工审核保证,编译器不会阻止一般性的布局回归。校验成功不代表设计质量合格;提交前要逐页实测窄屏和桌面尺寸、所有界面语言、键盘焦点与减少动效设置。
|
||||
|
||||
CSS 被限定在 `.ws-skin-root` 内,管理员页面不会继承皮肤。删除实例里的包会停止从服务器提供该包;已经下载过的浏览器副本会保留在本地存储,因此仍可能在该浏览器的选择器中出现。清除该站点的浏览器数据可移除本地副本。
|
||||
|
||||
|
||||
+112
-2
@@ -277,7 +277,6 @@ test("host chrome cannot be restyled into a viewport-sized overlay", () => {
|
||||
() => compile('[data-ws-part="host.plugins.overlay"] { position: fixed; inset: 0; z-index: 2147483647; }'),
|
||||
/layout is owned by WebSpeak/,
|
||||
);
|
||||
assert.throws(() => compile('[data-ws-part="host.watermark"] { position: fixed; }'), /layout is owned by WebSpeak/);
|
||||
assert.throws(() => compile('[data-ws-part="host.plugins.overlay"] { width: 100vw; height: 100vh; }'), /fullscreen overlay/);
|
||||
|
||||
// Descendant rules are the same escape: `*` can turn the library contents
|
||||
@@ -286,7 +285,6 @@ test("host chrome cannot be restyled into a viewport-sized overlay", () => {
|
||||
'[data-ws-part="host.plugins.overlay"] * { position: fixed; inset: 0; z-index: 2147483647; }',
|
||||
'[data-ws-part="host.plugins.overlay"] * { width: 100vw; height: 100vh; }',
|
||||
'[data-ws-part="host.plugins.overlay"] .ws-plugin-library { position: fixed; top: 0; left: 0; }',
|
||||
'[data-ws-part="host.watermark"] * { z-index: 2147483647; }',
|
||||
]) {
|
||||
assert.throws(() => compile(css), /layout is owned by WebSpeak|fullscreen overlay/, css);
|
||||
}
|
||||
@@ -299,6 +297,19 @@ test("host chrome cannot be restyled into a viewport-sized overlay", () => {
|
||||
assert.throws(() => compile(css), /layout is owned by WebSpeak|fullscreen overlay/, css);
|
||||
}
|
||||
|
||||
// Decorative host chrome is not on the recovery path: it may be repositioned,
|
||||
// resized, restacked and animated, at most with a warning.
|
||||
for (const css of [
|
||||
'[data-ws-part="host.watermark"] { position: fixed; }',
|
||||
'[data-ws-part="host.watermark"] * { z-index: 2147483647; }',
|
||||
'[data-ws-part="host.watermark"] { position: fixed; inset: 0; width: 100vw; height: 100vh; z-index: 2147483647; opacity: .2; }',
|
||||
'[data-ws-part="host.plugins.launcher"] { position: fixed; top: 0; left: 0; width: 100vw; height: 100vh; }',
|
||||
'[data-ws-part="host.hint"] { position: absolute; transform: translateX(-10px); }',
|
||||
'[data-ws-part="host.voice-status-decoration"] { position: fixed; inset: 0; pointer-events: none; }',
|
||||
]) {
|
||||
assert.doesNotThrow(() => compile(css), css);
|
||||
}
|
||||
|
||||
// Colors, borders, radius, shadows and artwork stay available, including on
|
||||
// descendants of the overlay.
|
||||
const themed = compile('[data-ws-part="host.plugins.overlay"] { border: 2px solid #1d4f9c; border-radius: 4px; background: #fff; box-shadow: 0 2px 8px #0003; }');
|
||||
@@ -307,6 +318,105 @@ test("host chrome cannot be restyled into a viewport-sized overlay", () => {
|
||||
assert.doesNotThrow(() => compile('[data-ws-part="host.plugins.launcher"] { background: #1d4f9c; width: 120px; }'));
|
||||
});
|
||||
|
||||
test("keyframes follow the same protected-control rules as regular declarations", () => {
|
||||
const rejected: Array<[string, RegExp]> = [
|
||||
['@keyframes k { to { display: none; opacity: 0; } } [data-ws-part="voice.audio-dock"] { animation: k 1s forwards; }', /must remain available/],
|
||||
['@keyframes k { to { visibility: hidden; } } [data-ws-part="voice.audio-dock"] { animation: k 1s forwards; }', /must remain available/],
|
||||
['@keyframes k { to { transform: translateX(-9999px); } } [data-ws-part="voice.audio-dock"] { animation: k 1s forwards; }', /must remain on screen/],
|
||||
['@keyframes k { to { inset: 0 0 0 -120vw; } } [data-ws-part="voice.audio-dock"] { animation: k 1s forwards; }', /must remain on screen/],
|
||||
['@keyframes k { to { filter: opacity(0); } } [data-ws-part="voice.audio-dock"] { animation-name: k; }', /must remain visible/],
|
||||
['@keyframes k { to { filter: brightness(0); } } [data-ws-part="voice.audio-dock"] { animation-name: k; }', /must remain visible/],
|
||||
// A variable animation name must not hide the name from the walk.
|
||||
[':root { --skin-anim: k; } @keyframes k { to { opacity: 0; } } [data-ws-part="voice.audio-dock"] { animation: var(--skin-anim) 1s forwards; }', /cannot use indirect values/],
|
||||
['@keyframes k { to { opacity: 0; } } [data-ws-part="home.title"] { --skin-anim: k; } [data-ws-part="voice.audio-dock"] { animation-name: var(--skin-anim); }', /cannot use indirect values/],
|
||||
];
|
||||
for (const [css, message] of rejected) {
|
||||
assert.throws(() => compile(css), (error: unknown) => error instanceof Error && message.test(error.message), css);
|
||||
}
|
||||
// A keyframe shared by a protected and a non-protected part is judged by the
|
||||
// protected reference.
|
||||
assert.throws(
|
||||
() => compile('@keyframes k { to { opacity: 0; } } [data-ws-part="home.title"] { animation: k 1s; } [data-ws-part="voice.audio-dock"] { animation: k 1s; }'),
|
||||
/must remain available/,
|
||||
);
|
||||
|
||||
// Harmless fades, color tweens and gentle motion on non-protected parts, and
|
||||
// visual / motion keyframes on decorative host parts, still compile.
|
||||
for (const css of [
|
||||
'@keyframes fade { from { opacity: 0; } to { opacity: 1; } } [data-ws-part="home.title"] { animation: fade 2s ease; }',
|
||||
'@keyframes tint { from { color: #fff; } to { color: #1d4f9c; } } [data-ws-part="home.header"] { animation: tint 1.2s; }',
|
||||
'@keyframes drift { from { transform: translateY(0); } to { transform: translateY(-6px); } } [data-ws-part="home.hero.eyebrow"] { animation: drift 3s infinite alternate; }',
|
||||
'@keyframes wm { from { opacity: .1; color: #8ab9cf; transform: translateX(0); } to { opacity: .3; color: #2b6d8a; transform: translateX(20px); } } [data-ws-part="host.watermark"] { animation: wm 4s infinite alternate; }',
|
||||
'@keyframes big { to { width: 100vw; height: 100vh; opacity: .2; } } [data-ws-part="host.watermark"] { animation: big 1s forwards; }',
|
||||
'@keyframes hide { to { display: none; } } [data-ws-part="host.hint"] { animation: hide 1s forwards; }',
|
||||
]) {
|
||||
assert.doesNotThrow(() => compile(css), css);
|
||||
}
|
||||
});
|
||||
|
||||
test("escaped, namespaced and :is()/:where() animation names cannot bypass the protected-control locks", () => {
|
||||
const rejected: Array<[string, RegExp]> = [
|
||||
// Escaped property name used to skip the keyframe mapping walk.
|
||||
['@keyframes k { to { display: none; } } [data-ws-part="voice.audio-dock"] { anim\\61 tion: k 1s forwards; }', /must remain available/],
|
||||
// A pack can predict the namespace and reference the already-renamed keyframe.
|
||||
['@keyframes k { to { display: none; } } [data-ws-part="voice.audio-dock"] { animation: ws-demo-skin-k 1s forwards; }', /must remain available/],
|
||||
// The protected subject can be wrapped in a functional pseudo-class.
|
||||
[':is([data-ws-part="voice.audio-dock"]) { display: none; }', /must remain available/],
|
||||
[':where([data-ws-part="voice.audio-dock"]) { display: none; }', /must remain available/],
|
||||
['@keyframes k { to { opacity: 0; } } :is([data-ws-part="voice.audio-dock"]) { animation: k 1s forwards; }', /must remain available/],
|
||||
// -webkit-* animation longhands participate in the same walks.
|
||||
['@keyframes k { to { display: none; } } [data-ws-part="voice.audio-dock"] { -webkit-animation: k 1s forwards; }', /must remain available/],
|
||||
['@keyframes k { to { display: none; } } [data-ws-part="voice.audio-dock"] { -webkit-animation-name: k; }', /must remain available/],
|
||||
['[data-ws-part="voice.audio-dock"] { -webkit-animation: var(--skin-a); }', /cannot use indirect values/],
|
||||
// Escaped *values* used to bail out of the mapping walk on a backslash and
|
||||
// still resolve to the renamed keyframe in the browser.
|
||||
['@keyframes k { to { display: none; } } [data-ws-part="voice.audio-dock"] { animation: ws-demo-skin-\\6b 1s forwards; }', /must remain available/],
|
||||
['@keyframes k { to { display: none; } } [data-ws-part="voice.audio-dock"] { animation: ws-demo-skin-\\00006b 1s forwards; }', /must remain available/],
|
||||
['@keyframes k { to { opacity: 0; } } [data-ws-part="voice.audio-dock"] { animation-name: \\6b; }', /must remain available/],
|
||||
// Prefixed visual-removal properties must use the same checks as the unprefixed form.
|
||||
['[data-ws-part="voice.audio-dock"] { -webkit-filter: opacity(0); }', /must remain visible/],
|
||||
['[data-ws-part="voice.audio-dock"] { -webkit-transform: scale(0); }', /must remain visible/],
|
||||
];
|
||||
for (const [css, message] of rejected) {
|
||||
assert.throws(() => compile(css), (error: unknown) => error instanceof Error && message.test(error.message), css);
|
||||
}
|
||||
|
||||
// `:not()` does not make the protected part the subject; only a v3 warning.
|
||||
assert.doesNotThrow(() => compile(':not([data-ws-part="voice.audio-dock"]) { display: none; }'));
|
||||
|
||||
// A harmless -webkit-animation on a non-protected part still compiles and its
|
||||
// keyframe name is rewritten into the skin namespace.
|
||||
const webkit = compile('@keyframes fade { from { opacity: 0; } to { opacity: 1; } } [data-ws-part="home.title"] { -webkit-animation: fade 2s ease; }');
|
||||
assert.match(webkit.css, /@keyframes ws-demo-skin-fade/);
|
||||
assert.match(webkit.css, /-webkit-animation: ws-demo-skin-fade 2s ease/);
|
||||
});
|
||||
|
||||
test("keyframes cannot turn the plugin overlay into a fullscreen layer", () => {
|
||||
for (const css of [
|
||||
'@keyframes k { to { position: fixed; inset: 0; z-index: 2147483647; } } [data-ws-part="host.plugins.overlay"] { animation: k 1s forwards; }',
|
||||
'@keyframes k { to { width: 100vw; height: 100vh; } } [data-ws-part="host.plugins.overlay"] * { animation: k 1s forwards; }',
|
||||
'@keyframes k { to { zoom: 10; } } [data-ws-part="host.plugins.overlay"] { animation: k 1s forwards; }',
|
||||
'@keyframes k { to { transform: scale(10); } } [data-ws-part="host.plugins.overlay"] { animation-name: k; }',
|
||||
]) {
|
||||
assert.throws(() => compile(css), /layout is owned by WebSpeak|fullscreen overlay/, css);
|
||||
}
|
||||
// The same animation is harmless on decorative host chrome.
|
||||
assert.doesNotThrow(() => compile('@keyframes k { to { position: fixed; inset: 0; width: 100vw; height: 100vh; z-index: 2147483647; opacity: .2; } } [data-ws-part="host.watermark"] { animation: k 1s forwards; }'));
|
||||
});
|
||||
|
||||
test("large layout restyles of non-protected parts and decorative host chrome compile", () => {
|
||||
for (const css of [
|
||||
'[data-ws-part="home.header"] { display: grid; grid-template-columns: 1fr 2fr; gap: 16px; position: relative; width: 80vw; height: 50vh; }',
|
||||
'[data-ws-part="home.header"] { display: flex; flex-direction: column; align-items: stretch; translate: 24px 0; }',
|
||||
'[data-ws-part="voice.audio-dock"] > div:first-child { position: absolute; width: 100vw; height: 100vh; }',
|
||||
// Official example skins (harbor, kaak) clip their own artwork.
|
||||
'[data-ws-part="home.header"] { clip-path: polygon(0 0, 100% 0, 100% 82%, 0 100%); }',
|
||||
'[data-ws-part="host.watermark"] { position: fixed; inset: 0; width: 100vw; height: 100vh; transform: rotate(-8deg); }',
|
||||
]) {
|
||||
assert.doesNotThrow(() => compile(css), css);
|
||||
}
|
||||
});
|
||||
|
||||
test("official and built-in skins hide host decorations unless the active skin opts in", () => {
|
||||
const decorations = ["host.watermark", "host.hint", "host.voice-status-decoration"];
|
||||
assert.deepEqual([...DEFAULT_HIDDEN_HOST_PARTS].sort(), [...decorations].sort());
|
||||
|
||||
+116
-34
@@ -1,5 +1,5 @@
|
||||
import postcss, { type AtRule, type Declaration, type Node, type Rule } from "postcss";
|
||||
import selectorParser from "postcss-selector-parser";
|
||||
import selectorParser, { type Node as SelectorNode } from "postcss-selector-parser";
|
||||
import valueParser from "postcss-value-parser";
|
||||
import {
|
||||
DECORATIVE_PART_IDS as OPTIONAL_VISUAL_PARTS,
|
||||
@@ -180,21 +180,47 @@ export function compileSkinCss(source: string, id: string, assets: SkinCssAssets
|
||||
|
||||
const referencedKeyframes = new Set<string>();
|
||||
const nonOptionalKeyframes = new Set<string>();
|
||||
// Keyframes referenced by a protected control must obey the same
|
||||
// visibility/positioning rules as a declaration on that control. Keyframe
|
||||
// params are already namespaced at this point, so the maps use scoped names.
|
||||
const protectedKeyframeParts = new Map<string, string>();
|
||||
// Keyframes referenced by non-decorative host chrome (the plugin overlay
|
||||
// shell) keep the host layout locks; decorative host parts are free to move.
|
||||
const lockedHostKeyframeParts = new Map<string, Set<string>>();
|
||||
root.walkRules((rule: Rule) => {
|
||||
if (hasKeyframesAncestor(rule)) return;
|
||||
const optionalTarget = hideableRules.has(rule);
|
||||
rule.walkDecls((declaration: Declaration) => {
|
||||
const property = declaration.prop.toLowerCase();
|
||||
// Match the enforcement walk: decode the property so an escaped
|
||||
// `anim\61 tion` cannot skip the keyframe mapping, and treat
|
||||
// `-webkit-animation` as `animation`.
|
||||
const property = decodeCssEscapes(declaration.prop).toLowerCase().replace(/^-(?:webkit|moz|ms|o)-/, "");
|
||||
if (property !== "animation" && property !== "animation-name") return;
|
||||
const value = declaration.value;
|
||||
if (/\b(?:var|attr)\s*\(|\\/i.test(value)) {
|
||||
// Decode first so an escaped identifier (`\6b`, `ws-…-\00006b`) is
|
||||
// matched against the original and namespaced names. `var()`/`attr()`
|
||||
// still cannot be resolved statically; only those bail out. A bare
|
||||
// backslash is no longer a reason to skip protected mapping.
|
||||
const decodedValue = decodeCssEscapes(declaration.value);
|
||||
if (/\b(?:var|attr)\s*\(/i.test(decodedValue)) {
|
||||
keyframeNames.forEach((_, name) => nonOptionalKeyframes.add(name));
|
||||
return;
|
||||
}
|
||||
for (const name of keyframeNames.keys()) {
|
||||
if (!referencesCssIdentifier(value, name)) continue;
|
||||
// The value may already use the namespaced name (a pack can name its own
|
||||
// id), so match both the original and the rewritten identifier.
|
||||
const protectedTarget = selectorSubjectProtectedPart(rule.selector);
|
||||
const lockedHostParts = selectorLockedHostParts(rule.selector);
|
||||
for (const [name, scopedName] of keyframeNames) {
|
||||
if (!referencesCssIdentifier(decodedValue, name) && !referencesCssIdentifier(decodedValue, scopedName)) continue;
|
||||
referencedKeyframes.add(name);
|
||||
if (!optionalTarget) nonOptionalKeyframes.add(name);
|
||||
if (protectedTarget && !protectedKeyframeParts.has(scopedName)) {
|
||||
protectedKeyframeParts.set(scopedName, protectedTarget);
|
||||
}
|
||||
if (lockedHostParts.length) {
|
||||
const parts = lockedHostKeyframeParts.get(scopedName) ?? new Set<string>();
|
||||
for (const part of lockedHostParts) parts.add(part);
|
||||
lockedHostKeyframeParts.set(scopedName, parts);
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
@@ -209,17 +235,30 @@ export function compileSkinCss(source: string, id: string, assets: SkinCssAssets
|
||||
const decodedValue = decodeCssEscapes(value);
|
||||
const owningRule = findOwningRule(declaration);
|
||||
const keyframesRule = owningRule ? findKeyframesRule(owningRule) : null;
|
||||
const keyframeScope = keyframesRule?.params.trim() ?? null;
|
||||
const canHideTarget = owningRule
|
||||
? hideableRules.has(owningRule) || Boolean(keyframesRule && optionalOnlyKeyframes.has(keyframesRule.params.trim()))
|
||||
: false;
|
||||
// Trusted UI and essential audio/recovery controls stay available even for
|
||||
// open skins. The host also draws authorization and recovery UI outside the
|
||||
// skin root, so a container-level hide cannot remove them either.
|
||||
const protectedTarget = owningRule && !keyframesRule ? selectorSubjectProtectedPart(owningRule.selector) : null;
|
||||
// skin root, so a container-level hide cannot remove them either. A
|
||||
// keyframe inherits the protected status of the rules that reference it.
|
||||
const protectedTarget = owningRule
|
||||
? keyframesRule
|
||||
? (keyframeScope ? protectedKeyframeParts.get(keyframeScope) ?? null : null)
|
||||
: selectorSubjectProtectedPart(owningRule.selector)
|
||||
: null;
|
||||
// Every themeable host part referenced anywhere in the selector. A rule may
|
||||
// target a descendant of the overlay (for example with `*`), so the subject
|
||||
// alone is not enough to decide whether host chrome layout is at stake.
|
||||
const hostChromeParts = owningRule && !keyframesRule ? selectorHostChromeParts(owningRule.selector) : [];
|
||||
// Decorative host chrome (watermark, hint, status strip, plugin launcher)
|
||||
// is free to be repositioned; only non-decorative host chrome keeps its
|
||||
// layout locks.
|
||||
const hostChromeParts = owningRule
|
||||
? keyframesRule
|
||||
? (keyframeScope ? [...(lockedHostKeyframeParts.get(keyframeScope) ?? [])] : [])
|
||||
: selectorLockedHostParts(owningRule.selector)
|
||||
: [];
|
||||
const inHostChromeScope = hostChromeParts.length > 0;
|
||||
const inOverlayScope = hostChromeParts.includes("host.plugins.overlay");
|
||||
if (property.startsWith("--") && !/^--skin-[a-z0-9_-]+$/i.test(property)
|
||||
@@ -231,10 +270,11 @@ export function compileSkinCss(source: string, id: string, assets: SkinCssAssets
|
||||
if (schemaVersion < 3 && isLayoutAffectingProperty(property)) {
|
||||
throw declaration.error("Skin CSS may change component artwork and appearance, but must not change layout, positioning, sizing, text flow, or interaction geometry.");
|
||||
}
|
||||
// Host chrome lives outside the skin root and owns its own placement. A
|
||||
// skin may repaint it (colors, borders, radius, artwork) but must not turn
|
||||
// it — or any of its descendants — into a viewport-sized overlay above
|
||||
// authorization/recovery UI.
|
||||
// Non-decorative host chrome lives outside the skin root and owns its own
|
||||
// placement. A skin may repaint it (colors, borders, radius, artwork) but
|
||||
// must not turn it — or any of its descendants — into a viewport-sized
|
||||
// overlay above authorization/recovery UI. Decorative host parts skip this
|
||||
// lock so they can be repositioned and resized freely.
|
||||
if (inHostChromeScope && HOST_CHROME_LOCKED_PROPERTIES.has(unprefixedProperty)) {
|
||||
throw declaration.error("Host chrome layout is owned by WebSpeak; skins may theme colors, borders, radius and artwork but must not reposition or restack host controls.");
|
||||
}
|
||||
@@ -252,22 +292,29 @@ export function compileSkinCss(source: string, id: string, assets: SkinCssAssets
|
||||
}
|
||||
if (!canHideTarget && schemaVersion < 3) throw declaration.error("Visibility and interaction styles can only use indirect values on explicitly optional visual parts.");
|
||||
}
|
||||
const removesVisual = property === "all"
|
||||
|| (property === "display" && compactValue === "none")
|
||||
|| (property === "visibility" && /^(?:hidden|collapse)$/.test(compactValue))
|
||||
|| (property === "opacity" && /^0(?:\.0+)?%?$/.test(compactValue))
|
||||
|| (property === "pointer-events" && compactValue === "none")
|
||||
|| (property === "clip-path" && /inset\(\s*50%/.test(compactValue))
|
||||
|| (property === "mask" && /(?:alpha\(0\)|luminance\(0\))/.test(compactValue));
|
||||
// An indirect animation name could resolve to a keyframe that hides or
|
||||
// moves the subject; check it at the declaration site instead of treating
|
||||
// every keyframe in the file as protected.
|
||||
if (!keyframesRule && protectedTarget && (unprefixedProperty === "animation" || unprefixedProperty === "animation-name")
|
||||
&& /\b(?:var|attr)\s*\(/i.test(decodedValue)) {
|
||||
throw declaration.error(`The required control "${protectedTarget}" cannot use indirect values for visibility or positioning.`);
|
||||
}
|
||||
const removesVisual = unprefixedProperty === "all"
|
||||
|| (unprefixedProperty === "display" && compactValue === "none")
|
||||
|| (unprefixedProperty === "visibility" && /^(?:hidden|collapse)$/.test(compactValue))
|
||||
|| (unprefixedProperty === "opacity" && /^0(?:\.0+)?%?$/.test(compactValue))
|
||||
|| (unprefixedProperty === "pointer-events" && compactValue === "none")
|
||||
|| (unprefixedProperty === "clip-path" && /inset\(\s*50%/.test(compactValue))
|
||||
|| (unprefixedProperty === "mask" && /(?:alpha\(0\)|luminance\(0\))/.test(compactValue));
|
||||
if (removesVisual && protectedTarget) {
|
||||
throw declaration.error(`The required control "${protectedTarget}" must remain available; permission, recovery and essential audio paths cannot be hidden.`);
|
||||
}
|
||||
if (removesVisual && !canHideTarget && schemaVersion < 3) {
|
||||
throw declaration.error("Only explicitly optional visual parts may be hidden or reset; required controls and their containers must remain available.");
|
||||
}
|
||||
const visuallyRemoves = (property === "transform" && /scale(?:3d)?\(\s*0(?:\s*[,)]|\s*\))/i.test(decodedValue))
|
||||
|| (property === "clip-path" && /inset\(\s*50%/i.test(decodedValue))
|
||||
|| (property === "filter" && /(?:opacity|brightness)\(\s*0(?:%|\s*[,)]|\s*\))/i.test(decodedValue));
|
||||
const visuallyRemoves = (unprefixedProperty === "transform" && /scale(?:3d)?\(\s*0(?:\s*[,)]|\s*\))/i.test(decodedValue))
|
||||
|| (unprefixedProperty === "clip-path" && /inset\(\s*50%/i.test(decodedValue))
|
||||
|| (unprefixedProperty === "filter" && /(?:opacity|brightness)\(\s*0(?:%|\s*[,)]|\s*\))/i.test(decodedValue));
|
||||
if (visuallyRemoves && protectedTarget) {
|
||||
throw declaration.error(`The required control "${protectedTarget}" must remain visible.`);
|
||||
}
|
||||
@@ -279,7 +326,7 @@ export function compileSkinCss(source: string, id: string, assets: SkinCssAssets
|
||||
}
|
||||
if (schemaVersion >= 3 && removesVisual && !protectedTarget) warnings.add("This open skin hides an interface part; keep a usable path to essential voice and recovery controls.");
|
||||
if (/\bz-index\s*:\s*(?:[1-9]\d{4,}|-\d{4,})\b/i.test(`${property}:${decodedValue}`) || (property === "position" && decodedValue === "fixed")) warnings.add("Fixed positioning or extreme stacking may cover important controls; check the preview on desktop and mobile.");
|
||||
const withScopedNames = rewriteScopedNames(value, property, keyframeNames, fontFamilyNames);
|
||||
const withScopedNames = rewriteScopedNames(value, unprefixedProperty, keyframeNames, fontFamilyNames);
|
||||
declaration.value = rewriteAssetUrls(withScopedNames, (assetPath) => {
|
||||
if (!hasSkinCssAsset(assets, assetPath)) throw declaration.error(`CSS references an asset not present in the package: ${assetPath}`);
|
||||
return `wskin-asset:${encodeURIComponent(assetPath)}`;
|
||||
@@ -427,21 +474,46 @@ function assertHostChromeSubject(parsed: selectorParser.Root): void {
|
||||
}
|
||||
}
|
||||
|
||||
/** Functional pseudo-classes whose arguments keep the subject role. */
|
||||
const SUBJECT_PSEUDO_CLASSES = new Set([":is", ":where", ":matches", ":-webkit-any", ":-moz-any"]);
|
||||
|
||||
/** The nodes after the last combinator, i.e. the subject compound. */
|
||||
function lastCompound(nodes: SelectorNode[]): SelectorNode[] {
|
||||
let start = 0;
|
||||
for (let index = nodes.length - 1; index >= 0; index -= 1) {
|
||||
if (nodes[index].type === "combinator") { start = index + 1; break; }
|
||||
}
|
||||
return nodes.slice(start);
|
||||
}
|
||||
|
||||
/**
|
||||
* Find a protected part in one compound. The subject may be wrapped in
|
||||
* `:is()`/`:where()`, so descend into those arguments. `:not(...)` is
|
||||
* deliberately skipped: a protected part inside `:not()` is not the subject.
|
||||
*/
|
||||
function compoundProtectedPart(nodes: SelectorNode[]): string | null {
|
||||
for (const node of nodes) {
|
||||
if (node.type === "attribute" && node.attribute.toLowerCase() === "data-ws-part" && node.value) {
|
||||
const part = node.value.replace(/^['"]|['"]$/g, "");
|
||||
if (PROTECTED_PART_IDS.has(part)) return part;
|
||||
}
|
||||
if (node.type === "pseudo" && node.nodes && SUBJECT_PSEUDO_CLASSES.has(node.value.toLowerCase())) {
|
||||
for (const nested of node.nodes) {
|
||||
const part = compoundProtectedPart(lastCompound(nested.nodes));
|
||||
if (part) return part;
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/** Find a protected part in the subject (last compound) of any selector in a rule. */
|
||||
function selectorSubjectProtectedPart(selector: string): string | null {
|
||||
try {
|
||||
const parsed = selectorParser().astSync(selector);
|
||||
for (const item of parsed.nodes) {
|
||||
let start = 0;
|
||||
for (let index = item.nodes.length - 1; index >= 0; index -= 1) {
|
||||
if (item.nodes[index].type === "combinator") { start = index + 1; break; }
|
||||
}
|
||||
for (let index = start; index < item.nodes.length; index += 1) {
|
||||
const node = item.nodes[index];
|
||||
if (node.type !== "attribute" || node.attribute.toLowerCase() !== "data-ws-part" || !node.value) continue;
|
||||
const part = node.value.replace(/^['"]|['"]$/g, "");
|
||||
if (PROTECTED_PART_IDS.has(part)) return part;
|
||||
}
|
||||
const part = compoundProtectedPart(lastCompound(item.nodes));
|
||||
if (part) return part;
|
||||
}
|
||||
} catch { /* A malformed selector is rejected elsewhere. */ }
|
||||
return null;
|
||||
@@ -460,6 +532,16 @@ function selectorHostChromeParts(selector: string): string[] {
|
||||
return parts;
|
||||
}
|
||||
|
||||
/**
|
||||
* Host parts whose layout stays owned by WebSpeak. Decorative host chrome (the
|
||||
* watermark, hint, voice-status strip and plugin launcher) is deliberately
|
||||
* excluded: skins may reposition, resize and animate it because recovery does
|
||||
* not depend on it.
|
||||
*/
|
||||
function selectorLockedHostParts(selector: string): string[] {
|
||||
return selectorHostChromeParts(selector).filter((part) => !OPTIONAL_VISUAL_PARTS.has(part));
|
||||
}
|
||||
|
||||
function isLayoutAffectingProperty(property: string): boolean {
|
||||
const unprefixed = property.replace(/^-(?:webkit|moz|ms|o)-/, "");
|
||||
if (LAYOUT_AFFECTING_PROPERTIES.has(unprefixed)) return true;
|
||||
|
||||
@@ -162,13 +162,16 @@ function openLibrary() {
|
||||
}
|
||||
|
||||
function onKeydown(event: KeyboardEvent) {
|
||||
if (event.defaultPrevented || event.repeat || !thirdPartyAllowed.value) return;
|
||||
if (event.repeat || !thirdPartyAllowed.value) return;
|
||||
// The recovery chord must survive a capture-phase preventDefault() from a
|
||||
// skin or plugin, so it runs before the defaultPrevented check below.
|
||||
if (isRecoveryShortcut(event)) {
|
||||
event.preventDefault();
|
||||
shortcutOpen.value = true;
|
||||
void nextTick(() => recoveryPopover.value?.querySelector("button")?.focus());
|
||||
return;
|
||||
}
|
||||
if (event.defaultPrevented) return;
|
||||
if (event.key === "Escape" && shortcutOpen.value) shortcutOpen.value = false;
|
||||
}
|
||||
|
||||
@@ -184,13 +187,13 @@ onMounted(() => {
|
||||
refreshLauncherReachability();
|
||||
reachabilityTimer = setInterval(refreshLauncherReachability, 1000);
|
||||
window.addEventListener("resize", refreshLauncherReachability);
|
||||
window.addEventListener("keydown", onKeydown);
|
||||
window.addEventListener("keydown", onKeydown, true);
|
||||
void nextTick(syncPopover);
|
||||
});
|
||||
onBeforeUnmount(() => {
|
||||
if (reachabilityTimer) clearInterval(reachabilityTimer);
|
||||
window.removeEventListener("resize", refreshLauncherReachability);
|
||||
window.removeEventListener("keydown", onKeydown);
|
||||
window.removeEventListener("keydown", onKeydown, true);
|
||||
layer?.dispose();
|
||||
});
|
||||
</script>
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
<template>
|
||||
<Teleport to="body">
|
||||
<Teleport v-if="layer" :to="layer.container">
|
||||
<section v-if="error" class="skin-load-recovery" data-ws-part="app.skin-load-recovery" role="alert">
|
||||
<p>{{ labels.skinLoadError(error.skinId) }}</p>
|
||||
<button type="button" @click="$emit('use-built-in')">{{ labels.skinUseBuiltIn }}</button>
|
||||
@@ -8,9 +8,10 @@
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { computed } from "vue";
|
||||
import { computed, onBeforeUnmount } from "vue";
|
||||
import type { Language } from "../i18n/web-client.js";
|
||||
import { resolveSkinLayoutLanguage, skinLayoutLabels } from "../i18n/skin-layout.js";
|
||||
import { createHostOwnedLayer, type HostOwnedLayer } from "../services/host-owned-layer.js";
|
||||
|
||||
defineEmits<{ "use-built-in": [] }>();
|
||||
|
||||
@@ -19,9 +20,11 @@ const props = defineProps<{
|
||||
language: Language;
|
||||
}>();
|
||||
const labels = computed(() => skinLayoutLabels[resolveSkinLayoutLanguage(props.language)]);
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
// The banner is trusted host UI: render it in a closed shadow root so compiled
|
||||
// skin CSS cannot restyle it (or hide it) from the document. The layer's fixed
|
||||
// wrapper is pointer-transparent, so the banner re-enables pointer events.
|
||||
const SKIN_LOAD_LAYER_CSS = `
|
||||
.skin-load-recovery {
|
||||
position: fixed;
|
||||
z-index: 2147482500;
|
||||
@@ -40,13 +43,18 @@ const labels = computed(() => skinLayoutLabels[resolveSkinLayoutLanguage(props.l
|
||||
background: #fffbeb;
|
||||
box-shadow: 0 8px 28px #0f172a33;
|
||||
font: 14px/1.45 ui-sans-serif, system-ui, sans-serif;
|
||||
pointer-events: auto;
|
||||
}
|
||||
.skin-load-recovery p { flex: 1; min-width: 0; margin: 0; overflow-wrap: anywhere; }
|
||||
.skin-load-recovery button { flex: 0 0 auto; min-height: 44px; max-width: 100%; padding: 7px 10px; border: 1px solid #b45309; border-radius: 8px; color: #78350f; background: #fff; cursor: pointer; white-space: normal; }
|
||||
.skin-load-recovery button:focus-visible { outline: 3px solid #1d4ed8; outline-offset: 2px; }
|
||||
|
||||
@media (max-width: 520px) {
|
||||
.skin-load-recovery { align-items: stretch; flex-direction: column; gap: 7px; }
|
||||
.skin-load-recovery button { width: 100%; }
|
||||
}
|
||||
</style>
|
||||
`;
|
||||
|
||||
const layer: HostOwnedLayer | null = createHostOwnedLayer("skin-load", SKIN_LOAD_LAYER_CSS);
|
||||
|
||||
onBeforeUnmount(() => layer?.dispose());
|
||||
</script>
|
||||
@@ -4,7 +4,7 @@ import type { SiteLanguage } from "../../../src/site-copy.js";
|
||||
const en = {
|
||||
hint: "Audio controls remain available in the toolbar and voice workspace.",
|
||||
library: "Application library",
|
||||
recovery: "Restore application library",
|
||||
recovery: "Restore built-in skin",
|
||||
useBuiltIn: "Use built-in skin",
|
||||
shortcut: "Restore the built-in skin (Ctrl+Alt+Shift+R, or ⌘+⌥+⇧+R on macOS)",
|
||||
};
|
||||
@@ -13,28 +13,28 @@ export const hostChromeCopy: Record<SiteLanguage, typeof en> = {
|
||||
zh: {
|
||||
hint: "音频控制始终保留在工具栏和语音工作区中。",
|
||||
library: "应用库",
|
||||
recovery: "恢复应用库",
|
||||
recovery: "恢复内置皮肤",
|
||||
useBuiltIn: "使用内置皮肤",
|
||||
shortcut: "恢复内置皮肤(Ctrl+Alt+Shift+R,macOS 为 ⌘+⌥+⇧+R)",
|
||||
},
|
||||
de: {
|
||||
hint: "Audiosteuerung bleibt in der Werkzeugleiste und im Sprachbereich verfügbar.",
|
||||
library: "Anwendungsbibliothek",
|
||||
recovery: "Anwendungsbibliothek wiederherstellen",
|
||||
recovery: "Integrierten Skin wiederherstellen",
|
||||
useBuiltIn: "Integrierten Skin verwenden",
|
||||
shortcut: "Integrierten Skin wiederherstellen (Strg+Alt+Umschalt+R, unter macOS ⌘+⌥+⇧+R)",
|
||||
},
|
||||
ru: {
|
||||
hint: "Управление звуком остаётся доступным на панели инструментов и в голосовой области.",
|
||||
library: "Библиотека приложений",
|
||||
recovery: "Восстановить библиотеку приложений",
|
||||
recovery: "Восстановить встроенную тему",
|
||||
useBuiltIn: "Использовать встроенную тему",
|
||||
shortcut: "Восстановить встроенную тему (Ctrl+Alt+Shift+R, в macOS ⌘+⌥+⇧+R)",
|
||||
},
|
||||
ja: {
|
||||
hint: "音声コントロールはツールバーと音声ワークスペースで常に利用できます。",
|
||||
library: "アプリライブラリ",
|
||||
recovery: "アプリライブラリを復元",
|
||||
recovery: "組み込みスキンを復元",
|
||||
useBuiltIn: "組み込みスキンを使用",
|
||||
shortcut: "組み込みスキンを復元(Ctrl+Alt+Shift+R、macOS は ⌘+⌥+⇧+R)",
|
||||
},
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
* without the Popover API still shows the UI above ordinary content.
|
||||
*/
|
||||
|
||||
export type HostOwnedLayerName = "recovery" | "authorization";
|
||||
export type HostOwnedLayerName = "recovery" | "authorization" | "skin-load";
|
||||
|
||||
/**
|
||||
* The CSS 32-bit maximum stacking value. A compiled skin may legitimately use
|
||||
|
||||
+2
@@ -26,6 +26,8 @@
|
||||
<div id="overlay" data-ws-part="host.plugins.overlay">Application library</div>
|
||||
<button type="button" id="launcher" data-ws-part="host.plugins.launcher">Plugins</button>
|
||||
</div>
|
||||
<!-- Decorative host chrome lives outside the skin root in the real client. -->
|
||||
<div id="watermark" data-ws-part="host.watermark" aria-hidden="true">Watermark</div>
|
||||
<div id="app"></div>
|
||||
<div id="auth-app"></div>
|
||||
<pre id="result" style="position:relative;z-index:5;background:#fff">pending</pre>
|
||||
|
||||
@@ -42,15 +42,26 @@ const scenarios = [
|
||||
name: "pointer-events-none",
|
||||
css: compileHostile('[data-ws-part="host.plugins.launcher"], [data-ws-part="host.plugins.overlay"] { pointer-events: none !important; }'),
|
||||
},
|
||||
{
|
||||
// Decorative host chrome may legitimately be a fixed, viewport-sized,
|
||||
// max-stacking decoration. Recovery lives in a closed-shadow top layer and
|
||||
// must still win the hit test.
|
||||
name: "decorative-watermark-overlay",
|
||||
css: compileHostile(`
|
||||
@keyframes drift { from { transform: translateX(0); } to { transform: translateX(12px); } }
|
||||
[data-ws-part="host.watermark"] { position: fixed; inset: 0; width: 100vw; height: 100vh; z-index: 2147483647; background: #123; animation: drift 3s ease-in-out infinite alternate; }
|
||||
`),
|
||||
},
|
||||
];
|
||||
|
||||
test("host chrome renders recovery and authorization in a closed-shadow top layer", async () => {
|
||||
const [hostChrome, authorization, ownedLayer, hostChromeService, publicSkin] = await Promise.all([
|
||||
const [hostChrome, authorization, ownedLayer, hostChromeService, publicSkin, recoveryNotice] = await Promise.all([
|
||||
read("../src/components/HostChrome.vue"),
|
||||
read("../src/components/InstanceAuthorization.vue"),
|
||||
read("../src/services/host-owned-layer.ts"),
|
||||
read("../src/services/host-chrome.ts"),
|
||||
read("../src/composables/usePublicSkin.ts"),
|
||||
read("../src/components/SkinLoadRecoveryNotice.vue"),
|
||||
]);
|
||||
|
||||
// Recovery: closed shadow root + manual popover + no skin hook.
|
||||
@@ -59,6 +70,11 @@ test("host chrome renders recovery and authorization in a closed-shadow top laye
|
||||
assert.match(hostChrome, /data-ws-recovery-action="built-in"/);
|
||||
assert.match(hostChrome, /requestBuiltInSkin/);
|
||||
assert.match(hostChrome, /isThirdPartySkinActive/);
|
||||
// The shortcut runs in the capture phase so a plugin/skin capture listener
|
||||
// cannot swallow it with preventDefault().
|
||||
assert.match(hostChrome, /addEventListener\("keydown", onKeydown, true\)/);
|
||||
assert.match(hostChrome, /removeEventListener\("keydown", onKeydown, true\)/);
|
||||
assert.doesNotMatch(hostChrome, /event\.defaultPrevented \|\| event\.repeat/);
|
||||
assert.doesNotMatch(hostChrome, /data-ws-part="host\.recovery"/);
|
||||
assert.doesNotMatch(hostChrome, /ws-host-recovery-layer/);
|
||||
|
||||
@@ -67,6 +83,12 @@ test("host chrome renders recovery and authorization in a closed-shadow top laye
|
||||
assert.match(authorization, /showModal\(\)/);
|
||||
assert.doesNotMatch(authorization, /data-ws-part="host\.permission"/);
|
||||
|
||||
// The load-failure banner is trusted UI too: closed shadow layer, stylesheet
|
||||
// inside the boundary, no document-level scoped stylesheet to override.
|
||||
assert.match(recoveryNotice, /createHostOwnedLayer\("skin-load"/);
|
||||
assert.match(recoveryNotice, /data-ws-part="app\.skin-load-recovery"/);
|
||||
assert.doesNotMatch(recoveryNotice, /<style scoped>/);
|
||||
|
||||
// The layer itself: closed shadow root, no data-ws-part, fixed fallback.
|
||||
assert.match(ownedLayer, /attachShadow\(\{ mode: "closed" \}\)/);
|
||||
assert.match(ownedLayer, /data-ws-host-layer/);
|
||||
|
||||
Reference in new issue
Block a user