adds tests for osr
This commit is contained in:
parent
5525ac36b8
commit
35ee99265e
7 changed files with 177 additions and 8 deletions
|
@ -1167,4 +1167,156 @@ describe('browser-window module', function () {
|
|||
w.loadURL(server.url)
|
||||
})
|
||||
})
|
||||
|
||||
describe('offscreen rendering', function () {
|
||||
it('creates offscreen window', function (done) {
|
||||
this.timeout(10000)
|
||||
let w_ = new BrowserWindow({
|
||||
show: false,
|
||||
width: 400,
|
||||
height: 400,
|
||||
webPreferences: {
|
||||
backgroundThrottling: false,
|
||||
offscreen: true
|
||||
}
|
||||
})
|
||||
w_.loadURL('file://' + fixtures + '/api/offscreen-rendering.html')
|
||||
w_.webContents.once('paint', function (event, rect, data, size) {
|
||||
assert.notEqual(data.length, 0)
|
||||
done()
|
||||
})
|
||||
})
|
||||
|
||||
describe('window.webContents.isOffscreen', function () {
|
||||
it('has offscreen type', function () {
|
||||
let w_ = new BrowserWindow({
|
||||
show: false,
|
||||
width: 400,
|
||||
height: 400,
|
||||
webPreferences: {
|
||||
backgroundThrottling: false,
|
||||
offscreen: true
|
||||
}
|
||||
})
|
||||
w_.loadURL('file://' + fixtures + '/api/offscreen-rendering.html')
|
||||
assert.equal(w_.webContents.isOffscreen(), true)
|
||||
})
|
||||
|
||||
it('is a regular window', function () {
|
||||
assert.equal(w.webContents.isOffscreen(), false)
|
||||
})
|
||||
})
|
||||
|
||||
describe('window.webContents.isPainting', function () {
|
||||
it('is currently painting', function (done) {
|
||||
this.timeout(10000)
|
||||
let w_ = new BrowserWindow({
|
||||
show: false,
|
||||
width: 400,
|
||||
height: 400,
|
||||
webPreferences: {
|
||||
backgroundThrottling: false,
|
||||
offscreen: true
|
||||
}
|
||||
})
|
||||
w_.loadURL('file://' + fixtures + '/api/offscreen-rendering.html')
|
||||
w_.webContents.once('paint', function (event, rect, data, size) {
|
||||
assert.equal(w_.webContents.isPainting(), true)
|
||||
done()
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
describe('window.webContents.stopPainting', function () {
|
||||
it('stops painting', function (done) {
|
||||
this.timeout(10000)
|
||||
let w_ = new BrowserWindow({
|
||||
show: false,
|
||||
width: 400,
|
||||
height: 400,
|
||||
webPreferences: {
|
||||
backgroundThrottling: false,
|
||||
offscreen: true
|
||||
}
|
||||
})
|
||||
w_.loadURL('file://' + fixtures + '/api/offscreen-rendering.html')
|
||||
|
||||
w_.webContents.on('dom-ready', function () {
|
||||
w_.webContents.stopPainting()
|
||||
assert.equal(w_.webContents.isPainting(), false)
|
||||
done()
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
describe('window.webContents.startPainting', function () {
|
||||
it('starts painting', function (done) {
|
||||
this.timeout(10000)
|
||||
let w_ = new BrowserWindow({
|
||||
show: false,
|
||||
width: 400,
|
||||
height: 400,
|
||||
webPreferences: {
|
||||
backgroundThrottling: false,
|
||||
offscreen: true
|
||||
}
|
||||
})
|
||||
w_.loadURL('file://' + fixtures + '/api/offscreen-rendering.html')
|
||||
|
||||
w_.webContents.on('dom-ready', function () {
|
||||
w_.webContents.stopPainting()
|
||||
w_.webContents.startPainting()
|
||||
w_.webContents.once('paint', function (event, rect, data, size) {
|
||||
assert.equal(w_.webContents.isPainting(), true)
|
||||
done()
|
||||
})
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
describe('window.webContents.getFrameRate', function () {
|
||||
it('has default frame rate', function (done) {
|
||||
this.timeout(10000)
|
||||
let w_ = new BrowserWindow({
|
||||
show: false,
|
||||
width: 400,
|
||||
height: 400,
|
||||
webPreferences: {
|
||||
backgroundThrottling: false,
|
||||
offscreen: true
|
||||
}
|
||||
})
|
||||
w_.loadURL('file://' + fixtures + '/api/offscreen-rendering.html')
|
||||
|
||||
w_.webContents.once('paint', function (event, rect, data, size) {
|
||||
assert.equal(w_.webContents.getFrameRate(), 60)
|
||||
done()
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
describe('window.webContents.setFrameRate', function () {
|
||||
it('has custom frame rate', function (done) {
|
||||
this.timeout(10000)
|
||||
let w_ = new BrowserWindow({
|
||||
show: false,
|
||||
width: 400,
|
||||
height: 400,
|
||||
webPreferences: {
|
||||
backgroundThrottling: false,
|
||||
offscreen: true
|
||||
}
|
||||
})
|
||||
w_.loadURL('file://' + fixtures + '/api/offscreen-rendering.html')
|
||||
|
||||
w_.webContents.on('dom-ready', function () {
|
||||
w_.webContents.setFrameRate(30)
|
||||
w_.webContents.once('paint', function (event, rect, data, size) {
|
||||
assert.equal(w_.webContents.getFrameRate(), 30)
|
||||
done()
|
||||
})
|
||||
})
|
||||
})
|
||||
})
|
||||
})
|
||||
})
|
||||
|
|
|
@ -40,11 +40,12 @@ describe('webContents module', function () {
|
|||
return a.getId() - b.getId()
|
||||
})
|
||||
|
||||
assert.equal(all.length, 4)
|
||||
assert.equal(all.length, 5)
|
||||
assert.equal(all[0].getType(), 'window')
|
||||
assert.equal(all[1].getType(), 'window')
|
||||
assert.equal(all[2].getType(), 'remote')
|
||||
assert.equal(all[3].getType(), 'webview')
|
||||
assert.equal(all[1].getType(), 'offscreen')
|
||||
assert.equal(all[2].getType(), 'window')
|
||||
assert.equal(all[3].getType(), 'remote')
|
||||
assert.equal(all[4].getType(), 'webview')
|
||||
|
||||
done()
|
||||
})
|
||||
|
|
11
spec/fixtures/api/offscreen-rendering.html
vendored
Normal file
11
spec/fixtures/api/offscreen-rendering.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)
|
||||
}, 10)
|
||||
</script>
|
||||
</html>
|
Loading…
Add table
Add a link
Reference in a new issue