summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/mozilla/tests/webdriver/cdp/port_file.py
blob: 23c31906faaafd20202250d0abe7b28742538880 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
import os

from support.network import websocket_request


def test_devtools_active_port_file(browser):
    current_browser = browser(use_cdp=True, clone_profile=False)

    assert current_browser.remote_agent_port != 0
    assert current_browser.debugger_address.startswith("/devtools/browser/")

    port_file = os.path.join(current_browser.profile.profile, "DevToolsActivePort")
    assert os.path.exists(port_file)


def test_connect(browser):
    current_browser = browser(use_cdp=True)

    # Both `localhost` and `127.0.0.1` have to accept connections.
    for target_host in ["127.0.0.1", "localhost"]:
        print(f"Connecting to the WebSocket via host {target_host}")
        response = websocket_request(
            target_host,
            current_browser.remote_agent_port,
            path=current_browser.debugger_address,
        )
        assert response.status == 101