fix(getProperties): return empty map for non-objects (#470)

This commit is contained in:
Dmitry Gozman 2020-01-13 15:36:22 -08:00 committed by Yury Semikhatsky
parent 98bf9ac1d5
commit 88a11a3fbd
2 changed files with 9 additions and 1 deletions

View File

@ -113,9 +113,12 @@ export class FFExecutionContext implements js.ExecutionContextDelegate {
}
async getProperties(handle: js.JSHandle): Promise<Map<string, js.JSHandle>> {
const objectId = handle._remoteObject.objectId;
if (!objectId)
return new Map();
const response = await this._session.send('Runtime.getObjectProperties', {
executionContextId: this._executionContextId,
objectId: handle._remoteObject.objectId,
objectId,
});
const result = new Map();
for (const property of response.properties)

View File

@ -115,6 +115,11 @@ module.exports.describe = function({testRunner, expect, CHROMIUM, FFOX, WEBKIT})
expect(foo).toBeTruthy();
expect(await foo.jsonValue()).toBe('bar');
});
it('should return empty map for non-objects', async({page, server}) => {
const aHandle = await page.evaluateHandle(() => 123);
const properties = await aHandle.getProperties();
expect(properties.size).toBe(0);
});
it('should return even non-own properties', async({page, server}) => {
const aHandle = await page.evaluateHandle(() => {
class A {