Debian Codegraph @

testing/web-platform/mozilla/tests/webdriver/cdp/debugger_address.py

raw
1 # META: timeout=long
2
3 import json
4
5 import pytest
6 from support.context import using_context
7 from support.helpers import clear_pref
8 from tests.support.http_request import HTTPRequest
9
10
11 @pytest.fixture(autouse=True)
12 def clear_protocol_pref(session):
13 yield
14 clear_pref(session, "remote.active-protocols")
15
16
17 @pytest.mark.allow_system_access
18 @pytest.mark.capabilities(
19 {
20 "moz:firefoxOptions": {
21 "prefs": {
22 "remote.active-protocols": 2,
23 },
24 },
25 }
26 )
27 def test_debugger_address_not_set(session, capabilities):
28 debugger_address = session.capabilities.get("moz:debuggerAddress")
29 assert debugger_address is None
30
31
32 @pytest.mark.allow_system_access
33 @pytest.mark.capabilities(
34 {
35 "moz:debuggerAddress": False,
36 "moz:firefoxOptions": {
37 "prefs": {
38 "remote.active-protocols": 2,
39 },
40 },
41 }
42 )
43 def test_debugger_address_false(session):
44 debugger_address = session.capabilities.get("moz:debuggerAddress")
45 assert debugger_address is None
46
47
48 @pytest.mark.allow_system_access
49 @pytest.mark.capabilities(
50 {
51 "moz:debuggerAddress": True,
52 "moz:firefoxOptions": {
53 "prefs": {
54 "remote.active-protocols": 2,
55 },
56 },
57 }
58 )
59 @pytest.mark.parametrize("fission_enabled", [True, False], ids=["enabled", "disabled"])
60 def test_debugger_address_true_with_fission(session, capabilities, fission_enabled):
61 debugger_address = session.capabilities.get("moz:debuggerAddress")
62 assert debugger_address is not None
63
64 host, port = debugger_address.split(":")
65 assert host == "127.0.0.1"
66 assert port.isnumeric()
67
68 # Fetch the browser version via the debugger address, `localhost` has
69 # to work as well.
70 for target_host in [host, "localhost"]:
71 print(f"Connecting to WebSocket via host {target_host}")
72 http = HTTPRequest(target_host, int(port))
73 with http.get("/json/version") as response:
74 data = json.loads(response.read())
75 assert session.capabilities["browserVersion"] in data["Browser"]
76
77 # Ensure Fission is not disabled (bug 1813981)
78 with using_context(session, "chrome"):
79 assert (
80 session.execute_script("""return Services.appinfo.fissionAutostart""")
81 is fission_enabled
82 )