2020-07-03 22:43:08 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								describe ( "[[Get]] trap normal behavior" ,  ( )  =>  {  
						 
					
						
							
								
									
										
										
										
											2020-07-06 07:37:45 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    test ( "forwarding when not defined in handler" ,  ( )  =>  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        expect ( new  Proxy ( { } ,  {  get :  undefined  } ) . foo ) . toBeUndefined ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        expect ( new  Proxy ( { } ,  {  get :  null  } ) . foo ) . toBeUndefined ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        expect ( new  Proxy ( { } ,  { } ) . foo ) . toBeUndefined ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-06-03 14:34:52 -07:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								    } ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-07-06 07:37:45 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    test ( "correct arguments supplied to trap" ,  ( )  =>  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        let  o  =  { } ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        let  p  =  new  Proxy ( o ,  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            get ( target ,  property ,  receiver )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                expect ( target ) . toBe ( o ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                expect ( property ) . toBe ( "foo" ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                expect ( receiver ) . toBe ( p ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            } , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        } ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-06-03 14:34:52 -07:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-07-06 07:37:45 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        p . foo ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-07-03 22:43:08 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    } ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-07-05 09:27:00 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-07-05 01:59:50 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    test ( "correct arguments passed to trap even for number" ,  ( )  =>  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        let  o  =  { } ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        let  p  =  new  Proxy ( o ,  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            get ( target ,  property ,  receiver )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                expect ( target ) . toBe ( o ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                expect ( property ) . toBe ( "1" ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                expect ( receiver ) . toBe ( p ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            } , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        } ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        p [ 1 ] ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    } ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-07-06 07:37:45 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    test ( "conditional return" ,  ( )  =>  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        let  o  =  {  foo :  1  } ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        let  p  =  new  Proxy ( o ,  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            get ( target ,  property ,  receiver )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                if  ( property  ===  "bar" )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                    return  2 ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                }  else  if  ( property  ===  "baz" )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                    return  receiver . qux ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                }  else  if  ( property  ===  "qux" )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                    return  3 ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                return  target [ property ] ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            } , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        } ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        expect ( p . foo ) . toBe ( 1 ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        expect ( p . bar ) . toBe ( 2 ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        expect ( p . baz ) . toBe ( 3 ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        expect ( p . qux ) . toBe ( 3 ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        expect ( p . test ) . toBeUndefined ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-11-04 21:55:15 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        expect ( p [ Symbol . hasInstance ] ) . toBeUndefined ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-07-06 07:37:45 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    } ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-11-24 17:47:51 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    test ( "custom receiver value" ,  ( )  =>  { 
							 
						 
					
						
							
								
									
										
										
										
											2020-12-26 16:24:24 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        let  p  =  new  Proxy ( 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            { } , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                get ( target ,  property ,  receiver )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                    return  receiver ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                } , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-11-24 17:47:51 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        expect ( Reflect . get ( p ,  "foo" ,  42 ) ) . toBe ( 42 ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    } ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-07-03 22:43:08 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								} ) ;  
						 
					
						
							
								
									
										
										
										
											2020-06-03 14:34:52 -07:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-07-03 22:43:08 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								describe ( "[[Get]] invariants" ,  ( )  =>  {  
						 
					
						
							
								
									
										
										
										
											2020-07-06 07:37:45 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    test ( "returned value must match the target property value if the property is non-configurable and non-writable" ,  ( )  =>  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        let  o  =  { } ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        Object . defineProperty ( o ,  "foo" ,  {  value :  5 ,  configurable :  false ,  writable :  true  } ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        Object . defineProperty ( o ,  "bar" ,  {  value :  10 ,  configurable :  false ,  writable :  false  } ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-06-03 14:34:52 -07:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-07-06 07:37:45 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        let  p  =  new  Proxy ( o ,  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            get ( )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                return  8 ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            } , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        } ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        expect ( p . foo ) . toBe ( 8 ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        expect ( ( )  =>  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            p . bar ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        } ) . toThrowWithMessage ( 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            TypeError , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            "Proxy handler's get trap violates invariant: the returned value must match the value on the target if the property exists on the target as a non-writable, non-configurable own data property" 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-06-03 14:34:52 -07:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								    } ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-07-06 07:37:45 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    test ( "returned value must be undefined if the property is a non-configurable accessor with no getter" ,  ( )  =>  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        let  o  =  { } ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        Object . defineProperty ( o ,  "foo" ,  {  configurable :  false ,  set ( _ )  { }  } ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-07-05 09:27:00 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-07-06 07:37:45 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        let  p  =  new  Proxy ( o ,  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            get ( )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                return  8 ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            } , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        } ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-06-03 14:34:52 -07:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-07-06 07:37:45 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        expect ( ( )  =>  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            p . foo ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        } ) . toThrowWithMessage ( 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            TypeError , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            "Proxy handler's get trap violates invariant: the returned value must be undefined if the property exists on the target as a non-configurable accessor property with an undefined get attribute" 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-07-05 09:27:00 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    } ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-07-03 22:43:08 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								} ) ;  
						 
					
						
							
								
									
										
										
										
											2021-09-05 20:21:58 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								test ( "Proxy handler that has the Proxy itself as its prototype" ,  ( )  =>  {  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    const  handler  =  { } ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    const  proxy  =  new  Proxy ( { } ,  handler ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    handler . _ _proto _ _  =  proxy ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    expect ( ( )  =>  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        proxy . foo ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    } ) . toThrowWithMessage ( Error ,  "Call stack size limit exceeded" ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								} ) ;