示例#1
0
    def set_tbb_securitylevel(self, level):

        if level not in {SECURITY_HIGH, SECURITY_MEDIUM, SECURITY_LOW}:
            raise ValueError("Invalid Tor Browser security setting: " +
                             str(level))
        if hasattr(self, 'torbrowser_driver'):
            set_security_level(self.torbrowser_driver, level)
    def test_set_security_high_webgl(self):
        with TBDriverFixture(TBB_PATH) as driver:
            set_security_level(driver, SECURITY_HIGH)
            driver.load_url_ensure(GET_WEBGL_ORG_URL)

            try:
                status_text = self.get_webgl_test_page_status_text(driver)
                assert status_text == "You must enable JavaScript to use WebGL."
            except (NoSuchElementException, TimeoutException):
                self.fail("Security level does not seem to be set to Safest")
 def test_set_security_high(self):
     with TBDriverFixture(TBB_PATH) as driver:
         set_security_level(driver, SECURITY_HIGH)
         driver.load_url_ensure(CHECK_TPO_URL)
         try:
             driver.find_element_by("JavaScript is enabled.",
                                    find_by=By.LINK_TEXT,
                                    timeout=5)
             self.fail("Security level does not seem to be set to Safest")
         except (NoSuchElementException, TimeoutException):
             pass
    def test_set_security_low_webgl(self):
        with TBDriverFixture(TBB_PATH) as driver:
            set_security_level(driver, SECURITY_LOW)
            driver.load_url_ensure(GET_WEBGL_ORG_URL)
            try:
                # test the status text
                status_text = self.get_webgl_test_page_status_text(driver)
                assert status_text.startswith("Your browser supports WebGL")

                # make sure WebGL is enabled
                webgl_container_inner_html = \
                    self.get_webgl_test_page_webgl_container_inner_html(driver)
                assert webgl_container_inner_html.startswith(
                    '<canvas id="webgl-logo"')

            except (NoSuchElementException, TimeoutException) as exc:
                self.fail(
                    "Security level does not seem to be set to Standard: %s" %
                    exc)
    def test_set_security_medium_webgl(self):
        with TBDriverFixture(TBB_PATH) as driver:
            set_security_level(driver, SECURITY_MEDIUM)
            driver.load_url_ensure(GET_WEBGL_ORG_URL)
            try:
                # test the status text
                status_text = self.get_webgl_test_page_status_text(driver)
                assert status_text == "Your browser supports WebGL"

                # make sure WebGL is click-to-play (NoScript)
                webgl_container_inner_html = \
                    self.get_webgl_test_page_webgl_container_inner_html(driver)
                assert webgl_container_inner_html.startswith(
                    '<a class="__NoScript_PlaceHolder__')

            except (NoSuchElementException, TimeoutException) as exc:
                self.fail(
                    "Security level does not seem to be set to Medium: %s" %
                    exc)