Skip to content

Commit 84ee297

Browse files
authored
test: add a test for bounding box on partially visible element (#1011)
1 parent 4be48a6 commit 84ee297

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

test/elementhandle.spec.js

+28
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,34 @@ module.exports.describe = function({testRunner, expect, FFOX, CHROMIUM, WEBKIT})
8686
expect(Math.round(box.width * 100)).toBe(200 * 100);
8787
expect(Math.round(box.height * 100)).toBe(20 * 100);
8888
});
89+
it('should work when inline box child is outside of viewport', async({page, server}) => {
90+
await page.setContent(`
91+
<style>
92+
i {
93+
position: absolute;
94+
top: -1000px;
95+
}
96+
body {
97+
margin: 0;
98+
font-size: 12px;
99+
}
100+
</style>
101+
<span><i>woof</i><b>doggo</b></span>
102+
`);
103+
const handle = await page.$('span');
104+
const box = await handle.boundingBox();
105+
const webBoundingBox = await handle.evaluate(e => {
106+
const rect = e.getBoundingClientRect();
107+
return {x: rect.x, y: rect.y, width: rect.width, height: rect.height};
108+
});
109+
const round = box => ({
110+
x: Math.round(box.x * 100),
111+
y: Math.round(box.y * 100),
112+
width: Math.round(box.width * 100),
113+
height: Math.round(box.height * 100),
114+
});
115+
expect(round(box)).toEqual(round(webBoundingBox));
116+
});
89117
});
90118

91119
describe('ElementHandle.contentFrame', function() {

0 commit comments

Comments
 (0)