test: rebaseline some click tests (#179)

This commit is contained in:
Pavel Feldman 2019-12-08 17:17:49 -08:00 committed by GitHub
parent 4f5fd4870c
commit f5cd742b79
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 16 additions and 16 deletions

View File

@ -275,17 +275,17 @@ export class ElementHandle<T extends Node = Node> extends js.JSHandle<T> {
point.y += border.y;
}
const metrics = await this._world.delegate.layoutViewport();
// Give 15 extra pixels to avoid any issues on viewport edge.
// Give 20 extra pixels to avoid any issues on viewport edge.
let scrollX = 0;
if (point.x < 15)
scrollX = point.x - 15;
if (point.x > metrics.width - 15)
scrollX = point.x - metrics.width + 15;
if (point.x < 20)
scrollX = point.x - 20;
if (point.x > metrics.width - 20)
scrollX = point.x - metrics.width + 20;
let scrollY = 0;
if (point.y < 15)
scrollY = point.y - 15;
if (point.y > metrics.height - 15)
scrollY = point.y - metrics.height + 15;
if (point.y < 20)
scrollY = point.y - 20;
if (point.y > metrics.height - 20)
scrollY = point.y - metrics.height + 20;
return { point, scrollX, scrollY };
}

View File

@ -93,9 +93,8 @@ module.exports.addTests = function({testRunner, expect, playwright, FFOX, CHROME
});
it('should select the text by triple clicking', async({page, server}) => {
await page.goto(server.PREFIX + '/input/textarea.html');
await page.focus('textarea');
const text = 'This is the text that we are going to try to select. Let\'s see how it goes.';
await page.keyboard.type(text);
await page.fill('textarea', text);
await page.tripleclick('textarea');
expect(await page.evaluate(() => {
const textarea = document.querySelector('textarea');
@ -284,12 +283,12 @@ module.exports.addTests = function({testRunner, expect, playwright, FFOX, CHROME
});
it('should click the button with px border with relative point', async({page, server}) => {
await page.goto(server.PREFIX + '/input/button.html');
await page.$eval('button', button => button.style.borderWidth = '2px');
await page.$eval('button', button => button.style.borderWidth = '8px');
await page.click('button', { relativePoint: { x: 20, y: 10 } });
expect(await page.evaluate(() => result)).toBe('Clicked');
// Safari reports border-relative offsetX/offsetY.
expect(await page.evaluate(() => offsetX)).toBe(WEBKIT ? 20 + 2 : 20);
expect(await page.evaluate(() => offsetY)).toBe(WEBKIT ? 10 + 2: 10);
expect(await page.evaluate(() => offsetX)).toBe(WEBKIT ? 20 + 8 : 20);
expect(await page.evaluate(() => offsetY)).toBe(WEBKIT ? 10 + 8 : 10);
});
it('should click the button with em border with relative point', async({page, server}) => {
await page.goto(server.PREFIX + '/input/button.html');
@ -303,12 +302,13 @@ module.exports.addTests = function({testRunner, expect, playwright, FFOX, CHROME
});
it('should click a very large button with relative point', async({page, server}) => {
await page.goto(server.PREFIX + '/input/button.html');
await page.$eval('button', button => button.style.borderWidth = '8px');
await page.$eval('button', button => button.style.height = button.style.width = '2000px');
await page.click('button', { relativePoint: { x: 1900, y: 1910 } });
expect(await page.evaluate(() => window.result)).toBe('Clicked');
// Safari reports border-relative offsetX/offsetY.
expect(await page.evaluate(() => offsetX)).toBe(WEBKIT ? 2 + 1900 : 1900);
expect(await page.evaluate(() => offsetY)).toBe(WEBKIT ? 2 + 1910 : 1910);
expect(await page.evaluate(() => offsetX)).toBe(WEBKIT ? 1900 + 8 : 1900);
expect(await page.evaluate(() => offsetY)).toBe(WEBKIT ? 1910 + 8 : 1910);
});
xit('should click a button in scrolling container with relative point', async({page, server}) => {
await page.goto(server.PREFIX + '/input/button.html');