Bug 1882089 - [remote] Update tests for explictly enabling the CDP protocol if needed. r=webdriver-reviewers,jdescottes

Differential Revision: https://phabricator.services.mozilla.com/D212908
This commit is contained in:
Henrik Skupin 2024-06-12 08:57:37 +00:00
Родитель 5098323b87
Коммит 130b05b763
19 изменённых файлов: 140 добавлений и 57 удалений

Просмотреть файл

@ -9,7 +9,6 @@ with Files("**"):
BROWSER_CHROME_MANIFESTS += [
"test/browser/browser.toml",
"test/browser/browser_cdp_only.toml",
"test/browser/dom/browser.toml",
"test/browser/emulation/browser.toml",
"test/browser/fetch/browser.toml",

Просмотреть файл

@ -5,9 +5,13 @@ args = [
"--remote-debugging-port",
"--remote-allow-origins=null",
]
prefs = [ # Bug 1600054: Make CDP Fission compatible
prefs = [
# CDP protocol is not Fission compatible
"fission.bfcacheInParent=false",
"fission.webContentIsolationStrategy=0",
# Only enable CDP protocol
"remote.active-protocols=2",
]
skip-if = [
"display == 'wayland'" # Bug 1861933: Timestamp unreliable due to worker setup
@ -23,6 +27,8 @@ support-files = [
["browser_httpd.js"]
["browser_interface.js"]
["browser_main_target.js"]
["browser_session.js"]

Просмотреть файл

@ -1,22 +0,0 @@
[DEFAULT]
tags = "cdp"
subsuite = "remote"
args = [
"--remote-debugging-port",
"--remote-allow-origins=null",
]
prefs = [ # Bug 1600054: Make CDP Fission compatible
"fission.bfcacheInParent=false",
"fission.webContentIsolationStrategy=0",
"remote.active-protocols=2",
]
skip-if = [
"display == 'wayland'" # Bug 1861933: Timestamp unreliable due to worker setup
]
support-files = [
"chrome-remote-interface.js",
"head.js",
]
["browser_interface.js"]

Просмотреть файл

@ -5,9 +5,13 @@ args = [
"--remote-debugging-port",
"--remote-allow-origins=null",
]
prefs = [ # Bug 1600054: Make CDP Fission compatible
prefs = [
# CDP protocol is not Fission compatible
"fission.bfcacheInParent=false",
"fission.webContentIsolationStrategy=0",
# Only enable CDP protocol
"remote.active-protocols=2",
]
skip-if = [
"display == 'wayland'" # Bug 1861933: Timestamp unreliable due to worker setup

Просмотреть файл

@ -5,9 +5,13 @@ args = [
"--remote-debugging-port",
"--remote-allow-origins=null",
]
prefs = [ # Bug 1600054: Make CDP Fission compatible
prefs = [
# CDP protocol is not Fission compatible
"fission.bfcacheInParent=false",
"fission.webContentIsolationStrategy=0",
# Only enable CDP protocol
"remote.active-protocols=2",
]
skip-if = [
"display == 'wayland'" # Bug 1861933: Timestamp unreliable due to worker setup

Просмотреть файл

@ -5,9 +5,13 @@ args = [
"--remote-debugging-port",
"--remote-allow-origins=null",
]
prefs = [ # Bug 1600054: Make CDP Fission compatible
prefs = [
# CDP protocol is not Fission compatible
"fission.bfcacheInParent=false",
"fission.webContentIsolationStrategy=0",
# Only enable CDP protocol
"remote.active-protocols=2",
]
skip-if = [
"display == 'wayland'" # Bug 1861933: Timestamp unreliable due to worker setup

Просмотреть файл

@ -5,9 +5,13 @@ args = [
"--remote-debugging-port",
"--remote-allow-origins=null",
]
prefs = [ # Bug 1600054: Make CDP Fission compatible
prefs = [
# CDP protocol is not Fission compatible
"fission.bfcacheInParent=false",
"fission.webContentIsolationStrategy=0",
# Only enable CDP protocol
"remote.active-protocols=2",
]
skip-if = [
"display == 'wayland'" # Bug 1861933: Timestamp unreliable due to worker setup

Просмотреть файл

@ -5,9 +5,13 @@ args = [
"--remote-debugging-port",
"--remote-allow-origins=null",
]
prefs = [ # Bug 1600054: Make CDP Fission compatible
prefs = [
# CDP protocol is not Fission compatible
"fission.bfcacheInParent=false",
"fission.webContentIsolationStrategy=0",
# Only enable CDP protocol
"remote.active-protocols=2",
]
skip-if = [
"display == 'wayland'" # Bug 1861933: Timestamp unreliable due to worker setup

Просмотреть файл

@ -5,9 +5,13 @@ args = [
"--remote-debugging-port",
"--remote-allow-origins=null",
]
prefs = [ # Bug 1600054: Make CDP Fission compatible
prefs = [
# CDP protocol is not Fission compatible
"fission.bfcacheInParent=false",
"fission.webContentIsolationStrategy=0",
# Only enable CDP protocol
"remote.active-protocols=2",
]
skip-if = [
"display == 'wayland'" # Bug 1861933: Timestamp unreliable due to worker setup

Просмотреть файл

@ -5,9 +5,13 @@ args = [
"--remote-debugging-port",
"--remote-allow-origins=null",
]
prefs = [ # Bug 1600054: Make CDP Fission compatible
prefs = [
# CDP protocol is not Fission compatible
"fission.bfcacheInParent=false",
"fission.webContentIsolationStrategy=0",
# Only enable CDP protocol
"remote.active-protocols=2",
]
skip-if = [
"display == 'wayland'" # Bug 1861933: Timestamp unreliable due to worker setup

Просмотреть файл

@ -5,9 +5,13 @@ args = [
"--remote-debugging-port",
"--remote-allow-origins=null",
]
prefs = [ # Bug 1600054: Make CDP Fission compatible
prefs = [
# CDP protocol is not Fission compatible
"fission.bfcacheInParent=false",
"fission.webContentIsolationStrategy=0",
# Only enable CDP protocol
"remote.active-protocols=2",
]
skip-if = [
"display == 'wayland'" # Bug 1861933: Timestamp unreliable due to worker setup

Просмотреть файл

@ -5,9 +5,13 @@ args = [
"--remote-debugging-port",
"--remote-allow-origins=null",
]
prefs = [ # Bug 1600054: Make CDP Fission compatible
prefs = [
# CDP protocol is not Fission compatible
"fission.bfcacheInParent=false",
"fission.webContentIsolationStrategy=0",
# Only enable CDP protocol
"remote.active-protocols=2",
]
skip-if = [
"display == 'wayland'" # Bug 1861933: Timestamp unreliable due to worker setup

Просмотреть файл

@ -5,6 +5,9 @@ args = [
"--remote-debugging-port",
"--remote-allow-origins=null",
]
prefs = [ # Only enable CDP protocol
"remote.active-protocols=2",
]
support-files = [
"!/remote/cdp/test/browser/chrome-remote-interface.js",
"!/remote/cdp/test/browser/head.js",

Просмотреть файл

@ -5,9 +5,13 @@ args = [
"--remote-debugging-port",
"--remote-allow-origins=null",
]
prefs = [ # Bug 1600054: Make CDP Fission compatible
prefs = [
# CDP protocol is not Fission compatible
"fission.bfcacheInParent=false",
"fission.webContentIsolationStrategy=0",
# Only enable CDP protocol
"remote.active-protocols=2",
]
skip-if = [
"display == 'wayland'" # Bug 1861933: Timestamp unreliable due to worker setup

Просмотреть файл

@ -5,9 +5,13 @@ args = [
"--remote-debugging-port",
"--remote-allow-origins=null",
]
prefs = [ # Bug 1600054: Make CDP Fission compatible
prefs = [
# CDP protocol is not Fission compatible
"fission.bfcacheInParent=false",
"fission.webContentIsolationStrategy=0",
# Only enable CDP protocol
"remote.active-protocols=2",
]
skip-if = [
"display == 'wayland'" # Bug 1861933: Timestamp unreliable due to worker setup

Просмотреть файл

@ -5,9 +5,13 @@ args = [
"--remote-debugging-port",
"--remote-allow-origins=null",
]
prefs = [ # Bug 1600054: Make CDP Fission compatible
prefs = [
# CDP protocol is not Fission compatible
"fission.bfcacheInParent=false",
"fission.webContentIsolationStrategy=0",
# Only enable CDP protocol
"remote.active-protocols=2",
]
skip-if = [
"display == 'wayland'" # Bug 1861933: Timestamp unreliable due to worker setup

Просмотреть файл

@ -28,8 +28,23 @@ class TestCommandLineArguments(MarionetteTestCase):
)
self.assertIsNone(debugger_address)
# With CDP enabled the capability has to be returned
self.marionette.set_pref("remote.active-protocols", 2)
self.marionette.quit()
self.marionette.instance.app_args.append("-remote-debugging-port")
self.marionette.start_session()
debugger_address = self.marionette.session_capabilities.get(
"moz:debuggerAddress"
)
self.assertEqual(debugger_address, "127.0.0.1:9222")
result = requests.get(url="http://{}/json/version".format(debugger_address))
self.assertTrue(result.ok)
# With BiDi only enabled the capability shouldn't be returned
self.marionette.set_pref("remote.active-protocols", 1)
self.marionette.clear_pref("remote.active-protocols")
self.marionette.quit()
self.marionette.instance.app_args.append("-remote-debugging-port")
@ -40,24 +55,14 @@ class TestCommandLineArguments(MarionetteTestCase):
)
self.assertIsNone(debugger_address)
# Clean the profile so that the preference is definetely reset.
# Clean the profile so that the preference is definitely reset.
self.marionette.quit(in_app=False, clean=True)
# With all protocols enabled again the capability has to be returned
self.marionette.start_session()
debugger_address = self.marionette.session_capabilities.get(
"moz:debuggerAddress"
)
self.assertEqual(debugger_address, "127.0.0.1:9222")
result = requests.get(url="http://{}/json/version".format(debugger_address))
self.assertTrue(result.ok)
def test_websocket_url(self):
# By default Remote Agent is not enabled
self.assertNotIn("webSocketUrl", self.marionette.session_capabilities)
# With CDP only enabled the capability is still not returned
# With CDP enabled the capability is not returned
self.marionette.set_pref("remote.active-protocols", 2)
self.marionette.quit()
@ -66,10 +71,10 @@ class TestCommandLineArguments(MarionetteTestCase):
self.assertNotIn("webSocketUrl", self.marionette.session_capabilities)
# Clean the profile so that the preference is definetely reset.
self.marionette.quit(in_app=False, clean=True)
# With all protocols enabled again the capability has to be returned
# With BiDi only enabled the capability is returned
self.marionette.clear_pref("remote.active-protocols")
self.marionette.quit()
self.marionette.instance.app_args.append("-remote-debugging-port")
self.marionette.start_session({"webSocketUrl": True})
session_id = self.marionette.session_id
@ -79,6 +84,9 @@ class TestCommandLineArguments(MarionetteTestCase):
websocket_url, "ws://127.0.0.1:9222/session/{}".format(session_id)
)
# Clean the profile so that the preference is definitely reset.
self.marionette.quit(in_app=False, clean=True)
# An issue in the command line argument handling lead to open Firefox on
# random URLs when remote-debugging-port is set to an explicit value, on macos.
# See Bug 1724251.

Просмотреть файл

@ -4,21 +4,55 @@ import json
import pytest
from support.context import using_context
from support.helpers import clear_pref
from tests.support.http_request import HTTPRequest
@pytest.fixture(autouse=True)
def clear_protocol_pref(session):
yield
clear_pref(session, "remote.active-protocols")
@pytest.mark.capabilities(
{
"moz:firefoxOptions": {
"prefs": {
"remote.active-protocols": 2,
},
},
}
)
def test_debugger_address_not_set(session):
debugger_address = session.capabilities.get("moz:debuggerAddress")
assert debugger_address is None
@pytest.mark.capabilities({"moz:debuggerAddress": False})
@pytest.mark.capabilities(
{
"moz:debuggerAddress": False,
"moz:firefoxOptions": {
"prefs": {
"remote.active-protocols": 2,
},
},
}
)
def test_debugger_address_false(session):
debugger_address = session.capabilities.get("moz:debuggerAddress")
assert debugger_address is None
@pytest.mark.capabilities({"moz:debuggerAddress": True})
@pytest.mark.capabilities(
{
"moz:debuggerAddress": True,
"moz:firefoxOptions": {
"prefs": {
"remote.active-protocols": 2,
},
},
}
)
@pytest.mark.parametrize("fission_enabled", [True, False], ids=["enabled", "disabled"])
def test_debugger_address_true_with_fission(session, fission_enabled):
debugger_address = session.capabilities.get("moz:debuggerAddress")

Просмотреть файл

@ -40,10 +40,10 @@ class Browser:
self.remote_agent_host = None
self.remote_agent_port = None
if self.extra_prefs is not None:
self.profile.set_preferences(self.extra_prefs)
active_protocols = 0
if use_cdp:
active_protocols += 2
self.cdp_port_file = os.path.join(
self.profile.profile, "DevToolsActivePort"
)
@ -51,12 +51,19 @@ class Browser:
os.remove(self.cdp_port_file)
if use_bidi:
active_protocols += 1
self.webdriver_bidi_file = os.path.join(
self.profile.profile, "WebDriverBiDiServer.json"
)
with suppress(FileNotFoundError):
os.remove(self.webdriver_bidi_file)
# Avoid modifying extra_prefs to prevent side-effects with the "browser" fixture,
# which checks session equality and would create a new session each time.
prefs = self.extra_prefs or {}
prefs.update({"remote.active-protocols": active_protocols})
self.profile.set_preferences(prefs)
cmdargs = ["-no-remote"]
if self.use_bidi or self.use_cdp:
cmdargs.extend(["--remote-debugging-port", "0"])