From 84ee297c4bbfaa2f3107c6821953194d210f1e12 Mon Sep 17 00:00:00 2001 From: Dmitry Gozman Date: Wed, 19 Feb 2020 14:08:29 -0800 Subject: [PATCH] test: add a test for bounding box on partially visible element (#1011) --- test/elementhandle.spec.js | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/test/elementhandle.spec.js b/test/elementhandle.spec.js index 67c96bcc10..6769eecbd2 100644 --- a/test/elementhandle.spec.js +++ b/test/elementhandle.spec.js @@ -86,6 +86,34 @@ module.exports.describe = function({testRunner, expect, FFOX, CHROMIUM, WEBKIT}) expect(Math.round(box.width * 100)).toBe(200 * 100); expect(Math.round(box.height * 100)).toBe(20 * 100); }); + it('should work when inline box child is outside of viewport', async({page, server}) => { + await page.setContent(` + + woofdoggo + `); + const handle = await page.$('span'); + const box = await handle.boundingBox(); + const webBoundingBox = await handle.evaluate(e => { + const rect = e.getBoundingClientRect(); + return {x: rect.x, y: rect.y, width: rect.width, height: rect.height}; + }); + const round = box => ({ + x: Math.round(box.x * 100), + y: Math.round(box.y * 100), + width: Math.round(box.width * 100), + height: Math.round(box.height * 100), + }); + expect(round(box)).toEqual(round(webBoundingBox)); + }); }); describe('ElementHandle.contentFrame', function() {