Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 21 additions & 1 deletion tests/page/jshandle-properties.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ it('getProperties should return empty map for non-objects', async ({ page }) =>
expect(properties.size).toBe(0);
});

it('getProperties should return even non-own properties', async ({ page }) => {
it('getProperties should return properties inhertied from super class', async ({ page }) => {
const aHandle = await page.evaluateHandle(() => {
class A {
a: string;
Expand All @@ -96,6 +96,26 @@ it('getProperties should return even non-own properties', async ({ page }) => {
expect(await properties.get('b').jsonValue()).toBe('2');
});

it('getProperties should return own enumerable properties only', {
annotation: { type: 'issue', description: 'https://github.com/microsoft/playwright/issues/42651' },
}, async ({ page }) => {
const aHandle = await page.evaluateHandle(() => {
class A {
constructor() {
(this as any).own = 1;
Object.defineProperty(this, 'ownHidden', { value: 2, enumerable: false });
}
}
(A.prototype as any).inherited = 3;
return new A();
});
expect([...(await aHandle.getProperties()).keys()]).toEqual(['own']);

await page.setContent('<div id=d><span>a</span><span>b</span></div>');
const collection = await page.evaluateHandle(() => document.querySelector('#d').children);
expect([...(await collection.getProperties()).keys()]).toEqual(['0', '1']);
});

it('getProperties should work with elements', async ({ page }) => {
await page.setContent(`<div>Hello</div>`);
const handle = await page.evaluateHandle(() => ({ body: document.body }));
Expand Down
Loading