Skip to content

Commit

Permalink
test: remove redundant color diffing dependency
Browse files Browse the repository at this point in the history
  • Loading branch information
codebytere committed Jul 21, 2022
1 parent 9e0a3c4 commit 625e753
Show file tree
Hide file tree
Showing 6 changed files with 71 additions and 729 deletions.
41 changes: 34 additions & 7 deletions spec-main/api-browser-window-spec.ts
Expand Up @@ -2063,16 +2063,43 @@ describe('BrowserWindow module', () => {
}).to.not.throw();
});

// TODO(nornagon): disabled due to flakiness.
it.skip('Allows setting a transparent window via CSS', async () => {
const appPath = path.join(__dirname, 'fixtures', 'apps', 'background-color-transparent');
it('Allows setting a transparent window via CSS', async () => {
const display = screen.getPrimaryDisplay();
const TRANSPARENT_BG_COLOR = '#244a24';

appProcess = childProcess.spawn(process.execPath, [appPath], {
stdio: 'inherit'
const backgroundWindow = new BrowserWindow({
...display.bounds,
frame: false,
backgroundColor: CHROMA_COLOR_HEX,
hasShadow: false
});

const [code] = await emittedOnce(appProcess, 'exit');
expect(code).to.equal(0);
await backgroundWindow.loadURL('about:blank');

const foregroundWindow = new BrowserWindow({
...display.bounds,
frame: false,
transparent: true,
vibrancy: 'under-window',
hasShadow: false,
webPreferences: {
contextIsolation: false,
nodeIntegration: true
}
});

const file = path.join(__dirname, 'fixtures', 'pages', 'css-transparent.html');
foregroundWindow.loadFile(file);
await emittedOnce(ipcMain, 'set-transparent');

const screenCapture = await captureScreen();
const centerColor = getPixelColor(screenCapture, {
x: display.size.width / 2,
y: display.size.height / 2
});

console.log(`centerColor is ${centerColor} and TRANSPARENT_BG_COLOR is ${TRANSPARENT_BG_COLOR}`);
expect(areColorsSimilar(centerColor, TRANSPARENT_BG_COLOR)).to.be.true();
});
});

Expand Down
15 changes: 0 additions & 15 deletions spec-main/fixtures/apps/background-color-transparent/index.html

This file was deleted.

This file was deleted.

31 changes: 31 additions & 0 deletions spec-main/fixtures/pages/css-transparent.html
@@ -0,0 +1,31 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>test-color-window</title>
<style>
body {
background: green;
}
</style>
</head>
<body id="body">
<script>
const { ipcRenderer } = require('electron');

const observer = new MutationObserver((mutationList, observer) => {
mutationList.forEach(({ type, attributeName }) => {
if (type === 'attributes' && attributeName === 'style') {
ipcRenderer.send('set-transparent');
}
});
});

observer.observe(document.body, { attributes: true });

document.addEventListener('DOMContentLoaded', event => {
document.body.style.background = 'transparent';
});
</script>
</body>
</html>
1 change: 0 additions & 1 deletion spec-main/package.json
Expand Up @@ -16,7 +16,6 @@
"dependencies": {
"chai-as-promised": "^7.1.1",
"dirty-chai": "^2.0.1",
"get-image-colors": "^4.0.0",
"pdfjs-dist": "^2.2.228"
}
}

0 comments on commit 625e753

Please sign in to comment.