test: ensure legacy callback functions work (#16436)
* test: test legacy callback functions * add TODO removal comments * fix callback spec
This commit is contained in:
parent
720197f9c8
commit
f105c84349
6 changed files with 114 additions and 9 deletions
|
@ -483,7 +483,7 @@ describe('BrowserWindow module', () => {
|
|||
})
|
||||
})
|
||||
|
||||
describe('BrowserWindow.getFocusedWindow()', (done) => {
|
||||
describe('BrowserWindow.getFocusedWindow()', () => {
|
||||
it('returns the opener window when dev tools window is focused', (done) => {
|
||||
w.show()
|
||||
w.webContents.once('devtools-focused', () => {
|
||||
|
@ -494,7 +494,7 @@ describe('BrowserWindow module', () => {
|
|||
})
|
||||
})
|
||||
|
||||
describe('BrowserWindow.capturePage(rect)', () => {
|
||||
describe('BrowserWindow.capturePage(rect)', (done) => {
|
||||
it('returns a Promise with a Buffer', async () => {
|
||||
const image = await w.capturePage({
|
||||
x: 0,
|
||||
|
@ -506,6 +506,19 @@ describe('BrowserWindow module', () => {
|
|||
expect(image.isEmpty()).to.be.true()
|
||||
})
|
||||
|
||||
// TODO(codebytere): remove when promisification is complete
|
||||
it('returns a Promise with a Buffer (callback)', () => {
|
||||
w.capturePage({
|
||||
x: 0,
|
||||
y: 0,
|
||||
width: 100,
|
||||
height: 100
|
||||
}, (image) => {
|
||||
expect(image.isEmpty()).to.be.true()
|
||||
done()
|
||||
})
|
||||
})
|
||||
|
||||
it('preserves transparency', async () => {
|
||||
const w = await openTheWindow({
|
||||
show: false,
|
||||
|
@ -525,6 +538,28 @@ describe('BrowserWindow module', () => {
|
|||
// Values can be 0,2,3,4, or 6. We want 6, which is RGB + Alpha
|
||||
expect(imgBuffer[25]).to.equal(6)
|
||||
})
|
||||
|
||||
// TODO(codebytere): remove when promisification is complete
|
||||
it('preserves transparency (callback)', async () => {
|
||||
const w = await openTheWindow({
|
||||
show: false,
|
||||
width: 400,
|
||||
height: 400,
|
||||
transparent: true
|
||||
})
|
||||
const p = emittedOnce(w, 'ready-to-show')
|
||||
w.loadURL('data:text/html,<html><body background-color: rgba(255,255,255,0)></body></html>')
|
||||
await p
|
||||
w.show()
|
||||
|
||||
w.capturePage((image) => {
|
||||
const imgBuffer = image.toPNG()
|
||||
// Check the 25th byte in the PNG.
|
||||
// Values can be 0,2,3,4, or 6. We want 6, which is RGB + Alpha
|
||||
expect(imgBuffer[25]).to.equal(6)
|
||||
done()
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
describe('BrowserWindow.setBounds(bounds[, animate])', () => {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue