-
Notifications
You must be signed in to change notification settings - Fork 660
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: preserve correct page size on screenshot in full-page mode in Ch…
…rome headless(closes #5961) (#7054) ## Purpose For some reason in chrome:headless page body size is set incorrectly. ## Approach Update devtools-protocol package and use the native screenshot approach. ## References Closes #5961 Closes #7224 ## Pre-Merge TODO - [ ] Write tests for your proposed changes - [ ] Make sure that existing tests do not fail Co-authored-by: Andrey Belym <belym.a.2105@gmail.com> Co-authored-by: Aleksey Popov <alekseypopow1995@yandex.ru>
- Loading branch information
1 parent
f79980f
commit 89eecab
Showing
5 changed files
with
125 additions
and
37 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
73 changes: 73 additions & 0 deletions
73
test/functional/fixtures/regression/gh-5961/pages/index.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
|
||
<head> | ||
<meta charset="UTF-8"> | ||
<title>Testcafe screenshot sizing issue</title> | ||
<style> | ||
* { | ||
margin: 0; | ||
padding: 0; | ||
} | ||
|
||
body { | ||
background-color: black; | ||
} | ||
|
||
div.wrapper { | ||
position: relative; | ||
height: 5000px; | ||
} | ||
|
||
div.d { | ||
width: 50px; | ||
height: 50px; | ||
position: absolute; | ||
} | ||
|
||
.left { | ||
left: 0; | ||
} | ||
|
||
.right { | ||
right: 0; | ||
} | ||
|
||
.top { | ||
top: 0; | ||
} | ||
|
||
.bottom { | ||
bottom: 0; | ||
} | ||
|
||
.red { | ||
background-color: rgb(255, 0, 0); | ||
} | ||
|
||
.green { | ||
background-color: rgb(0, 255, 0); | ||
} | ||
|
||
@media screen and (max-width: 1023px) { | ||
.red { | ||
background-color: rgb(0, 255, 0); | ||
} | ||
|
||
.green { | ||
background-color: rgb(255, 0, 0); | ||
} | ||
} | ||
</style> | ||
</head> | ||
|
||
<body> | ||
<div class="wrapper"> | ||
<div class="d left top red"></div> | ||
<div class="d right top green"></div> | ||
<div class="d left bottom green"></div> | ||
<div class="d right bottom red"></div> | ||
</div> | ||
</body> | ||
|
||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
const assertionHelper = require('../../../assertion-helper.js'); | ||
const { expect } = require('chai'); | ||
const config = require('../../../config.js'); | ||
const { skipInExperimentalDebug } = require('../../../utils/skip-in.js'); | ||
|
||
if (config.useLocalBrowsers && config.useHeadlessBrowsers) { | ||
describe('[Regression](GH-5961)', () => { | ||
afterEach(assertionHelper.removeScreenshotDir); | ||
|
||
skipInExperimentalDebug('Screenshot', () => { | ||
return runTests('./testcafe-fixtures/index.js', 'Take a resized full page screenshot', { setScreenshotPath: true }) | ||
.then(function () { | ||
return assertionHelper.checkScreenshotFileFullPage(false, 'custom'); | ||
}) | ||
.then(function (result) { | ||
expect(result).eql(true); | ||
}); | ||
}); | ||
}); | ||
} |
15 changes: 15 additions & 0 deletions
15
test/functional/fixtures/regression/gh-5961/testcafe-fixtures/index.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import { ClientFunction } from 'testcafe'; | ||
import { parseUserAgent } from '../../../../../../lib/utils/parse-user-agent'; | ||
|
||
fixture`Getting Started` | ||
.page`http://localhost:3000/fixtures/regression/gh-5961/pages/index.html`; | ||
|
||
test('Take a resized full page screenshot', async t => { | ||
const ua = await ClientFunction(() => navigator.userAgent.toString())(); | ||
|
||
await t.resizeWindow(1024, 768); | ||
await t.takeScreenshot({ | ||
path: 'custom/' + parseUserAgent(ua).name + '.png', | ||
fullPage: true, | ||
}); | ||
}); |