fix: opt into location services once device service has been started (#14253)
* fix: opt into location services once device service has been started * refactor: provide fake location provider to mock geolocation reponses * chore: add spec for navigator.geolocation api using fake location provider
This commit is contained in:
parent
c8f506a8aa
commit
bce5bd87a8
13 changed files with 209 additions and 11 deletions
|
@ -226,6 +226,47 @@ describe('chromium feature', () => {
|
|||
})
|
||||
})
|
||||
|
||||
describe('navigator.geolocation', () => {
|
||||
before(function () {
|
||||
if (!features.isFakeLocationProviderEnabled()) {
|
||||
return this.skip()
|
||||
}
|
||||
})
|
||||
|
||||
it('returns position when permission is granted', (done) => {
|
||||
navigator.geolocation.getCurrentPosition((position) => {
|
||||
assert(position.timestamp)
|
||||
done()
|
||||
}, (error) => {
|
||||
done(error)
|
||||
})
|
||||
})
|
||||
|
||||
it('returns error when permission is denied', (done) => {
|
||||
w = new BrowserWindow({
|
||||
show: false,
|
||||
webPreferences: {
|
||||
partition: 'geolocation-spec'
|
||||
}
|
||||
})
|
||||
w.webContents.on('ipc-message', (event, args) => {
|
||||
if (args[0] === 'success') {
|
||||
done()
|
||||
} else {
|
||||
done('unexpected response from geolocation api')
|
||||
}
|
||||
})
|
||||
w.webContents.session.setPermissionRequestHandler((wc, permission, callback) => {
|
||||
if (permission === 'geolocation') {
|
||||
callback(false)
|
||||
} else {
|
||||
callback(true)
|
||||
}
|
||||
})
|
||||
w.loadURL(`file://${fixtures}/pages/geolocation/index.html`)
|
||||
})
|
||||
})
|
||||
|
||||
describe('window.open', () => {
|
||||
it('returns a BrowserWindowProxy object', () => {
|
||||
const b = window.open('about:blank', '', 'show=no')
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue