@@ -303,8 +303,8 @@ describe("沙盒环境测试", async () => {
303303 // });
304304
305305 // 在模拟环境无法测试:在实际操作中和TM一致
306- // 在非拦截式沙盒裡删除 沙盒onload 后,会取得页面的真onload
307- // 在非拦截式沙盒裡删除 真onload 后,会变undefined
306+ // 在非拦截式沙盒里删除 沙盒onload 后,会取得页面的真onload
307+ // 在非拦截式沙盒里删除 真onload 后,会变undefined
308308 // it.concurrent("删除 onload 后应该为 null", () => {
309309 // const mockFn = vi.fn();
310310 // _this["onload"] = function thisOnLoad() {
@@ -376,33 +376,58 @@ describe("沙盒环境测试", async () => {
376376
377377 it . concurrent ( "[兼容问题] Ensure Illegal invocation can be tested" , ( ) => {
378378 expect ( global . setTimeout . name ) . toEqual ( "setTimeout" ) ;
379+ // -----
379380 //@ts -ignore
380- expect ( global . setTimeoutForTest . name ) . toEqual ( "setTimeoutForTest " ) ;
381- expect ( _this . setTimeoutForTest . name ) . toEqual ( "bound setTimeoutForTest " ) ;
381+ expect ( global . setTimeoutForTest1 . name ) . toEqual ( "setTimeoutForTest1 " ) ;
382+ expect ( _this . setTimeoutForTest1 . name ) . toEqual ( "bound setTimeoutForTest1 " ) ;
382383 //@ts -ignore
383384 expect ( ( ) => global . setTimeout . call ( global , ( ) => { } , 1 ) ) . not . toThrow ( ) ;
384385 //@ts -ignore
385- expect ( ( ) => global . setTimeoutForTest . call ( global , ( ) => { } , 1 ) ) . not . toThrow ( ) ;
386+ expect ( ( ) => global . setTimeoutForTest1 . call ( global , ( ) => { } , 1 ) ) . not . toThrow ( ) ;
386387 //@ts -ignore
387- expect ( ( ) => global . setTimeoutForTest . call ( { } , ( ) => { } , 1 ) ) . toThrow ( ) ;
388+ expect ( ( ) => global . setTimeoutForTest1 . call ( { } , ( ) => { } , 1 ) ) . toThrow ( ) ;
389+ // -----
390+ //@ts -ignore
391+ expect ( global . setTimeoutForTest2 . name ) . toEqual ( "setTimeoutForTest2" ) ;
392+ expect ( _this . setTimeoutForTest2 . name ) . toEqual ( "bound setTimeoutForTest2" ) ;
393+ //@ts -ignore
394+ expect ( ( ) => global . setTimeout . call ( global , ( ) => { } , 1 ) ) . not . toThrow ( ) ;
395+ //@ts -ignore
396+ expect ( ( ) => global . setTimeoutForTest2 . call ( global , ( ) => { } , 1 ) ) . not . toThrow ( ) ;
397+ //@ts -ignore
398+ expect ( ( ) => global . setTimeoutForTest2 . call ( { } , ( ) => { } , 1 ) ) . toThrow ( ) ;
388399 } ) ;
389400 // https://github.com/xcanwin/KeepChatGPT 环境隔离得不够干净导致的
390401 it . concurrent ( "[兼容问题] Uncaught TypeError: Illegal invocation #189" , ( ) => {
391- // setTimeout 和 setTimeoutForTest 都測試吧
402+ // setTimeout 和 setTimeoutForTest1 都测试吧
392403 const promise1 = new Promise ( ( resolve ) => {
393404 console . log ( _this . setTimeout . prototype ) ;
394- _this . setTimeoutForTest ( resolve , 1 ) ;
405+ _this . setTimeoutForTest1 ( resolve , 1 ) ;
395406 } ) ;
396407 const promise2 = new Promise ( ( resolve ) => {
397408 console . log ( _this . setTimeout . prototype ) ;
398409 _this . setTimeout ( resolve , 1 ) ;
399410 } ) ;
400- expect ( Promise . all ( [ promise1 , promise2 ] ) . then ( ( ) => "ok" ) ) . resolves . toBe ( "ok" ) ;
411+ const res = Promise . all ( [ promise1 , promise2 ] ) ;
412+ expect ( res . then ( ( res ) => ( ! res [ 0 ] && ! res [ 1 ] ? "ok" : "ng" ) ) ) . resolves . toBe ( "ok" ) ;
401413 } ) ;
402414 // AC-baidu-重定向优化百度搜狗谷歌必应搜索_favicon_双列
403415 it . concurrent ( "[兼容问题] TypeError: Object.freeze is not a function #116" , ( ) => {
404416 expect ( ( ) => _this . Object . freeze ( { } ) ) . not . toThrow ( ) ;
405417 } ) ;
418+ it . concurrent ( "Proxy Function #985" , ( ) => {
419+ // setTimeout 和 setTimeoutForTest2 都测试吧
420+ const promise1 = new Promise ( ( resolve ) => {
421+ console . log ( _this . setTimeout . prototype ) ;
422+ _this . setTimeoutForTest2 ( resolve , 1 ) ;
423+ } ) ;
424+ const promise2 = new Promise ( ( resolve ) => {
425+ console . log ( _this . setTimeout . prototype ) ;
426+ _this . setTimeout ( resolve , 1 ) ;
427+ } ) ;
428+ const res = Promise . all ( [ promise1 , promise2 ] ) ;
429+ expect ( res . then ( ( res ) => ( res [ 0 ] === "proxy" && ! res [ 1 ] ? "ok" : "ng" ) ) ) . resolves . toBe ( "ok" ) ;
430+ } ) ;
406431
407432 const tag = ( < any > global ) [ Symbol . toStringTag ] ; // 实际环境:'[object Window]' 测试环境:'[object global]'
408433
0 commit comments