Skip to content

Commit 0b2bb9a

Browse files
lauromouradiemol
andauthored
py: Don't expose 0.0.0.0 as destination IP for tests (#14324)
Webkit recently[1] started blocking 0.0.0.0 as destination addresses, and Chrome is also in the process of enabling such change[2]. This commit falls back to use the default localhost IP instead of 0.0.0.0 if we don't want to use the real IP. And if the server is actually using 0.0.0.0, fallback to localhost when generating the URL for the tests. [1] WebKit/WebKit@e59cd4a [2] https://chromestatus.com/feature/5106143060033536 Co-authored-by: Diego Molina <[email protected]>
1 parent c9f60ef commit 0b2bb9a

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

py/conftest.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -320,7 +320,7 @@ def wait_for_server(url, timeout):
320320

321321
@pytest.fixture(autouse=True, scope="session")
322322
def webserver(request):
323-
host = get_lan_ip() if request.config.getoption("use_lan_ip") else "0.0.0.0"
323+
host = get_lan_ip() if request.config.getoption("use_lan_ip") else None
324324

325325
webserver = SimpleWebServer(host=host)
326326
webserver.start()

py/test/selenium/webdriver/common/webserver.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ class SimpleWebServer:
138138

139139
def __init__(self, host=DEFAULT_HOST_IP, port=DEFAULT_PORT):
140140
self.stop_serving = False
141-
host = host
141+
host = host if host else DEFAULT_HOST_IP
142142
port = port
143143
while True:
144144
try:
@@ -171,7 +171,8 @@ def stop(self):
171171

172172
def where_is(self, path, localhost=False) -> str:
173173
# True force serve the page from localhost
174-
if localhost:
174+
# 0.0.0.0 shouldn't be used as a destination address, so fallback to localhost
175+
if localhost or self.host == "0.0.0.0":
175176
return f"http://{DEFAULT_HOST}:{self.port}/{path}"
176177
return f"http://{self.host}:{self.port}/{path}"
177178

0 commit comments

Comments
 (0)