chore(tooling): 对齐协作规范与浏览器验收工具
验证:713 项单测、8 视口环境、代码及格式检查通过;未运行生产构建。
This commit is contained in:
@@ -0,0 +1,59 @@
|
||||
/*
|
||||
Copyright (C) 2025 QuantumNous
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as
|
||||
published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
For commercial licensing, please contact support@quantumnous.com
|
||||
*/
|
||||
|
||||
// 有头 Chrome 焦点守卫:唯一页面、禁止新建 / 切换标签页、后台建页兜底、前台状态检测。
|
||||
// 规则见 docs/ui/GLOBAL_UI_BASELINE.md 第 7.1 节。
|
||||
|
||||
// Use this for static review captures, not for interaction/animation tests.
|
||||
export async function prepareStaticCapture(page) {
|
||||
await page.evaluate(async () => {
|
||||
await Promise.race([
|
||||
Promise.all([
|
||||
document.fonts.ready,
|
||||
...[...document.images]
|
||||
.filter((image) => image.currentSrc && image.checkVisibility())
|
||||
.map((image) => image.decode().catch(() => {})),
|
||||
]),
|
||||
new Promise((_, reject) =>
|
||||
setTimeout(
|
||||
() =>
|
||||
reject(
|
||||
new Error(
|
||||
'Static capture fonts/images did not settle within 10s',
|
||||
),
|
||||
),
|
||||
10000,
|
||||
),
|
||||
),
|
||||
]);
|
||||
});
|
||||
}
|
||||
|
||||
export const staticScreenshotOptions = {
|
||||
scale: 'css',
|
||||
animations: 'disabled',
|
||||
caret: 'hide',
|
||||
style:
|
||||
'*, *::before, *::after { animation: none !important; transition: none !important; caret-color: transparent !important; }',
|
||||
};
|
||||
|
||||
export async function captureStatic(page, options = {}) {
|
||||
await prepareStaticCapture(page);
|
||||
return page.screenshot({ ...options, ...staticScreenshotOptions });
|
||||
}
|
||||
Reference in New Issue
Block a user