Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Support resize window #10

Merged
merged 13 commits into from
Aug 1, 2024
Merged

feat: Support resize window #10

merged 13 commits into from
Aug 1, 2024

Conversation

tianfeng92
Copy link
Contributor

@tianfeng92 tianfeng92 commented Aug 1, 2024

Description

Job example: https://app.saucelabs.com/tests/85b6389899714d53b8514a1a88cb3563#2

Notes: when getting and setting window size, TestCafe official provider is checking if the browser is jwp type and using _getWindowSize and _setWindowSize. These two methods are both deprecated and commented as This command is deprecated and likely not supported by any browser.. They have been removed recently as well. Therefore, in this PR, only use browser.getWindowRect and browser.setWindowRect which are for W3C browser.

currentHeight: number,
) {
if (width > maxWindowSize || height > maxWindowSize) {
throw new WindowSizeRangeError();
Copy link
Contributor Author

@tianfeng92 tianfeng92 Aug 1, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TestCafe has checked the input before. Only positive integer is allowed. However, there is no limit for max size. So here added one.

Meanwhile, TestCafe official provider is using MAX_SAFE_INTEGER as the maxWindowSize to validate the input. However, the error message is mismatched with the actual value, which is 2^53-1.

Considering real-world scenarios, setting it to 2^31-1 is good enough.

export const maxWindowSize = 2 ** 31 - 1;

@tianfeng92 tianfeng92 marked this pull request as ready for review August 1, 2024 16:49
@tianfeng92 tianfeng92 requested a review from a team as a code owner August 1, 2024 16:49
@tianfeng92 tianfeng92 merged commit e45af5b into main Aug 1, 2024
1 check passed
@tianfeng92 tianfeng92 deleted the DEVX-2785 branch August 1, 2024 20:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants