test: fix frame-subscriber test on Mac
This commit is contained in:
parent
ae12d53884
commit
09f018ce8c
1 changed files with 21 additions and 3 deletions
|
@ -2358,14 +2358,32 @@ describe('BrowserWindow module', () => {
|
||||||
})
|
})
|
||||||
it('subscribes to frame updates (only dirty rectangle)', (done) => {
|
it('subscribes to frame updates (only dirty rectangle)', (done) => {
|
||||||
let called = false
|
let called = false
|
||||||
|
let gotInitialFullSizeFrame = false
|
||||||
|
const [contentWidth, contentHeight] = w.getContentSize()
|
||||||
w.loadFile(path.join(fixtures, 'api', 'frame-subscriber.html'))
|
w.loadFile(path.join(fixtures, 'api', 'frame-subscriber.html'))
|
||||||
w.webContents.on('dom-ready', () => {
|
w.webContents.on('did-finish-load', () => {
|
||||||
w.webContents.beginFrameSubscription(true, (data) => {
|
w.webContents.beginFrameSubscription(true, (data, rect) => {
|
||||||
|
if (data.length === 0) {
|
||||||
|
// Chromium sometimes sends a 0x0 frame at the beginning of the
|
||||||
|
// page load.
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if (rect.height === contentHeight && rect.width === contentWidth &&
|
||||||
|
!gotInitialFullSizeFrame) {
|
||||||
|
// The initial frame is full-size, but we're looking for a call
|
||||||
|
// with just the dirty-rect. The next frame should be a smaller
|
||||||
|
// rect.
|
||||||
|
gotInitialFullSizeFrame = true
|
||||||
|
return
|
||||||
|
}
|
||||||
// This callback might be called twice.
|
// This callback might be called twice.
|
||||||
if (called) return
|
if (called) return
|
||||||
|
// We asked for just the dirty rectangle, so we expect to receive a
|
||||||
|
// rect smaller than the full size.
|
||||||
|
assert(rect.width < contentWidth || rect.height < contentHeight)
|
||||||
called = true
|
called = true
|
||||||
|
|
||||||
assert.notStrictEqual(data.length, 0)
|
expect(data.length).to.equal(rect.width * rect.height * 4)
|
||||||
w.webContents.endFrameSubscription()
|
w.webContents.endFrameSubscription()
|
||||||
done()
|
done()
|
||||||
})
|
})
|
||||||
|
|
Loading…
Reference in a new issue