brizental pushed to branch tor-browser-149.0a1-16.0-2 at The Tor Project / Applications / Tor Browser

Commits:

2 changed files:

Changes:

  • testing/marionette/harness/marionette_harness/runner/mixins/tor_browser.py
    1
    +from marionette_driver import Wait
    
    1 2
     from marionette_driver.errors import ScriptTimeoutException
    
    2 3
     
    
    3 4
     DEFAULT_BOOTSTRAP_TIMEOUT_MS = 60 * 1000
    
    ... ... @@ -20,7 +21,7 @@ class TorBrowserMixin:
    20 21
             while attempt < max_retries:
    
    21 22
                 try:
    
    22 23
                     with self.marionette.using_context("chrome"):
    
    23
    -                    self.marionette.execute_async_script(
    
    24
    +                    did_bootstrap = self.marionette.execute_async_script(
    
    24 25
                             """
    
    25 26
                             const { TorConnect, TorConnectStage, TorConnectTopics } = ChromeUtils.importESModule(
    
    26 27
                                 "resource://gre/modules/TorConnect.sys.mjs"
    
    ... ... @@ -29,7 +30,7 @@ class TorBrowserMixin:
    29 30
     
    
    30 31
                             // Only the first test of a suite will need to bootstrap.
    
    31 32
                             if (TorConnect.stage.name === TorConnectStage.Bootstrapped) {
    
    32
    -                            resolve();
    
    33
    +                            resolve(false);
    
    33 34
                                 return;
    
    34 35
                             }
    
    35 36
     
    
    ... ... @@ -37,7 +38,7 @@ class TorBrowserMixin:
    37 38
                                 const topic = TorConnectTopics.BootstrapComplete;
    
    38 39
                                 Services.obs.addObserver(function observer() {
    
    39 40
                                     Services.obs.removeObserver(observer, topic);
    
    40
    -                                resolve();
    
    41
    +                                resolve(true);
    
    41 42
                                 }, topic);
    
    42 43
                                 TorConnect.beginBootstrapping();
    
    43 44
                             }
    
    ... ... @@ -55,6 +56,23 @@ class TorBrowserMixin:
    55 56
                             script_timeout=DEFAULT_BOOTSTRAP_TIMEOUT_MS,
    
    56 57
                         )
    
    57 58
     
    
    59
    +                # The above script waits for bootstrap to be complete,
    
    60
    +                # but doesn't wait for the redirection to about:blank that
    
    61
    +                # happens after bootstrap to be complete.
    
    62
    +                #
    
    63
    +                # We need to wait for this navigation to complete,
    
    64
    +                # otherwise subsequent calls to navigate may race with it.
    
    65
    +                #
    
    66
    +                # Android doesn't do any redirection, the tor connect UI in
    
    67
    +                # there is native and the initial state of the browser
    
    68
    +                # doesn't even have an open tab to check against.
    
    69
    +                # So we skip this check for that platform.
    
    70
    +                if did_bootstrap and self.marionette.session_capabilities.get("browserName") != "fennec":
    
    71
    +                    Wait(self.marionette).until(
    
    72
    +                        lambda mn: mn.get_url() == "about:blank",
    
    73
    +                        message="Still not in about:blank",
    
    74
    +                    )
    
    75
    +
    
    58 76
                     return
    
    59 77
                 except ScriptTimeoutException:
    
    60 78
                     attempt += 1
    

  • testing/tor/test_circuit_isolation.py
    ... ... @@ -31,8 +31,11 @@ class TestCircuitIsolation(MarionetteTestCase, TorBrowserMixin):
    31 31
                 By.CLASS_NAME,
    
    32 32
                 "off",
    
    33 33
             )
    
    34
    -        ip = self.marionette.find_element(By.TAG_NAME, "strong")
    
    35
    -        return ip_address(ip.text.strip())
    
    34
    +        ip = self.marionette.execute_script(
    
    35
    +            "return document.querySelector('strong').textContent"
    
    36
    +        ).strip()
    
    37
    +
    
    38
    +        return ip_address(ip)
    
    36 39
     
    
    37 40
         def extract_generic(self, url):
    
    38 41
             # Fetch the IP address from any generic page that only contains
    
    ... ... @@ -49,7 +52,7 @@ class TestCircuitIsolation(MarionetteTestCase, TorBrowserMixin):
    49 52
             ips = [
    
    50 53
                 self.extract_from_check_tpo(),
    
    51 54
                 self.extract_generic("https://am.i.mullvad.net/ip"),
    
    52
    -            self.extract_generic("https://test1.ifconfig.me/ip"),
    
    55
    +            self.extract_generic("https://v4.ident.me"),
    
    53 56
             ]
    
    54 57
             self.logger.info(f"Found the following IP addresses: {ips}")
    
    55 58
             unique_ips = set(ips)
    
    ... ... @@ -59,9 +62,12 @@ class TestCircuitIsolation(MarionetteTestCase, TorBrowserMixin):
    59 62
                 len(unique_ips),
    
    60 63
                 "Some of the IP addresses we got are not unique.",
    
    61 64
             )
    
    62
    -        duplicate = self.extract_generic("https://test2.ifconfig.me/ip")
    
    63
    -        self.assertEqual(
    
    64
    -            ips[-1],
    
    65
    -            duplicate,
    
    66
    -            "Two IPs that were expected to be equal are different, we might be over isolating!",
    
    67
    -        )
    65
    +
    
    66
    +        # TODO: Renable the duplicate check once
    
    67
    +        # https://gitlab.torproject.org/tpo/tpa/team/-/issues/42547 is resolved.
    
    68
    +        # duplicate = self.extract_generic("https://test2.ifconfig.me/ip")
    
    69
    +        # self.assertEqual(
    
    70
    +        #     ips[-1],
    
    71
    +        #     duplicate,
    
    72
    +        #     "Two IPs that were expected to be equal are different, we might be over isolating!",
    
    73
    +        # )