添加测试
Some checks failed
build / Build (push) Failing after 7s
test / Run tests (push) Failing after 10s
Some checks failed
build / Build (push) Failing after 7s
test / Run tests (push) Failing after 10s
This commit is contained in:
@ -39,7 +39,7 @@ export default class LoggerCore {
|
||||
this.labels = config.labels || {};
|
||||
// 获取日志debug等级, 如果是开发环境, 则默认为trace
|
||||
if (process.env.NODE_ENV === "development") {
|
||||
this.debug = "trace";
|
||||
this.debug = "debug";
|
||||
}
|
||||
if (!LoggerCore.instance) {
|
||||
LoggerCore.instance = this;
|
||||
|
@ -13,6 +13,7 @@ export class GMApi {
|
||||
}
|
||||
}
|
||||
xhr.onload = function () {
|
||||
console.log(xhr.getAllResponseHeaders());
|
||||
con?.sendMessage({
|
||||
action: "onload",
|
||||
data: {
|
||||
|
@ -83,6 +83,7 @@ export class Runtime {
|
||||
return this.execScript(script);
|
||||
} else {
|
||||
// 定时脚本加入定时任务
|
||||
await this.stopCronJob(script.uuid);
|
||||
return this.crontabScript(script);
|
||||
}
|
||||
}
|
||||
|
@ -148,10 +148,17 @@ export default class GMApi {
|
||||
}
|
||||
params.headers["X-Scriptcat-GM-XHR-Request-Id"] = requestId.toString();
|
||||
await this.buildDNRRule(requestId, request.params[0]);
|
||||
let responseHeader = "";
|
||||
// 等待response
|
||||
this.gmXhrHeadersReceived.addListener("headersReceived:" + requestId, (details) => {
|
||||
console.log("处理", details);
|
||||
});
|
||||
this.gmXhrHeadersReceived.addListener(
|
||||
"headersReceived:" + requestId,
|
||||
(details: chrome.webRequest.WebResponseHeadersDetails) => {
|
||||
details.responseHeaders?.forEach((header) => {
|
||||
responseHeader += header.name + ": " + header.value + "\n";
|
||||
});
|
||||
console.log("处理", details, responseHeader);
|
||||
}
|
||||
);
|
||||
// 再发送到offscreen, 处理请求
|
||||
const offscreenCon = await connect(this.sender, "gmApi/xmlHttpRequest", request.params[0]);
|
||||
offscreenCon.onMessage((msg) => {
|
||||
|
@ -219,6 +219,9 @@ export default class GMApi {
|
||||
let connect: MessageConnect;
|
||||
this.connect("GM_xmlhttpRequest", [param]).then((con) => {
|
||||
connect = con;
|
||||
con.onMessage((data) => {
|
||||
console.log("data", data);
|
||||
});
|
||||
});
|
||||
|
||||
return {
|
||||
|
@ -1,3 +1,4 @@
|
||||
import { describe, expect, it } from "vitest";
|
||||
import { init, proxyContext, writables } from "./utils";
|
||||
|
||||
describe("proxy context", () => {
|
||||
|
16
src/runtime/gm_api.test.ts
Normal file
16
src/runtime/gm_api.test.ts
Normal file
@ -0,0 +1,16 @@
|
||||
import { fakeBrowser } from "@webext-core/fake-browser";
|
||||
import { it } from "node:test";
|
||||
import initTestEnv from "@Tests/utils";
|
||||
import { beforeEach, describe, expect } from "vitest";
|
||||
|
||||
initTestEnv();
|
||||
|
||||
describe("GM xhr", () => {
|
||||
beforeEach(() => {
|
||||
// See https://webext-core.aklinker1.io/fake-browser/reseting-state
|
||||
fakeBrowser.reset();
|
||||
});
|
||||
it("1", async () => {
|
||||
expect(1).toBe(2);
|
||||
});
|
||||
});
|
Reference in New Issue
Block a user