From f25a27a0a491a191c5b3a5aea754cb137f1bba34 Mon Sep 17 00:00:00 2001 From: Dmitry Gozman Date: Tue, 11 Feb 2020 17:04:49 -0800 Subject: [PATCH] test: add a test for bounding box with page scale (#935) Does not work on WebKit, because it uses device-independent pixels instead of css pixels for content quads. --- test/elementhandle.spec.js | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/test/elementhandle.spec.js b/test/elementhandle.spec.js index 4a8efb9de2..c83d95ad6d 100644 --- a/test/elementhandle.spec.js +++ b/test/elementhandle.spec.js @@ -68,6 +68,24 @@ module.exports.describe = function({testRunner, expect, FFOX, CHROMIUM, WEBKIT}) }, element); expect(pwBoundingBox).toEqual(webBoundingBox); }); + it.skip(WEBKIT)('should work with page scale', async({newPage, server}) => { + const page = await newPage({ viewport: { width: 400, height: 400, isMobile: true} }); + await page.goto(server.PREFIX + '/input/button.html'); + const button = await page.$('button'); + await button.evaluate(button => { + document.body.style.margin = '0'; + button.style.borderWidth = '0'; + button.style.width = '200px'; + button.style.height = '20px'; + button.style.marginLeft = '17px'; + button.style.marginTop = '23px'; + }); + const box = await button.boundingBox(); + expect(Math.round(box.x * 100)).toBe(17 * 100); + expect(Math.round(box.y * 100)).toBe(23 * 100); + expect(Math.round(box.width * 100)).toBe(200 * 100); + expect(Math.round(box.height * 100)).toBe(20 * 100); + }); }); describe('ElementHandle.contentFrame', function() {