Browse Source

fix: Check for duplicate entries returned by the 'ownKeys' proxy trap

Dmitry Panov 4 năm trước cách đây
mục cha
commit
1bf71b1daa
2 tập tin đã thay đổi với 5 bổ sung1 xóa
  1. 3 0
      proxy.go
  2. 2 1
      tc39_test.go

+ 3 - 0
proxy.go

@@ -566,6 +566,9 @@ func (p *proxyObject) proxyOwnKeys() ([]Value, bool) {
 					panic(p.val.runtime.NewTypeError("%s is not a valid property name", item.String()))
 				}
 			}
+			if _, exists := keySet[item]; exists {
+				panic(p.val.runtime.NewTypeError("'ownKeys' on proxy: trap returned duplicate entries"))
+			}
 			keyList = append(keyList, item)
 			keySet[item] = struct{}{}
 		}

+ 2 - 1
tc39_test.go

@@ -327,6 +327,7 @@ var (
 		"sec-object.getownpropertydescriptor",
 		"sec-object.getownpropertydescriptors",
 		"sec-object.entries",
+		"sec-proxy-object-internal-methods-and-internal-slots-ownpropertykeys",
 	}
 )
 
@@ -695,7 +696,7 @@ func TestTC39(t *testing.T) {
 	// Tests ignored: 10,453, passed: 14,782
 
 	// at ddfe24afe3043388827aa220ef623b8540958bbd
-	// Tests ignored: 19,212, passed: 14,483
+	// Tests ignored: 19,183, passed: 14,512
 
 	ctx := &tc39TestCtx{
 		base: tc39BASE,