From bf3a06fe23c76df1b00a04916ffe01193b1dcdae Mon Sep 17 00:00:00 2001 From: Yang Jun Date: Wed, 13 May 2026 01:06:51 +0800 Subject: [PATCH] test(context): assert scope isolation without probing prototypes Replace Object.getPrototypeOf checks for bottom() and getAll() with 'in' checks on typical Object.prototype names plus a merge assertion. Co-authored-by: Cursor --- src/context/context.spec.ts | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/src/context/context.spec.ts b/src/context/context.spec.ts index 20f8883e4..2692b0704 100644 --- a/src/context/context.spec.ts +++ b/src/context/context.spec.ts @@ -217,11 +217,16 @@ describe('Context', function () { }) }) describe('scope storage', function () { - it('should use null prototype for bottom scope', function () { - expect(Object.getPrototypeOf(new Context().bottom())).toBeNull() + it('should not treat Object.prototype properties as implicit keys on bottom scope', function () { + const bottom = new Context().bottom() as Record + expect('toString' in bottom).toBe(false) + expect('hasOwnProperty' in bottom).toBe(false) }) - it('should use null prototype for getAll() merge result', function () { - expect(Object.getPrototypeOf(new Context({ a: 1 }).getAll())).toBeNull() + it('should merge into a scope result without implicit Object.prototype keys', function () { + const all = new Context({ a: 1 }).getAll() as Record + expect(all.a).toBe(1) + expect('toString' in all).toBe(false) + expect('hasOwnProperty' in all).toBe(false) }) }) })