Skip to content

Commit e4565b8

Browse files
fix geolocation tests
1 parent b2b2cea commit e4565b8

File tree

2 files changed

+22
-16
lines changed

2 files changed

+22
-16
lines changed

tests/emulation/__snapshots__/test_geolocation.ambr

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# serializer version: 1
2-
# name: test_geolocation_emulate_unavailable
2+
# name: test_geolocation_emulate_unavailable[capabilities0]
33
dict({
44
'type': 'object',
55
'value': list([
@@ -13,7 +13,7 @@
1313
]),
1414
})
1515
# ---
16-
# name: test_geolocation_per_user_context
16+
# name: test_geolocation_per_user_context[capabilities0]
1717
dict({
1818
'type': 'object',
1919
'value': list([
@@ -69,7 +69,7 @@
6969
]),
7070
})
7171
# ---
72-
# name: test_geolocation_per_user_context.1
72+
# name: test_geolocation_per_user_context[capabilities0].1
7373
dict({
7474
'type': 'object',
7575
'value': list([
@@ -121,7 +121,7 @@
121121
]),
122122
})
123123
# ---
124-
# name: test_geolocation_set_and_clear
124+
# name: test_geolocation_set_and_clear[capabilities0]
125125
dict({
126126
'type': 'object',
127127
'value': list([
@@ -177,7 +177,7 @@
177177
]),
178178
})
179179
# ---
180-
# name: test_geolocation_set_and_clear.1
180+
# name: test_geolocation_set_and_clear[capabilities0].1
181181
dict({
182182
'type': 'object',
183183
'value': list([

tests/emulation/test_geolocation.py

Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,12 @@
4545
'accuracy': ANOTHER_ACCURACY,
4646
}
4747

48+
# Geolocation permissions require secure context (either `Secure` or `SecureLocalhost`).
49+
pytestmark = pytest.mark.parametrize('capabilities', [{
50+
'acceptInsecureCerts': True
51+
}],
52+
indirect=True)
53+
4854

4955
async def get_geolocation(websocket, context_id):
5056
"""
@@ -73,11 +79,11 @@ async def get_geolocation(websocket, context_id):
7379

7480

7581
@pytest.mark.asyncio
76-
async def test_geolocation_set_and_clear(websocket, context_id, url_example,
82+
async def test_geolocation_set_and_clear(websocket, context_id, url_bad_ssl,
7783
snapshot):
78-
await goto_url(websocket, context_id, url_example)
84+
await goto_url(websocket, context_id, url_bad_ssl)
7985

80-
await set_permission(websocket, get_origin(url_example),
86+
await set_permission(websocket, get_origin(url_bad_ssl),
8187
{'name': 'geolocation'}, 'granted')
8288

8389
initial_geolocation = await get_geolocation(websocket, context_id)
@@ -125,10 +131,10 @@ async def test_geolocation_set_and_clear(websocket, context_id, url_example,
125131

126132
@pytest.mark.asyncio
127133
async def test_geolocation_emulate_unavailable(websocket, context_id,
128-
url_example, snapshot):
129-
await goto_url(websocket, context_id, url_example)
134+
url_bad_ssl, snapshot):
135+
await goto_url(websocket, context_id, url_bad_ssl)
130136

131-
await set_permission(websocket, get_origin(url_example),
137+
await set_permission(websocket, get_origin(url_bad_ssl),
132138
{'name': 'geolocation'}, 'granted')
133139

134140
initial_geolocation = await get_geolocation(websocket, context_id)
@@ -165,12 +171,12 @@ async def test_geolocation_emulate_unavailable(websocket, context_id,
165171

166172

167173
@pytest.mark.asyncio
168-
async def test_geolocation_per_user_context(websocket, url_example,
174+
async def test_geolocation_per_user_context(websocket, url_bad_ssl,
169175
user_context_id, create_context,
170176
snapshot):
171-
await set_permission(websocket, get_origin(url_example),
177+
await set_permission(websocket, get_origin(url_bad_ssl),
172178
{'name': 'geolocation'}, 'granted', "default")
173-
await set_permission(websocket, get_origin(url_example),
179+
await set_permission(websocket, get_origin(url_bad_ssl),
174180
{'name': 'geolocation'}, 'granted', user_context_id)
175181

176182
# Set different geolocation overrides for different user contexts.
@@ -193,13 +199,13 @@ async def test_geolocation_per_user_context(websocket, url_example,
193199

194200
# Assert the overrides applied for the right contexts.
195201
browsing_context_id_1 = await create_context()
196-
await goto_url(websocket, browsing_context_id_1, url_example)
202+
await goto_url(websocket, browsing_context_id_1, url_bad_ssl)
197203
emulated_geolocation_1 = await get_geolocation(websocket,
198204
browsing_context_id_1)
199205
assert emulated_geolocation_1 == snapshot()
200206

201207
browsing_context_id_2 = await create_context(user_context_id)
202-
await goto_url(websocket, browsing_context_id_2, url_example)
208+
await goto_url(websocket, browsing_context_id_2, url_bad_ssl)
203209
emulated_geolocation_2 = await get_geolocation(websocket,
204210
browsing_context_id_2)
205211
assert emulated_geolocation_2 == snapshot()

0 commit comments

Comments
 (0)