This commit is contained in:
deepak1556 2016-12-04 00:22:57 +05:30
Родитель 3de3fb53bd
Коммит e043dabcb8
2 изменённых файлов: 42 добавлений и 0 удалений

Просмотреть файл

@ -4,6 +4,7 @@ const path = require('path')
const ws = require('ws')
const url = require('url')
const remote = require('electron').remote
const {closeWindow} = require('./window-helpers')
const {BrowserWindow, ipcMain, protocol, session, webContents} = remote
@ -109,6 +110,38 @@ describe('chromium feature', function () {
}
}).catch(done)
})
it('can return new device id when cookie storage is cleared', function (done) {
const options = {
origin: null,
storages: ['cookies']
}
let deviceIds = []
const ses = session.fromPartition('persist:media-device-id')
let w = new BrowserWindow({
show: false,
webPreferences: {
session: ses
}
})
w.webContents.on('ipc-message', function (event, args) {
if (args[0] === 'deviceIds') {
deviceIds.push(args[1])
}
if (deviceIds.length === 2) {
assert.notDeepEqual(deviceIds[0], deviceIds[1])
closeWindow(w).then(function () {
w = null
done()
})
} else {
ses.clearStorageData(options, function () {
w.webContents.reload()
})
}
})
w.loadURL('file://' + fixtures + '/pages/media-id-reset.html')
})
})
describe('navigator.language', function () {

9
spec/fixtures/pages/media-id-reset.html поставляемый Normal file
Просмотреть файл

@ -0,0 +1,9 @@
<script>
const {ipcRenderer} = require('electron')
navigator.mediaDevices.enumerateDevices().then((devices) => {
return devices.map((device) => device.deviceId)
.filter((deviceId) => deviceId !== "default")
}).then((deviceIds) => {
ipcRenderer.send('deviceIds', deviceIds)
})
</script>