Skip to content

Commit 04dbdb2

Browse files
committed
✅ 修复测试问题
1 parent e516058 commit 04dbdb2

2 files changed

Lines changed: 7 additions & 3 deletions

File tree

‎pkg/chrome-extension-mock/web_reqeuest.ts‎

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,10 @@ export default class WebRequest {
44
) => chrome.webRequest.BlockingResponse | void;
55

66
mockXhr(xhr: any): any {
7-
return () => {
7+
// eslint-disable-next-line no-underscore-dangle
8+
const _this = this;
9+
// eslint-disable-next-line func-names
10+
return function () {
811
// eslint-disable-next-line new-cap
912
const ret = new xhr();
1013
const header: chrome.webRequest.HttpHeader[] = [];
@@ -20,7 +23,7 @@ export default class WebRequest {
2023
name: "cookie",
2124
value: "website=example.com",
2225
});
23-
const resp = this.sendHeader?.({
26+
const resp = _this.sendHeader?.({
2427
method: ret.method,
2528
url: ret.url,
2629
requestHeaders: header,

‎src/runtime/gm_api.test.ts‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -313,8 +313,9 @@ describe("GM xmlHttpRequest", () => {
313313
});
314314
});
315315
});
316+
316317
it("unsafeHeader/cookie", async () => {
317-
global.XMLHttpRequest = chromeMock.webRequest.mockXhr(mockXhr);
318+
// global.XMLHttpRequest = chromeMock.webRequest.mockXhr(mockXhr);
318319
// 模拟header
319320
await new Promise<void>((resolve) => {
320321
contentApi.GM_xmlhttpRequest({

0 commit comments

Comments
 (0)