feat: promisify win.capturePage() (#15743)
* feat: promisify win.capturePage * mark optional arg correctly * Add to breaking changes doc * properly deprecate win.capturePage * remove change from api-contract * document both callback and promise versions * address docs feedback * update promisification progress doc
This commit is contained in:
parent
73fbb69c50
commit
41c2685204
9 changed files with 74 additions and 38 deletions
|
@ -490,15 +490,13 @@ describe('BrowserWindow module', () => {
|
|||
})
|
||||
})
|
||||
|
||||
describe('BrowserWindow.capturePage(rect, callback)', () => {
|
||||
it('calls the callback with a Buffer', async () => {
|
||||
const image = await new Promise((resolve) => {
|
||||
w.capturePage({
|
||||
x: 0,
|
||||
y: 0,
|
||||
width: 100,
|
||||
height: 100
|
||||
}, resolve)
|
||||
describe('BrowserWindow.capturePage(rect)', () => {
|
||||
it('returns a Promise with a Buffer', async () => {
|
||||
const image = await w.capturePage({
|
||||
x: 0,
|
||||
y: 0,
|
||||
width: 100,
|
||||
height: 100
|
||||
})
|
||||
|
||||
expect(image.isEmpty()).to.be.true()
|
||||
|
@ -515,7 +513,7 @@ describe('BrowserWindow module', () => {
|
|||
await emittedOnce(w, 'ready-to-show')
|
||||
w.show()
|
||||
|
||||
const image = await new Promise((resolve) => w.capturePage(resolve))
|
||||
const image = await w.capturePage()
|
||||
const imgBuffer = image.toPNG()
|
||||
|
||||
// Check the 25th byte in the PNG.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue