Skip to content

Playwright is a framework for Web Testing and Automation. It allows testing Chromium, Firefox and WebKit with a single API.

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

Yury Semikhatsky603b9f54dda6
diff --git a/src/dom.ts b/src/dom.ts
index 875a032240..1efbe3e855 100644
--- a/src/dom.ts
+++ b/src/dom.ts
@@ -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);
diff --git a/test/evaluation.spec.js b/test/evaluation.spec.js
index f092e33926..097f34f9e8 100644
--- a/test/evaluation.spec.js
+++ b/test/evaluation.spec.js
@@ -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');
+ });
});
};