Skip to content

Commit

Permalink
test(resize): add a screenshot resize test (#5907)
Browse files Browse the repository at this point in the history
  • Loading branch information
pavelfeldman authored Mar 23, 2021
1 parent ec6453d commit 9f1b2f6
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 0 deletions.
14 changes: 14 additions & 0 deletions test/elementhandle-screenshot.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -401,4 +401,18 @@ describe('element screenshot', (suite, parameters) => {
const buffer = await elementHandle.screenshot({ path: outputPath, type: 'jpeg' });
expect([buffer[0], buffer[1], buffer[2]]).toEqual([0xFF, 0xD8, 0xFF]);
});

it('should not issue resize event', async ({page, server}) => {
await page.goto(server.PREFIX + '/grid.html');
let resizeTriggered = false;
await page.exposeFunction('resize', () => {
resizeTriggered = true;
});
await page.evaluate(() => {
window.addEventListener('resize', () => (window as any).resize());
});
const elementHandle = await page.$('.box:nth-of-type(3)');
await elementHandle.screenshot();
expect(resizeTriggered).toBeFalsy();
});
});
13 changes: 13 additions & 0 deletions test/page-screenshot.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -341,4 +341,17 @@ describe('page screenshot', (suite, { browserName, headful }) => {
expect(pixel(0, 8339).r).toBeLessThan(128);
expect(pixel(0, 8339).b).toBeGreaterThan(128);
});

it('should not issue resize event', async ({page, server}) => {
await page.goto(server.PREFIX + '/grid.html');
let resizeTriggered = false;
await page.exposeFunction('resize', () => {
resizeTriggered = true;
});
await page.evaluate(() => {
window.addEventListener('resize', () => (window as any).resize());
});
await page.screenshot();
expect(resizeTriggered).toBeFalsy();
});
});

0 comments on commit 9f1b2f6

Please sign in to comment.