Merge pull request #6164 from MaxWhere/master
beginFrameSubscription bugfix and improvement
This commit is contained in:
commit
3d2ad0080d
7 changed files with 94 additions and 31 deletions
|
@ -603,21 +603,42 @@ describe('browser-window module', function () {
|
|||
})
|
||||
|
||||
describe('beginFrameSubscription method', function () {
|
||||
this.timeout(20000)
|
||||
it('subscribes to frame updates', function (done) {
|
||||
this.timeout(20000)
|
||||
|
||||
it('subscribes frame updates', function (done) {
|
||||
let called = false
|
||||
w.loadURL('file://' + fixtures + '/api/blank.html')
|
||||
w.webContents.beginFrameSubscription(function (data) {
|
||||
// This callback might be called twice.
|
||||
if (called) return
|
||||
called = true
|
||||
|
||||
assert.notEqual(data.length, 0)
|
||||
w.webContents.endFrameSubscription()
|
||||
done()
|
||||
w.loadURL('file://' + fixtures + '/api/frame-subscriber.html')
|
||||
w.webContents.on('dom-ready', function () {
|
||||
w.webContents.beginFrameSubscription(function (data) {
|
||||
assert.notEqual(data.length, 0)
|
||||
w.webContents.endFrameSubscription()
|
||||
done()
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
it('subscribes to frame updates (only dirty rectangle)', function (done) {
|
||||
this.timeout(20000)
|
||||
|
||||
w.loadURL('file://' + fixtures + '/api/frame-subscriber.html')
|
||||
w.webContents.on('dom-ready', function () {
|
||||
w.webContents.beginFrameSubscription(true, function (data) {
|
||||
assert.notEqual(data.length, 0)
|
||||
w.webContents.endFrameSubscription()
|
||||
done()
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
it('throws error when subscriber is not well defined', function (done) {
|
||||
this.timeout(20000)
|
||||
|
||||
w.loadURL('file://' + fixtures + '/api/frame-subscriber.html')
|
||||
try{
|
||||
w.webContents.beginFrameSubscription(true, true)
|
||||
} catch(e) {
|
||||
done()
|
||||
}
|
||||
})
|
||||
})
|
||||
|
||||
describe('savePage method', function () {
|
||||
|
|
11
spec/fixtures/api/frame-subscriber.html
vendored
Normal file
11
spec/fixtures/api/frame-subscriber.html
vendored
Normal file
|
@ -0,0 +1,11 @@
|
|||
<html>
|
||||
<body>
|
||||
<div style="width: 10px; height: 10px;" id="dirty"></div>
|
||||
</body>
|
||||
<script type="text/javascript" charset="utf-8">
|
||||
setInterval(function(){
|
||||
document.getElementById('dirty').style.backgroundColor =
|
||||
'#'+(Math.random()*0xFFFFFF<<0).toString(16)
|
||||
}, 100)
|
||||
</script>
|
||||
</html>
|
Loading…
Add table
Add a link
Reference in a new issue