@@ -31,46 +31,45 @@ const { CreateContextParameters } = require('selenium-webdriver/bidi/createConte
3131suite (
3232 function ( env ) {
3333 describe ( 'BiDi Emulation' , function ( ) {
34- let driver , emulation , permission , script , browser
34+ let driver , emulation , permission , script , browser , windowHandle
3535
3636 const GET_ORIGIN = '() => {return window.location.origin;}'
3737
3838 const GET_CURRENT_GEOLOCATION = `
39- new Promise((resolve) => {
40- navigator.geolocation.getCurrentPosition(
41- position => {
42- const coords = position.coords;
43- resolve({
44- latitude: coords.latitude,
45- longitude: coords.longitude,
46- accuracy: coords.accuracy,
47- altitude: coords.altitude,
48- altitudeAccuracy: coords.altitudeAccuracy,
49- heading: coords.heading,
50- speed: coords.speed,
51- timestamp: position.timestamp
52- });
53- },
54- error => resolve({ error: error.message }),
55- { enableHighAccuracy: false, timeout: 10000, maximumAge: 0 }
56- );
57- })
58- `
39+ new Promise((resolve) => {
40+ navigator.geolocation.getCurrentPosition(
41+ position => {
42+ const coords = position.coords;
43+ resolve({
44+ latitude: coords.latitude,
45+ longitude: coords.longitude,
46+ accuracy: coords.accuracy,
47+ altitude: coords.altitude,
48+ altitudeAccuracy: coords.altitudeAccuracy,
49+ heading: coords.heading,
50+ speed: coords.speed,
51+ timestamp: position.timestamp
52+ });
53+ },
54+ error => resolve({ error: error.message }),
55+ { enableHighAccuracy: false, timeout: 10000, maximumAge: 0 }
56+ );
57+ })`
5958
6059 beforeEach ( async function ( ) {
6160 driver = await env . builder ( ) . build ( )
6261 emulation = await getEmulationInstance ( driver )
6362 permission = await getPermissionInstance ( driver )
6463 script = await getScriptManager ( [ ] , driver )
6564 browser = await BrowserBiDi ( driver )
65+ windowHandle = await driver . getWindowHandle ( )
6666 } )
6767
6868 afterEach ( function ( ) {
6969 return driver . quit ( )
7070 } )
7171
7272 it ( 'can override geolocation for browsing context' , async function ( ) {
73- const windowHandle = await driver . getWindowHandle ( )
7473 const context = await BrowsingContext ( driver , { browsingContextId : windowHandle } )
7574 await context . navigate ( Pages . blankPage , 'complete' )
7675
@@ -137,7 +136,6 @@ suite(
137136 } )
138137
139138 ignore ( env . browsers ( Browser . FIREFOX ) ) . it ( 'can override geolocation with error' , async function ( ) {
140- const windowHandle = await driver . getWindowHandle ( )
141139 const context = await BrowsingContext ( driver , { browsingContextId : windowHandle } )
142140 await context . navigate ( Pages . blankPage , 'complete' )
143141
0 commit comments