feat: promisify webContents.hasServiceWorker() (#16535)

* feat: promisify contents.hasServiceWorker()

* spec: add initial test for hasServiceWorker()
This commit is contained in:
Shelley Vohr 2019-01-26 10:23:16 -08:00 committed by GitHub
parent 5a35c3a279
commit d105dcc0d3
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
8 changed files with 60 additions and 23 deletions

View file

@ -228,6 +228,23 @@ describe('webContents module', () => {
})
})
describe('ServiceWorker APIs', () => {
it('can successfully register a ServiceWorker', async () => {
await w.loadFile(path.join(fixtures, 'api', 'service-worker', 'service-worker.html'))
const hasSW = await w.webContents.hasServiceWorker()
expect(hasSW).to.be.true()
})
it('can successfully register a ServiceWorker (callback)', (done) => {
w.loadFile(path.join(fixtures, 'api', 'service-worker', 'service-worker.html')).then(() => {
w.webContents.hasServiceWorker(hasSW => {
expect(hasSW).to.be.true()
done()
})
})
})
})
describe('isCurrentlyAudible() API', () => {
it('returns whether audio is playing', async () => {
const webContents = remote.getCurrentWebContents()