2020-07-03 22:43:08 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								describe ( "[[Has]] trap normal behavior" ,  ( )  =>  {  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    test ( "forwarding when not defined in handler" ,  ( )  =>  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        expect ( "foo"  in  new  Proxy ( { } ,  {  has :  null  } ) ) . toBe ( false ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        expect ( "foo"  in  new  Proxy ( { } ,  {  has :  undefined } ) ) . toBe ( false ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        expect ( "foo"  in  new  Proxy ( { } ,  { } ) ) . toBe ( false ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-06-03 14:34:52 -07:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								    } ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-07-03 22:43:08 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    test ( "correct arguments supplied to trap" ,  ( )  =>  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        let  o  =  { } ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        let  p  =  new  Proxy ( o ,  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            has ( target ,  prop )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                expect ( target ) . toBe ( o ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                expect ( prop ) . toBe ( "foo" ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-06-03 14:34:52 -07:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								                return  true ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-07-03 22:43:08 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        } ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-06-03 14:34:52 -07:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-07-03 22:43:08 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        "foo"  in  p ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    } ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-06-03 14:34:52 -07:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-07-03 22:43:08 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    test ( "conditional return" ,  ( )  =>  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        let  o  =  { } ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        let  p  =  new  Proxy ( o ,  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            has ( target ,  prop )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                if  ( target . checkedFoo ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                    return  true ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                if  ( prop  ===  "foo" ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                    target . checkedFoo  =  true ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                return  false ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        } ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-06-03 14:34:52 -07:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-07-03 22:43:08 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        expect ( "foo"  in  p ) . toBe ( false ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        expect ( "foo"  in  p ) . toBe ( true ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-06-03 14:34:52 -07:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								    } ) ; 
							 
						 
					
						
							
								
									
										
										
										
											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 ( "[[Has]] invariants" ,  ( )  =>  {  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    test ( "cannot return false if the property exists and is non-configurable" ,  ( )  =>  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        let  o  =  { } ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        Object . defineProperty ( o ,  "foo" ,  {  configurable :  false  } ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-06-03 14:34:52 -07:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-07-03 22:43:08 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        p  =  new  Proxy ( o ,  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            has ( )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                return  false ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        } ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-06-03 14:34:52 -07:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-07-03 22:43:08 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        expect ( ( )  =>  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            "foo"  in  p ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        } ) . toThrowWithMessage ( TypeError ,  "Proxy handler's has trap violates invariant: a property cannot be reported as non-existent if it exists on the target as a non-configurable property" ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-06-03 14:34:52 -07:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								    } ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-07-03 22:43:08 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    test ( "cannot return false if the property exists and the target is non-extensible" ,  ( )  =>  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        let  o  =  { } ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        Object . defineProperty ( o ,  "foo" ,  {  value :  10 ,  configurable :  true  } ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        let  p  =  new  Proxy ( o ,  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            has ( )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                return  false ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        } ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        Object . preventExtensions ( o ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        expect ( ( )  =>  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            "foo"  in  p ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        } ) . toThrowWithMessage ( TypeError ,  "Proxy handler's has trap violates invariant: a property cannot be reported as non-existent if it exists on the target and the target is non-extensible" ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    } ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								} ) ;