fix(getProperties): return empty map for non-objects (#470)
This commit is contained in:
parent
98bf9ac1d5
commit
88a11a3fbd
|
|
@ -113,9 +113,12 @@ export class FFExecutionContext implements js.ExecutionContextDelegate {
|
||||||
}
|
}
|
||||||
|
|
||||||
async getProperties(handle: js.JSHandle): Promise<Map<string, js.JSHandle>> {
|
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', {
|
const response = await this._session.send('Runtime.getObjectProperties', {
|
||||||
executionContextId: this._executionContextId,
|
executionContextId: this._executionContextId,
|
||||||
objectId: handle._remoteObject.objectId,
|
objectId,
|
||||||
});
|
});
|
||||||
const result = new Map();
|
const result = new Map();
|
||||||
for (const property of response.properties)
|
for (const property of response.properties)
|
||||||
|
|
|
||||||
|
|
@ -115,6 +115,11 @@ module.exports.describe = function({testRunner, expect, CHROMIUM, FFOX, WEBKIT})
|
||||||
expect(foo).toBeTruthy();
|
expect(foo).toBeTruthy();
|
||||||
expect(await foo.jsonValue()).toBe('bar');
|
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}) => {
|
it('should return even non-own properties', async({page, server}) => {
|
||||||
const aHandle = await page.evaluateHandle(() => {
|
const aHandle = await page.evaluateHandle(() => {
|
||||||
class A {
|
class A {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue