Microsoft is acquiring GitHub. Decentraleyes is leaving GitHub. Welcome to its new home!

To participate, please register, or sign in with an existing GitLab.com, Bitbucket, or GitHub account.

Past contributions on GitHub? Be sure to reclaim your Comments, Issues, and Pull Requests.

Commit e20b937e authored by Thomas Rientjes's avatar Thomas Rientjes

Create Marionette automation driver tests

parent d34c03da
Pipeline #42 passed with stage
in 13 seconds
import hashlib
import os
from marionette_harness.marionette_test import MarionetteTestCase
from marionette_driver.addons import Addons
from marionette_driver.marionette import Actions
from marionette_driver import Wait
from marionette_driver import By
class TestSecuritySettings(MarionetteTestCase):
def setUp(self):
MarionetteTestCase.setUp(self)
addons = Addons(self.marionette)
testDirectory = os.path.dirname(os.path.realpath(__file__))
addons.install(testDirectory + '/../tor-browser-settings.xpi', True)
test_directory = os.path.dirname(os.path.realpath(__file__))
addons.install(test_directory + '/../tor-browser-settings.xpi', True)
self.nsa_policy_hashes = {
'standard': 'b4d0f04ae2dd6ec98bf2c1e78687ff2d',
'safer': '49024842451f92d27fac4b3bbee5ab5d',
'safest': '49024842451f92d27fac4b3bbee5ab5d'
}
def test_if_settings_page_is_reachable(self):
with self.marionette.using_context('content'):
self.marionette.navigate('chrome://tor-browser-settings/content/settings.html')
self.assertEqual(self.marionette.title, 'Orfox Settings')
self.marionette.navigate('chrome://tor-browser-settings/content/settings.html')
wait = Wait(self.marionette, timeout=5)
def page_loaded():
return self.marionette.title == 'Orfox Settings'
wait.until(lambda _: page_loaded())
def test_if_preferences_are_updated_after_selecting_security_level_0(self):
self.marionette.navigate('chrome://tor-browser-settings/content/settings.html')
level_0 = self.marionette.find_element(By.CSS_SELECTOR, '[data-label-for="security_level:0"]')
wait = Wait(self.marionette, timeout=5)
action = Actions(self.marionette)
action.tap(level_0).perform()
def preferences_updated():
nsa_policy = self.marionette.get_pref('extensions.nsa.policy')
nsa_policy_hash = hashlib.md5(nsa_policy).hexdigest()
return (nsa_policy_hash == self.nsa_policy_hashes['standard'] and
self.marionette.get_pref('javascript.options.ion.content') is True and
self.marionette.get_pref('javascript.options.typeinference') is True and
self.marionette.get_pref('media.webaudio.enabled') is True and
self.marionette.get_pref('mathml.disabled') is False and
self.marionette.get_pref('javascript.options.baselinejit.content') is True and
self.marionette.get_pref('gfx.font_rendering.opentype_svg.enabled') is True and
self.marionette.get_pref('svg.in-content.enabled') is True)
wait.until(lambda _: preferences_updated())
def test_if_preferences_are_updated_after_selecting_security_level_1(self):
self.marionette.navigate('chrome://tor-browser-settings/content/settings.html')
level_1 = self.marionette.find_element(By.CSS_SELECTOR, '[data-label-for="security_level:1"]')
wait = Wait(self.marionette, timeout=5)
action = Actions(self.marionette)
action.tap(level_1).perform()
def preferences_updated():
nsa_policy = self.marionette.get_pref('extensions.nsa.policy')
nsa_policy_hash = hashlib.md5(nsa_policy).hexdigest()
return (nsa_policy_hash == self.nsa_policy_hashes['safer'] and
self.marionette.get_pref('javascript.options.ion.content') is False and
self.marionette.get_pref('javascript.options.typeinference') is False and
self.marionette.get_pref('media.webaudio.enabled') is False and
self.marionette.get_pref('mathml.disabled') is True and
self.marionette.get_pref('javascript.options.baselinejit.content') is False and
self.marionette.get_pref('gfx.font_rendering.opentype_svg.enabled') is False and
self.marionette.get_pref('svg.in-content.enabled') is True)
wait.until(lambda _: preferences_updated())
def test_if_preferences_are_updated_after_selecting_security_level_2(self):
self.marionette.navigate('chrome://tor-browser-settings/content/settings.html')
level_2 = self.marionette.find_element(By.CSS_SELECTOR, '[data-label-for="security_level:2"]')
wait = Wait(self.marionette, timeout=5)
action = Actions(self.marionette)
action.tap(level_2).perform()
def preferences_updated():
nsa_policy = self.marionette.get_pref('extensions.nsa.policy')
nsa_policy_hash = hashlib.md5(nsa_policy).hexdigest()
return (nsa_policy_hash == self.nsa_policy_hashes['safest'] and
self.marionette.get_pref('javascript.options.ion.content') is False and
self.marionette.get_pref('javascript.options.typeinference') is False and
self.marionette.get_pref('media.webaudio.enabled') is False and
self.marionette.get_pref('mathml.disabled') is True and
self.marionette.get_pref('javascript.options.baselinejit.content') is False and
self.marionette.get_pref('gfx.font_rendering.opentype_svg.enabled') is False and
self.marionette.get_pref('svg.in-content.enabled') is False)
wait.until(lambda _: preferences_updated())
def tearDown(self):
MarionetteTestCase.tearDown(self)
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment