fix: falsy transparent shouldn't affect webContents background (#36914)

This commit is contained in:
David Sanders 2023-05-02 14:44:34 -07:00 committed by GitHub
parent d95f9d2c63
commit a26343f3e0
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 65 additions and 15 deletions

View file

@ -6012,7 +6012,7 @@ describe('BrowserWindow module', () => {
});
// Linux and arm64 platforms (WOA and macOS) do not return any capture sources
ifit(process.platform === 'darwin' && process.arch !== 'x64')('should not display a visible background', async () => {
ifit(process.platform === 'darwin' && process.arch === 'x64')('should not display a visible background', async () => {
const display = screen.getPrimaryDisplay();
const backgroundWindow = new BrowserWindow({
@ -6085,6 +6085,32 @@ describe('BrowserWindow module', () => {
expect(areColorsSimilar(centerColor, HexColors.PURPLE)).to.be.true();
});
// Linux and arm64 platforms (WOA and macOS) do not return any capture sources
ifit(process.platform === 'darwin' && process.arch === 'x64')('should not make background transparent if falsy', async () => {
const display = screen.getPrimaryDisplay();
for (const transparent of [false, undefined]) {
const window = new BrowserWindow({
...display.bounds,
transparent
});
await once(window, 'show');
await window.webContents.loadURL('data:text/html,<head><meta name="color-scheme" content="dark"></head>');
await setTimeout(500);
const screenCapture = await captureScreen();
const centerColor = getPixelColor(screenCapture, {
x: display.size.width / 2,
y: display.size.height / 2
});
window.close();
// color-scheme is set to dark so background should not be white
expect(areColorsSimilar(centerColor, HexColors.WHITE)).to.be.false();
}
});
});
describe('"backgroundColor" option', () => {