fix: make contentFrame cross-frame handles test pass (#761)

This commit is contained in:
Yury Semikhatsky 2020-01-30 11:04:09 -08:00 committed by GitHub
parent eb568046eb
commit 603b9f54dd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 10 additions and 1 deletions

View File

@ -154,7 +154,7 @@ export class ElementHandle<T extends Node = Node> extends js.JSHandle<T> {
}
async contentFrame(): Promise<frames.Frame | null> {
const isFrameElement = await this._evaluateInUtility(node => node && (node instanceof HTMLIFrameElement || node instanceof HTMLFrameElement));
const isFrameElement = await this._evaluateInUtility(node => node && (node.nodeName === 'IFRAME' || node.nodeName === 'FRAME'));
if (!isFrameElement)
return null;
return this._page._delegate.getContentFrame(this);

View File

@ -381,5 +381,14 @@ module.exports.describe = function({testRunner, expect, FFOX, CHROMIUM, WEBKIT})
const error = await page.evaluate(body => body.innerHTML, bodyHandle).catch(e => e);
expect(error.message).toContain('Unable to adopt element handle from a different document');
});
it.skip(FFOX)('should return non-empty Node.constructor.name in utility context', async({page,server}) => {
await page.goto(server.EMPTY_PAGE);
await utils.attachFrame(page, 'frame1', server.EMPTY_PAGE);
const frame = page.frames()[1];
const context = await frame._utilityContext();
const elementHandle = await context.evaluateHandle(() => window.top.document.querySelector('#frame1'));
const constructorName = await context.evaluate(node => node.constructor.name, elementHandle);
expect(constructorName).toBe('HTMLIFrameElement');
});
});
};