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:
Shelley Vohr 2018-11-27 23:50:53 -05:00 committed by GitHub
parent 73fbb69c50
commit 41c2685204
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
9 changed files with 74 additions and 38 deletions

View file

@ -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.