зеркало из https://github.com/electron/electron.git
add spec
This commit is contained in:
Родитель
3de3fb53bd
Коммит
e043dabcb8
|
@ -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 () {
|
||||
|
|
|
@ -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>
|
Загрузка…
Ссылка в новой задаче