|
16 | 16 | */
|
17 | 17 |
|
18 | 18 | const utils = require('./utils');
|
19 |
| -const {FFOX, CHROMIUM, WEBKIT, WIN, USES_HOOKS} = utils.testOptions(browserType); |
| 19 | +const {FFOX, CHROMIUM, WEBKIT, WIN, HEADLESS, USES_HOOKS} = utils.testOptions(browserType); |
20 | 20 |
|
21 | 21 | async function giveItAChanceToClick(page) {
|
22 | 22 | for (let i = 0; i < 5; i++)
|
@@ -400,16 +400,17 @@ describe('Page.click', function() {
|
400 | 400 | });
|
401 | 401 | await page.click('button', { position: { x: 20, y: 10 } });
|
402 | 402 | expect(await page.evaluate(() => result)).toBe('Clicked');
|
| 403 | + const round = x => Math.round(x + 0.01); |
403 | 404 | let expected = { x: 28, y: 18 }; // 20;10 + 8px of border in each direction
|
404 | 405 | if (WEBKIT) {
|
405 | 406 | // WebKit rounds up during css -> dip -> css conversion.
|
406 | 407 | expected = { x: 29, y: 19 };
|
407 |
| - } else if (CHROMIUM) { |
408 |
| - // Chromium rounds down during css -> dip -> css conversion. |
| 408 | + } else if (CHROMIUM && HEADLESS) { |
| 409 | + // Headless Chromium rounds down during css -> dip -> css conversion. |
409 | 410 | expected = { x: 27, y: 18 };
|
410 | 411 | }
|
411 |
| - expect(await page.evaluate(() => pageX)).toBe(expected.x); |
412 |
| - expect(await page.evaluate(() => pageY)).toBe(expected.y); |
| 412 | + expect(round(await page.evaluate(() => pageX))).toBe(expected.x); |
| 413 | + expect(round(await page.evaluate(() => pageY))).toBe(expected.y); |
413 | 414 | await context.close();
|
414 | 415 | });
|
415 | 416 |
|
|
0 commit comments