add onImageAdded to api

This commit is contained in:
Anthony Kim
2026-03-03 12:19:14 -08:00
parent dedf3b1595
commit d6c872bb2c
5 changed files with 38 additions and 1 deletions
@@ -2159,6 +2159,19 @@ test.describe('Kitty Graphics Protocol', () => {
strictEqual(await ctx.page.evaluate(`window.imageAddon._storage._images.has(${oldStorageId})`), false);
});
});
test.describe('onImageAdded callback', () => {
test('onImageAdded fires for each kitty image', async () => {
await ctx.page.evaluate(`
window._imageAddedCount = 0;
window.imageAddon.onImageAdded(() => { window._imageAddedCount++; });
`);
await ctx.proxy.write(`\x1b_Ga=T,f=100;${KITTY_BLACK_1X1_BASE64}\x1b\\`);
await pollFor(ctx.page, 'window._imageAddedCount', 1);
await ctx.proxy.write(`\x1b_Ga=T,f=100;${KITTY_RGB_3X1_BASE64}\x1b\\`);
await pollFor(ctx.page, 'window._imageAddedCount', 2);
});
});
});
/**