test: assert null-prototype registries vs all Object.prototype keys

Co-authored-by: Cursor <[email protected]>
This commit is contained in:
Yang Jun
2026-05-12 01:03:40 +08:00
co-authored by Cursor
parent 0078a0d01f
commit f4bfd03b49
3 changed files with 36 additions and 32 deletions
+8 -7
View File
@@ -77,15 +77,16 @@ describe('Issues', function () {
)
expect(html).toBe('BAR')
})
it('filter/tag lookup must not inherit Object.prototype (node + UMD)', async () => {
const tpl = '{% assign r = 1 | valueOf %}{{ r.context }}{{ r.liquid }}{{ r.token }}|{{ r }}'
it('filter/tag maps are null-prototype; built-ins work (node + UMD)', async () => {
const tpl = `{{ 'a' | append: 'b' }}`
const nodeEngine = new Liquid()
expect(await nodeEngine.parseAndRender(tpl)).toBe('|1')
expect(() => nodeEngine.parse('{% constructor %}')).toThrow('tag "constructor" not found')
const umdEngine = new LiquidUMD()
expect(await umdEngine.parseAndRender(tpl)).toBe('|1')
expect(() => umdEngine.parse('{% constructor %}')).toThrow('tag "constructor" not found')
expect(Object.getPrototypeOf(nodeEngine.filters)).toBeNull()
expect(Object.getPrototypeOf(nodeEngine.tags)).toBeNull()
expect(Object.getPrototypeOf(umdEngine.filters)).toBeNull()
expect(Object.getPrototypeOf(umdEngine.tags)).toBeNull()
expect(await nodeEngine.parseAndRender(tpl)).toBe('ab')
expect(await umdEngine.parseAndRender(tpl)).toBe('ab')
})
it('lenientIf not working as expected in umd #313', async () => {
const engine = new LiquidUMD({