fix: CI Node 18/20 下 aria-crypto 失败 — SubtleCrypto 跨 realm ArrayBuffer 兼容
- crypto.ts encryptPage/decryptPage 改传 TypedArray 视图(ArrayBuffer.isView 检查跨 realm 可靠)
- jest.setup.js structuredClone polyfill 用跨 realm toString 标签检查
(修复 fake-indexeddb 存储 ArrayBuffer 被 JSON 破坏成 {} 的问题)
- 新增 SSTable 加密真实路径测试(加密落盘→重载解密, 8 个测试)
- aria/v025 固定 db 名改随机(fake-indexeddb 真实持久化后防表残留冲突)
- Node 18/20/22/24 全矩阵 837 测试通过
This commit is contained in:
+10
-1
@@ -1,6 +1,15 @@
|
||||
// jest setup: polyfill structuredClone for fake-indexeddb
|
||||
if (typeof globalThis.structuredClone !== 'function') {
|
||||
globalThis.structuredClone = (obj) => JSON.parse(JSON.stringify(obj));
|
||||
// 注意:不能用 JSON 序列化 —— ArrayBuffer/TypedArray 会被破坏成 {},
|
||||
// fake-indexeddb 存储 AriaEngine 二进制页面(4KB SSTable/WAL)依赖正确的克隆。
|
||||
// 且不能依赖 instanceof(TextEncoder 产生 node realm 的 ArrayBuffer,
|
||||
// 与 jsdom realm 的构造函数不匹配),需用跨 realm 的 toString 标签检查。
|
||||
globalThis.structuredClone = (obj) => {
|
||||
const tag = Object.prototype.toString.call(obj);
|
||||
if (tag === '[object ArrayBuffer]') return obj.slice(0);
|
||||
if (ArrayBuffer.isView(obj)) return new obj.constructor(obj);
|
||||
return JSON.parse(JSON.stringify(obj));
|
||||
};
|
||||
}
|
||||
|
||||
// polyfill TextEncoder/TextDecoder for jsdom environment
|
||||
|
||||
Reference in New Issue
Block a user