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

fix: resize and maximize window with disableMultipleWindows option in NA mode #8135

Merged
merged 2 commits into from
Feb 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/browser/provider/built-in/dedicated/chrome/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ export default {
if (additionalOptions.nativeAutomation)
await this._setupNativeAutomation({ browserId, browserClient, runtimeInfo, nativeAutomationOptions: toNativeAutomationSetupOptions(additionalOptions, config.headless) });

if (!additionalOptions.disableMultipleWindows)
if (additionalOptions.nativeAutomation || !additionalOptions.disableMultipleWindows)
runtimeInfo.activeWindowId = runtimeInfo?.nativeAutomation?.windowId || this.calculateWindowId();

await browserClient.initMainWindowCdpClient();
Expand Down
4 changes: 2 additions & 2 deletions test/functional/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,11 @@ testingEnvironments[testingEnvironmentNames.mobileBrowsers] = {

browsers: [
{
browserName: 'browserstack:iPad 9th@15',
browserName: 'browserstack:ipad:ios 15',
alias: 'ipad',
},
{
browserName: 'browserstack:iPhone 13 Pro@15',
browserName: 'browserstack:iphone:ios 15',
alias: 'iphone',
},
],
Expand Down
9 changes: 9 additions & 0 deletions test/functional/fixtures/regression/gh-8117/pages/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Resize window</title>
</head>
<body>
</body>
</html>
47 changes: 47 additions & 0 deletions test/functional/fixtures/regression/gh-8117/test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
const { onlyInNativeAutomation } = require('../../../utils/skip-in');
const path = require('path');
const createTestCafe = require('../../../../../lib');
const { createReporter } = require('../../../utils/reporter');
const { expect } = require('chai');

let testCafe = null;
let runner = null;
let errors = null;

const reporter = createReporter({
reportTestDone (_, testRunInfo) {
errors = testRunInfo.errs;
},
});

const run = (pathToTest, concurrency) => {
const src = path.join(__dirname, pathToTest);

return createTestCafe('127.0.0.1', 1335, 1336)
.then(tc => {
testCafe = tc;
})
.then(() => {
runner = testCafe.createRunner();
return runner
.src(src)
.browsers(`chrome`)
.reporter(reporter)
.concurrency(concurrency)
.run({ disableMultipleWindows: true });
})
.then(() => {
testCafe.close();
});
};

describe('[Regression](GH-8117)', function () {
onlyInNativeAutomation('Should resize and maximize window in native automation mode with disableMultipleWindows option', function () {
return run('testcafe-fixtures/maximize.js')
.then(() => expect(errors.length).eql(0));
});
onlyInNativeAutomation('Should resize window in native automation mode with disableMultipleWindows option', function () {
return run('testcafe-fixtures/resize.js')
.then(() => expect(errors.length).eql(0));
});
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import { expect } from 'chai';
import { ClientFunction } from 'testcafe';

const getWindowDimensionsInfo = ClientFunction(() => {
return {
innerWidth: window.innerWidth,
innerHeight: window.innerHeight,
outerWidth: window.outerWidth,
outerHeight: window.outerHeight,
availableHeight: screen.availHeight,
availableWidth: screen.availWidth,
};
});

fixture `Maximize Window`
.page `http://localhost:3000/fixtures/regression/gh-8117/pages/index.html`;

test('Maximize window', async t => {
await t.maximizeWindow();

const dimensions = await getWindowDimensionsInfo();

expect(dimensions.outerWidth).to.be.at.least(dimensions.availableWidth);
expect(dimensions.outerHeight).to.be.at.least(dimensions.availableHeight);
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import { expect } from 'chai';
import { getWindowHeight, getWindowWidth } from '../../../../esm-utils/window-helpers.js';

fixture `Resize window`
.page `http://localhost:3000/fixtures/regression/gh-8117/pages/index.html`;

test('Resize window', async t => {
const newWidth = 500;
const newHeight = 500;

await t.resizeWindow(newWidth, newHeight);

expect(await getWindowWidth()).equals(newWidth);
expect(await getWindowHeight()).equals(newHeight);
});
Loading