清理冗余代码:删除未使用变量、types.ts 改为 .d.ts、测试路径改引 dist/
- 删除未使用的 getActiveEnv 解构、sender 参数改为 _sender - types.ts 重命名为 types.d.ts,消除无用的 dist/types.js 产物 - 测试文件引用路径从根目录改为 dist/
This commit is contained in:
@@ -35,7 +35,7 @@ function createMockDoc(elements) {
|
||||
|
||||
// 加载 content.js 到 vm 沙箱,返回沙箱上下文
|
||||
function loadContentJs(mockDoc) {
|
||||
const code = fs.readFileSync(path.join(__dirname, "..", "content.js"), "utf8");
|
||||
const code = fs.readFileSync(path.join(__dirname, "..", "dist", "content.js"), "utf8");
|
||||
const sandbox = {
|
||||
URL: globalThis.URL,
|
||||
window: { location: { href: "https://example.com/login" } },
|
||||
@@ -62,7 +62,7 @@ function loadContentJs(mockDoc) {
|
||||
sandbox.globalThis = sandbox;
|
||||
vm.createContext(sandbox);
|
||||
// 先加载 utils.js
|
||||
const utilsCode = fs.readFileSync(path.join(__dirname, "..", "utils.js"), "utf8");
|
||||
const utilsCode = fs.readFileSync(path.join(__dirname, "..", "dist", "utils.js"), "utf8");
|
||||
vm.runInContext(utilsCode, sandbox);
|
||||
vm.runInContext(code, sandbox);
|
||||
return sandbox;
|
||||
|
||||
Reference in New Issue
Block a user