tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

test_cli_arguments.py (2275B)


      1 # This Source Code Form is subject to the terms of the Mozilla Public
      2 # License, v. 2.0. If a copy of the MPL was not distributed with this
      3 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
      4 
      5 import copy
      6 
      7 import requests
      8 
      9 from marionette_harness import MarionetteTestCase
     10 
     11 
     12 class TestCommandLineArguments(MarionetteTestCase):
     13    def setUp(self):
     14        super(TestCommandLineArguments, self).setUp()
     15 
     16        self.orig_arguments = copy.copy(self.marionette.instance.app_args)
     17 
     18    def tearDown(self):
     19        self.marionette.instance.app_args = self.orig_arguments
     20        self.marionette.quit(in_app=False, clean=True)
     21 
     22        super(TestCommandLineArguments, self).tearDown()
     23 
     24    def test_websocket_url(self):
     25        # By default Remote Agent is not enabled
     26        self.assertNotIn("webSocketUrl", self.marionette.session_capabilities)
     27 
     28        # With BiDi enabled the capability is returned
     29        self.marionette.quit()
     30        self.marionette.instance.app_args.append("-remote-debugging-port")
     31        self.marionette.start_session({"webSocketUrl": True})
     32 
     33        session_id = self.marionette.session_id
     34        websocket_url = self.marionette.session_capabilities.get("webSocketUrl")
     35 
     36        self.assertEqual(
     37            websocket_url, "ws://127.0.0.1:9222/session/{}".format(session_id)
     38        )
     39 
     40        # Clean the profile so that the preference is definitely reset.
     41        self.marionette.quit(in_app=False, clean=True)
     42 
     43    # An issue in the command line argument handling lead to open Firefox on
     44    # random URLs when remote-debugging-port is set to an explicit value, on macos.
     45    # See Bug 1724251.
     46    def test_start_page_about_blank(self):
     47        self.marionette.quit()
     48        self.marionette.instance.app_args.append("-remote-debugging-port=0")
     49        self.marionette.start_session({"webSocketUrl": True})
     50        self.assertEqual(self.marionette.get_url(), "about:blank")
     51 
     52    def test_startup_timeout(self):
     53        try:
     54            self.marionette.quit()
     55            with self.assertRaisesRegex(IOError, "Process killed after 0s"):
     56                # Use a small enough timeout which should always cause an IOError
     57                self.marionette.start_session(timeout=0)
     58        finally:
     59            self.marionette.start_session()