Bug 1680114 - [geckodriver] Set fission.autostart=false when moz:debuggerAddress is requested. r=webdriver-reviewers,jgraham
authorHenrik Skupin <mail@hskupin.info>
Fri, 04 Dec 2020 09:53:26 +0000
changeset 559420 c22c3f6c8eadfaf2cf1678f1d78d4f2de1093e74
parent 559419 6e45b8c280e020d31f69085bf5b77d5b4186ce27
child 559421 0bb1bdd259916f3b13683ae43861c80a81705527
push id38004
push userncsoregi@mozilla.com
push dateFri, 04 Dec 2020 16:21:20 +0000
treeherdermozilla-central@c22c3f6c8ead [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerswebdriver-reviewers, jgraham
bugs1680114
milestone85.0a1
first release with
nightly linux32
c22c3f6c8ead / 85.0a1 / 20201204162120 / files
nightly linux64
c22c3f6c8ead / 85.0a1 / 20201204162120 / files
nightly mac
c22c3f6c8ead / 85.0a1 / 20201204162120 / files
nightly win32
c22c3f6c8ead / 85.0a1 / 20201204162120 / files
nightly win64
c22c3f6c8ead / 85.0a1 / 20201204162120 / files
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
releases
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1680114 - [geckodriver] Set fission.autostart=false when moz:debuggerAddress is requested. r=webdriver-reviewers,jgraham Differential Revision: https://phabricator.services.mozilla.com/D98439
testing/geckodriver/src/capabilities.rs
testing/web-platform/mozilla/meta/webdriver/new_session/debugger_address.py.ini
testing/web-platform/mozilla/tests/webdriver/new_session/debugger_address.py
--- a/testing/geckodriver/src/capabilities.rs
+++ b/testing/geckodriver/src/capabilities.rs
@@ -422,16 +422,24 @@ impl FirefoxOptions {
                 remote_args.push("--remote-debugging-port".to_owned());
                 remote_args.push("0".to_owned());
 
                 if let Some(ref mut args) = rv.args {
                     args.append(&mut remote_args);
                 } else {
                     rv.args = Some(remote_args);
                 }
+
+                // Force Fission disabled until Remote Agent is compatible,
+                // and preference hasn't been already set
+                let has_fission_pref = rv.prefs.iter().find(|&x| x.0 == "fission.autostart");
+                if has_fission_pref.is_none() {
+                    rv.prefs
+                        .push(("fission.autostart".to_owned(), Pref::new(false)));
+                }
             }
         }
 
         Ok(rv)
     }
 
     fn load_profile(options: &Capabilities) -> WebDriverResult<Option<Profile>> {
         if let Some(profile_json) = options.get("profile") {
@@ -826,16 +834,21 @@ mod tests {
             let mut iter = args.iter();
             assert!(iter
                 .find(|&arg| arg == &"--remote-debugging-port".to_owned())
                 .is_some());
             assert_eq!(iter.next(), Some(&"0".to_owned()));
         } else {
             assert!(false, "CLI arguments for remote protocol not found");
         }
+
+        assert!(opts
+            .prefs
+            .iter()
+            .any(|pref| pref == &("fission.autostart".to_owned(), Pref::new(false))));
     }
 
     #[test]
     fn fx_options_from_capabilities_with_invalid_caps() {
         let mut caps = Capabilities::new();
         caps.insert("moz:firefoxOptions".into(), json!(42));
 
         FirefoxOptions::from_capabilities(None, AndroidStorageInput::Auto, &mut caps)
--- a/testing/web-platform/mozilla/meta/webdriver/new_session/debugger_address.py.ini
+++ b/testing/web-platform/mozilla/meta/webdriver/new_session/debugger_address.py.ini
@@ -1,8 +1,10 @@
 [debugger_address.py]
   disabled:
     if os == 'win' and ccov: https://bugzilla.mozilla.org/show_bug.cgi?id=1677750
 
-  [test_debugger_address_true]
+  [test_debugger_address_true[capabilities0\]]
     bug: https://bugzilla.mozilla.org/show_bug.cgi?id=1606604
     expected:
       if not nightly_build: FAIL
+    disabled:
+      if fission: (not supported)
--- a/testing/web-platform/mozilla/tests/webdriver/new_session/debugger_address.py
+++ b/testing/web-platform/mozilla/tests/webdriver/new_session/debugger_address.py
@@ -1,46 +1,74 @@
 import json
 
-from tests.support.asserts import assert_success
+import pytest
+
 from tests.support.http_request import HTTPRequest
 
 
-def test_debugger_address_not_set(new_session, configuration):
-    capabilities = dict(configuration["capabilities"])
+def set_context(session, context):
+    body = {"context": context}
+    session.send_session_command("POST", "moz/context", body)
 
-    response, _ = new_session({"capabilities": {"alwaysMatch": capabilities}})
-    result = assert_success(response)
 
-    debugger_address = result["capabilities"].get("moz:debuggerAddress")
+def test_debugger_address_not_set(session):
+    debugger_address = session.capabilities.get("moz:debuggerAddress")
     assert debugger_address is None
 
 
-def test_debugger_address_false(new_session, configuration):
-    capabilities = dict(configuration["capabilities"])
-    capabilities["moz:debuggerAddress"] = False
-
-    response, _ = new_session({"capabilities": {"alwaysMatch": capabilities}})
-    result = assert_success(response)
-
-    debugger_address = result["capabilities"].get("moz:debuggerAddress")
+@pytest.mark.capabilities({"moz:debuggerAddress": False})
+def test_debugger_address_false(session):
+    debugger_address = session.capabilities.get("moz:debuggerAddress")
     assert debugger_address is None
 
 
-def test_debugger_address_true(new_session, configuration):
-    capabilities = dict(configuration["capabilities"])
-    capabilities["moz:debuggerAddress"] = True
-
-    response, _ = new_session({"capabilities": {"alwaysMatch": capabilities}})
-    result = assert_success(response)
-
-    debugger_address = result["capabilities"].get("moz:debuggerAddress")
+@pytest.mark.capabilities({"moz:debuggerAddress": True})
+def test_debugger_address_true(session):
+    debugger_address = session.capabilities.get("moz:debuggerAddress")
     assert debugger_address is not None
 
     host, port = debugger_address.split(":")
     assert host == "localhost"
     assert port.isnumeric()
 
     # Fetch the browser version via the debugger address
     http = HTTPRequest(host, int(port))
     with http.get("/json/version") as response:
         data = json.loads(response.read())
-        assert result["capabilities"]["browserVersion"] in data["Browser"]
+        assert session.capabilities["browserVersion"] in data["Browser"]
+
+    # Force disabling Fission until Remote Agent is compatible
+    set_context(session, "chrome")
+    assert (
+        session.execute_script("""return Services.appinfo.fissionAutostart""") is False
+    )
+
+
+@pytest.mark.capabilities(
+    {
+        "moz:debuggerAddress": True,
+        "moz:firefoxOptions": {
+            "prefs": {
+                "fission.autostart": True,
+            }
+        },
+    }
+)
+def test_debugger_address_true_fission_override(session):
+    debugger_address = session.capabilities.get("moz:debuggerAddress")
+    assert debugger_address is not None
+
+    host, port = debugger_address.split(":")
+    assert host == "localhost"
+    assert port.isnumeric()
+
+    # Fetch the browser version via the debugger address
+    http = HTTPRequest(host, int(port))
+    with http.get("/json/version") as response:
+        data = json.loads(response.read())
+        assert session.capabilities["browserVersion"] in data["Browser"]
+
+    # Allow Fission to be enabled when setting the preference
+    set_context(session, "chrome")
+    assert (
+        session.execute_script("""return Services.appinfo.fissionAutostart""") is True
+    )