Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Thomas Rientjes
tor-browser-settings
Commits
e20b937e
Commit
e20b937e
authored
Jul 08, 2017
by
Thomas Rientjes
Browse files
Create Marionette automation driver tests
parent
d34c03da
Changes
1
Hide whitespace changes
Inline
Side-by-side
test/test_security_settings.py
View file @
e20b937e
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
)
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment