Skip to content
Merged
Show file tree
Hide file tree
Changes from 11 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
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
export const CONTAINERIZED_CHROME_FLAGS = ['--no-sandbox', '--disable-dev-shm-usage'];

export function buildChromeArgs ({ config, cdpPort, platformArgs, tempProfileDir, isContainerized, isNativeAutomation }) {
export function buildChromeArgs ({ config, cdpPort, platformArgs, tempProfileDir, isContainerized, isNativeAutomation, browserName }) {
const headlessMode = browserName === 'edge' ? '--headless' : '--headless=new';

let chromeArgs = []
.concat(
cdpPort ? [`--remote-debugging-port=${cdpPort}`] : [],
!config.userProfile ? [`--user-data-dir=${tempProfileDir.path}`] : [],
config.headless ? ['--headless'] : [],
config.headless ? [headlessMode] : [],
config.userArgs ? [config.userArgs] : [],
// NOTE: we need to prevent new window blocking for multiple windows in Native Automation
isNativeAutomation ? ['--disable-popup-blocking'] : [],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export async function start (pageUrl, { browserName, config, cdpPort, tempProfil
const chromeInfo = await browserTools.getBrowserInfo(config.path || browserName);
const chromeOpenParameters = Object.assign({}, chromeInfo);

chromeOpenParameters.cmd = buildChromeArgs({ config, cdpPort, platformArgs: chromeOpenParameters.cmd, tempProfileDir, isContainerized, isNativeAutomation });
chromeOpenParameters.cmd = buildChromeArgs({ config, cdpPort, platformArgs: chromeOpenParameters.cmd, tempProfileDir, isContainerized, isNativeAutomation, browserName });

await browserStarter.startBrowser(chromeOpenParameters, pageUrl);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@ const getWindowDimensionsInfo = ClientFunction(() => {
};
});

const isHeadlessChrome = ClientFunction(() => {
return /HeadlessChrome/.test(window.navigator.userAgent);
});

const INITIAL_SIZE = 500;

fixture `Maximize Window`
Expand All @@ -29,9 +33,18 @@ fixture `Maximize Window`

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

const dimensions = await getWindowDimensionsInfo();

expect(dimensions.outerWidth).to.be.at.least(dimensions.availableWidth);
expect(dimensions.outerHeight).to.be.at.least(dimensions.availableHeight);
// HACK: headless outerWidth/Height and availHeight/Width are random and different
// that is why we check with innerWidth/Height
if (isHeadless) {
expect(dimensions.innerWidth).to.be.at.least(dimensions.availableWidth);
expect(dimensions.innerHeight).to.be.at.least(dimensions.availableHeight);
}
else {
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
@@ -1,8 +1,10 @@
const routes = {
main: 'http://one-dummy-url.com',
get: 'http://one-dummy-url.com/get',
post: 'http://one-dummy-url.com/post',
another: 'https://another-dummy-url.com',
main: 'http://one-dummy-url.com',
get: 'http://one-dummy-url.com/get',
post: 'http://one-dummy-url.com/post',
another: 'https://another-dummy-url.com',
secureMain: 'https://secure-dummy-url.com',
secureGet: 'https://secure-dummy-url.com/get',
};

export default routes;
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ const testPageMarkup = `
<button onclick="sendRequest()">Send request</button>
<script>
function sendRequest() {
fetch('${DUMMY_URLS.get}')
fetch('${DUMMY_URLS.secureGet}')
.then(res => {
return res.text();
})
Expand All @@ -23,9 +23,9 @@ const testPageMarkup = `
`;

const requestMock = RequestMock()
.onRequestTo(DUMMY_URLS.main)
.onRequestTo(DUMMY_URLS.secureMain)
.respond(testPageMarkup)
.onRequestTo(DUMMY_URLS.get)
.onRequestTo(DUMMY_URLS.secureGet)
.respond('Data from mocked fetch request')
.onRequestTo(DUMMY_URLS.another)
.respond();
Expand All @@ -36,7 +36,7 @@ test
.requestHooks(requestMock)
('Basic', async t => {
await t
.navigateTo(DUMMY_URLS.main)
.navigateTo(DUMMY_URLS.secureMain)
.expect(Selector('h1').textContent).eql('Mocked page')
.click('button')
.expect(Selector('h2').textContent).eql('Data from mocked fetch request')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { RequestMock } from 'testcafe';
import DUMMY_URLS from '../../common/mock-routes.js';

const mock = RequestMock()
.onRequestTo(DUMMY_URLS.get)
.onRequestTo(DUMMY_URLS.secureGet)
.respond(() => {
throw new Error('Error in the "respond" method');
});
Expand All @@ -11,5 +11,5 @@ fixture `Fixture`
.requestHooks(mock);

test('test', async t => {
await t.navigateTo(DUMMY_URLS.get);
await t.navigateTo(DUMMY_URLS.secureGet);
});
5 changes: 3 additions & 2 deletions test/functional/fixtures/regression/gh-3456/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,12 @@ const assertionHelper = require('../../../assertion-helper.js');
const SCREENSHOTS_PATH = path.resolve(assertionHelper.SCREENSHOTS_PATH);

if (config.useLocalBrowsers) {
describe('[Regression](GH-3456) Should process --window-size arg in Headless mode ', function () {
// See chromium issue with --window-size flag in headless https://issues.chromium.org/issues/40256833
describe.skip('[Regression](GH-3456) Should process --window-size arg in Headless mode ', function () {
it(':headless', () => {
const browsers = [
'chrome:headless --window-size=501,602',
'chrome --headless --window-size=501,602',
'chrome --headless=new --window-size=501,602',
];

return createTestCafe('127.0.0.1', 1335, 1336)
Expand Down