diff --git a/tbselenium/test/test_set_security_level.py b/tbselenium/test/test_set_security_level.py index 8c61049..beaaae9 100644 --- a/tbselenium/test/test_set_security_level.py +++ b/tbselenium/test/test_set_security_level.py @@ -9,8 +9,21 @@ from tbselenium.utils import SECURITY_HIGH, SECURITY_MEDIUM, SECURITY_LOW +GET_WEBGL_ORG_URL = "https://get.webgl.org/" + + class SecurityLevelTest(unittest.TestCase): + def get_webgl_test_page_status_text(self, driver): + status = driver.find_element_by( + "h1.good", find_by=By.CSS_SELECTOR, timeout=5) + return status.text + + def get_webgl_test_page_webgl_container_inner_html(self, driver): + webgl_container = driver.find_element_by( + "logo-container", find_by=By.ID, timeout=5) + return webgl_container.get_attribute('innerHTML').strip() + def test_set_security_low(self): with TBDriverFixture(TBB_PATH) as driver: set_security_level(driver, SECURITY_LOW) @@ -22,7 +35,26 @@ def test_set_security_low(self): except (NoSuchElementException, TimeoutException): pass - # TODO: find a better way to test for this + 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 == "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( + '