Skip to content

Commit

Permalink
Fix maximizeWindow after resize (#8361)
Browse files Browse the repository at this point in the history
<!--
Thank you for your contribution.

Before making a PR, please read our contributing guidelines at

https://github.com/DevExpress/testcafe/blob/master/CONTRIBUTING.md#code-contribution

We recommend creating a *draft* PR, so that you can mark it as 'ready
for review' when you are done.
-->

## Purpose
Window did not maximize properly after resizing. 

## Approach
Remove redundant use of _setDeviceMetricsOverride in resize window using
CDP.

## References
closes #8360

## Pre-Merge TODO
- [ ] Write tests for your proposed changes
- [ ] Make sure that existing tests do not fail

---------

Co-authored-by: Bayheck <[email protected]>
  • Loading branch information
Bayheck and Bayheck authored Jan 24, 2025
1 parent 45310bf commit a4ff2d4
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,7 @@ export class BrowserClient {
}

public async resizeBounds (newDimensions: Size): Promise<void> {
const { viewportSize, config } = this._runtimeInfo;
const { viewportSize } = this._runtimeInfo;

let nonClientWidth = 0;
let nonClientHeight = 0;
Expand All @@ -258,8 +258,6 @@ export class BrowserClient {
const client = await this.getActiveClient();

if (client) {
await this._setDeviceMetricsOverride(client, newDimensions.width, newDimensions.height, 1, config.mobile);

const windowParams = await client.Browser.getWindowForTarget({ targetId: target.id });

if (windowParams.bounds.windowState !== 'normal') {
Expand Down
4 changes: 4 additions & 0 deletions test/functional/fixtures/api/es-next/resize-window/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,10 @@ describe('[API] Resize window actions', function () {
it('Should resize the window after maximizeWindow', function () {
return runTests('./testcafe-fixtures/resize-window-test.js', 'Resize the window after maximizeWindow', { only: 'chrome' });
});

it('Should maximizeWindow after resize', function () {
return runTests('./testcafe-fixtures/resize-window-test.js', 'Correctly maximizeWindow after resize', { only: 'chrome' });
});
});

describe('t.resizeWindowToFitDevice', function () {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,3 +100,15 @@ test('Resize the window after maximizeWindow', async t => {
expect(await getWindowWidth()).equals(640);
expect(await getWindowHeight()).equals(480);
});

test('Correctly maximizeWindow after resize', async t => {
await t.resizeWindow(640, 480);

expect(await getWindowWidth()).equals(640);
expect(await getWindowHeight()).equals(480);

await t.maximizeWindow();

expect(await getWindowWidth()).to.be.above(640);
expect(await getWindowHeight()).to.be.above(480);
});

0 comments on commit a4ff2d4

Please sign in to comment.