up
This commit is contained in:
+14
-52
@@ -78,6 +78,14 @@ app.whenReady().then(async () => {
|
||||
return s.status !== 'pending' && s.command.id === id && s
|
||||
}, id)
|
||||
}
|
||||
await evaluate(
|
||||
`Array.from(document.querySelectorAll('button')).find(b => b.textContent.includes('Пуск с начала')).click()`,
|
||||
)
|
||||
await poll(async () => {
|
||||
const state = await evaluate('window.screenBridge.state()')
|
||||
if (state.status === 'error') throw new Error(state.error)
|
||||
return state.status === 'playing'
|
||||
}, 'computer UI play')
|
||||
assert.equal((await command('audio-play', 'play')).status, 'playing')
|
||||
assert.equal((await command('audio-pause', 'pause')).status, 'paused')
|
||||
assert.equal((await command('audio-stop', 'stop')).status, 'stopped')
|
||||
@@ -101,59 +109,13 @@ app.whenReady().then(async () => {
|
||||
`window.screenBridge.command({id:'forbidden', action:'play', media:'audio', position:0})`,
|
||||
),
|
||||
)
|
||||
const network = (await evaluate('window.screenBridge.host()')).lan[0]
|
||||
assert.ok(network, 'LAN interface available for browser smoke')
|
||||
await evaluate(`window.screenBridge.lan(${JSON.stringify(network.address)})`)
|
||||
const host = await evaluate('window.screenBridge.host()')
|
||||
const phone = new BrowserWindow({
|
||||
show: false,
|
||||
webPreferences: {
|
||||
nodeIntegration: false,
|
||||
contextIsolation: true,
|
||||
sandbox: true,
|
||||
backgroundThrottling: false,
|
||||
partition: 'screen-smoke-phone',
|
||||
},
|
||||
})
|
||||
assert.equal((await fetch(host.url)).status, 200)
|
||||
await phone.webContents.session.setProxy({ mode: 'direct' })
|
||||
await phone.loadURL(host.url)
|
||||
const phoneEval = (s) => phone.webContents.executeJavaScript(s)
|
||||
await poll(async () => await phoneEval('!!document.querySelector("input")'), 'phone UI')
|
||||
assert.equal(await phoneEval('typeof window.screenBridge'), 'undefined')
|
||||
await phoneEval(
|
||||
`(() => {const input = document.querySelector('input'); input.value = ${JSON.stringify(host.code)}; input.dispatchEvent(new Event('input', {bubbles:true}));})()`,
|
||||
assert.equal(
|
||||
await evaluate("document.body.textContent.includes('Телефон по локальной сети')"),
|
||||
false,
|
||||
)
|
||||
await delay(100)
|
||||
await phoneEval(
|
||||
`Array.from(document.querySelectorAll('button')).find(b => b.textContent.includes('Подключиться')).click()`,
|
||||
)
|
||||
const pending = await poll(
|
||||
async () => (await evaluate('window.screenBridge.host()')).pending[0],
|
||||
'pair request from phone UI',
|
||||
)
|
||||
await evaluate(`window.screenBridge.approve(${JSON.stringify(pending)})`)
|
||||
await poll(
|
||||
async () =>
|
||||
await phoneEval(
|
||||
`!Array.from(document.querySelectorAll('button')).find(b => b.textContent.includes('Пуск с начала')).disabled`,
|
||||
),
|
||||
'phone connected',
|
||||
)
|
||||
await phoneEval(
|
||||
`Array.from(document.querySelectorAll('button')).find(b => b.textContent.includes('Пуск с начала')).click()`,
|
||||
)
|
||||
await poll(async () => {
|
||||
const state = await evaluate('window.screenBridge.state()')
|
||||
return state.status === 'playing' && state.samples.some((s) => s.origin === 'phone')
|
||||
}, 'phone play')
|
||||
await command('computer-after-phone', 'pause')
|
||||
await evaluate('window.screenBridge.lan(null)')
|
||||
await poll(
|
||||
async () => await phoneEval(`document.body.textContent.includes('Нет связи')`),
|
||||
'phone revoked',
|
||||
)
|
||||
phone.close()
|
||||
assert.deepEqual(Object.keys(await evaluate('window.screenBridge.host()')), ['displays'])
|
||||
assert.equal(await evaluate('typeof window.screenBridge.lan'), 'undefined')
|
||||
assert.equal(await evaluate('typeof window.screenBridge.approve'), 'undefined')
|
||||
output.close()
|
||||
await evaluate('window.screenBridge.show(424242)')
|
||||
const reopened = await poll(
|
||||
|
||||
Reference in New Issue
Block a user