|
1 | | -import { init, proxyContext } from "./utils"; |
| 1 | +import { init, proxyContext, writables } from "./utils"; |
2 | 2 |
|
3 | | -describe('proxy context', () => { |
4 | | - const context: any = {}; |
5 | | - const global: any = { |
6 | | - gbok: 'gbok', |
7 | | - onload: null, |
8 | | - eval: () => { |
9 | | - console.log('eval'); |
10 | | - }, |
11 | | - }; |
12 | | - init.set('onload', true); |
13 | | - init.set('gbok', true); |
14 | | - const _this = proxyContext(global, context); |
| 3 | +describe("proxy context", () => { |
| 4 | + const context: any = {}; |
| 5 | + const global: any = { |
| 6 | + gbok: "gbok", |
| 7 | + onload: null, |
| 8 | + eval: () => { |
| 9 | + console.log("eval"); |
| 10 | + }, |
| 11 | + }; |
| 12 | + init.set("onload", true); |
| 13 | + init.set("gbok", true); |
| 14 | + const _this = proxyContext(global, context); |
15 | 15 |
|
16 | | - it('set contenxt', () => { |
17 | | - _this['md5'] = 'ok'; |
18 | | - expect(_this['md5']).toEqual('ok'); |
19 | | - expect(global['md5']).toEqual(undefined); |
20 | | - }); |
| 16 | + it("set contenxt", () => { |
| 17 | + _this["md5"] = "ok"; |
| 18 | + expect(_this["md5"]).toEqual("ok"); |
| 19 | + expect(global["md5"]).toEqual(undefined); |
| 20 | + }); |
21 | 21 |
|
22 | | - it('set window null', () => { |
23 | | - _this['onload'] = 'ok'; |
24 | | - expect(_this['onload']).toEqual('ok'); |
25 | | - expect(context['onload']).toEqual(undefined); |
26 | | - expect(global['onload']).toEqual('ok'); |
27 | | - }); |
| 22 | + it("set window null", () => { |
| 23 | + _this["onload"] = "ok"; |
| 24 | + expect(_this["onload"]).toEqual("ok"); |
| 25 | + expect(context["onload"]).toEqual(undefined); |
| 26 | + expect(global["onload"]).toEqual("ok"); |
| 27 | + }); |
28 | 28 |
|
29 | | - it('update', () => { |
30 | | - _this['okk'] = 'ok'; |
31 | | - expect(_this['okk']).toEqual('ok'); |
32 | | - expect(global['okk']).toEqual(undefined); |
33 | | - _this['okk'] = 'ok2'; |
34 | | - expect(_this['okk']).toEqual('ok2'); |
35 | | - expect(global['okk']).toEqual(undefined); |
36 | | - }); |
| 29 | + it("update", () => { |
| 30 | + _this["okk"] = "ok"; |
| 31 | + expect(_this["okk"]).toEqual("ok"); |
| 32 | + expect(global["okk"]).toEqual(undefined); |
| 33 | + _this["okk"] = "ok2"; |
| 34 | + expect(_this["okk"]).toEqual("ok2"); |
| 35 | + expect(global["okk"]).toEqual(undefined); |
| 36 | + }); |
37 | 37 |
|
38 | | - it('访问global的对象', () => { |
39 | | - expect(_this['gbok']).toEqual('gbok'); |
40 | | - }); |
| 38 | + it("访问global的对象", () => { |
| 39 | + expect(_this["gbok"]).toEqual("gbok"); |
| 40 | + }); |
| 41 | +}); |
| 42 | + |
| 43 | +describe("兼容问题", () => { |
| 44 | + console.log("ok"); |
| 45 | + const _this = proxyContext({}, {}); |
| 46 | + // https://github.com/xcanwin/KeepChatGPT 环境隔离得不够干净导致的 |
| 47 | + it("Uncaught TypeError: Illegal invocation #189", () => { |
| 48 | + return new Promise((resolve) => { |
| 49 | + console.log(_this.setTimeout.prototype); |
| 50 | + _this.setTimeout(resolve, 100); |
| 51 | + }); |
| 52 | + }); |
| 53 | + // AC-baidu-重定向优化百度搜狗谷歌必应搜索_favicon_双列 |
| 54 | + it("TypeError: Object.freeze is not a function #116", () => { |
| 55 | + expect(() => _this.Object.freeze({})).not.toThrow(); |
| 56 | + }); |
41 | 57 | }); |
0 commit comments