fix: use content box for OOPIF offset calculations (#7911)

If an iframe has a border, it has to be added to the offsets
too. We can work around it by using the content box coordinates
for the offsets. That should also prevent discrepancies if the
iframe has a padding set.
This commit is contained in:
Alex Rudenko 2022-01-18 09:22:15 +01:00 committed by GitHub
parent c09522a5f2
commit 344feb53c2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -489,14 +489,14 @@ export class ElementHandle<
const { backendNodeId } = await parent._client.send('DOM.getFrameOwner', {
frameId: frame._id,
});
const { quads } = await parent._client.send('DOM.getContentQuads', {
const result = await parent._client.send('DOM.getBoxModel', {
backendNodeId: backendNodeId,
});
if (!quads || !quads.length) {
if (!result) {
break;
}
const protocolQuads = quads.map((quad) => this._fromProtocolQuad(quad));
const topLeftCorner = protocolQuads[0][0];
const contentBoxQuad = result.model.content;
const topLeftCorner = this._fromProtocolQuad(contentBoxQuad)[0];
offsetX += topLeftCorner.x;
offsetY += topLeftCorner.y;
frame = parent;