GitLab is used only for code review, issue tracking and project management. Canonical locations for source code are still https://gitweb.torproject.org/ https://git.torproject.org/ and git-rw.torproject.org.

Unverified Commit fdf5dd90 authored by boklm's avatar boklm
Browse files

Replace all selenium tests by marionette tests

parent cd763eb8
......@@ -233,7 +233,7 @@ our @tests = (
},
{
name => 'check',
type => 'selenium',
type => 'marionette',
use_net => 1,
descr => 'Check that http://check.torproject.org/ think we are using tor',
},
......@@ -337,26 +337,27 @@ our @tests = (
},
{
name => 'fp_screen_dimensions',
type => 'selenium',
type => 'marionette',
descr => 'Check that screen dimensions are spoofed correctly',
},
{
name => 'fp_screen_coords',
type => 'selenium',
type => 'marionette',
descr => 'Check that screenX, screenY, screenLeft, screenTop, mozInnerScreenX, mozInnerScreenY are 0',
},
{
name => 'fp_plugins',
type => 'selenium',
type => 'marionette',
descr => 'Check that plugins are disabled',
},
{
name => 'fp_useragent',
type => 'selenium',
type => 'marionette',
descr => 'Check that userAgent is as expected',
}, {
},
{
name => 'fp_navigator',
type => 'selenium',
type => 'marionette',
descr => 'Check that navigator properties are as expected',
},
{
......
from marionette_driver import By
from marionette_driver.errors import MarionetteException
from firefox_ui_harness import FirefoxTestCase
class Test(FirefoxTestCase):
def test_check_tpo(self):
with self.marionette.using_context('content'):
driver = self.marionette
driver.navigate("http://check.torproject.org/")
self.assertEqual("Congratulations. This browser is configured to use Tor.", driver.find_element("css selector", "h1.on").text)
#!/usr/bin/python
import tbbtest
from marionette_driver import By
from marionette_driver.errors import MarionetteException
from firefox_ui_harness import FirefoxTestCase
# expected values for navigation properties
nav_props = {"appCodeName": "Mozilla",
......@@ -45,13 +47,14 @@ nav_props = {"appCodeName": "Mozilla",
}
class Test(tbbtest.TBBTest):
class Test(FirefoxTestCase):
def test_navigator(self):
driver = self.driver
js = driver.execute_script
# Check that plugins are disabled
for nav_prop, expected_value in nav_props.iteritems():
# cast to string on the JS side, otherwise we have issues
# that raise from Python/JS type disparity
current_value = js("return ''+navigator['%s']" % nav_prop)
self.assertEqual(expected_value, current_value, "Navigator property mismatch %s [%s != %s]" % (nav_prop, current_value, expected_value))
with self.marionette.using_context('content'):
self.marionette.navigate('about:robots')
js = self.marionette.execute_script
for nav_prop, expected_value in nav_props.iteritems():
# cast to string on the JS side, otherwise we have issues
# that raise from Python/JS type disparity
self.marionette.set_context(self.marionette.CONTEXT_CONTENT)
current_value = js("return ''+navigator['%s']" % nav_prop)
self.assertEqual(expected_value, current_value, "Navigator property mismatch %s [%s != %s]" % (nav_prop, current_value, expected_value))
from marionette_driver import By
from marionette_driver.errors import MarionetteException
from firefox_ui_harness import FirefoxTestCase
class Test(FirefoxTestCase):
def test_plugins(self):
with self.marionette.using_context('content'):
self.marionette.navigate('about:robots')
js = self.marionette.execute_script
# Check that plugins are disabled
self.assertEqual(True, js("return navigator.plugins.length === 0"))
self.assertEqual(True, js("return navigator.mimeTypes.length === 0"))
from marionette_driver import By
from marionette_driver.errors import MarionetteException
from firefox_ui_harness import FirefoxTestCase
class Test(FirefoxTestCase):
def test_screen_coords(self):
# https://gitweb.torproject.org/torbrowser.git/blob/HEAD:/src/current-patches/firefox/0021-Do-not-expose-physical-screen-info.-via-window-and-w.patch
with self.marionette.using_context('content'):
self.marionette.navigate('about:robots')
js = self.marionette.execute_script
# check that screenX, screenY are 0
self.assertEqual(True, js("return screenX === 0"))
self.assertEqual(True, js("return screenY === 0"))
# check that mozInnerScreenX, mozInnerScreenY are 0
self.assertEqual(True, js("return mozInnerScreenX === 0"))
self.assertEqual(True, js("return mozInnerScreenY === 0"))
# check that screenLeft, screenTop are 0
self.assertEqual(True, js("return screen.left === 0"))
self.assertEqual(True, js("return screen.top === 0"))
# check that availLeft, availTop are 0
self.assertEqual(True, js("return screen.availLeft === 0"))
self.assertEqual(True, js("return screen.availTop === 0"))
from marionette_driver import By
from marionette_driver.errors import MarionetteException
from firefox_ui_harness import FirefoxTestCase
class Test(FirefoxTestCase):
def test_screen_dims(self):
with self.marionette.using_context('content'):
# https://gitweb.torproject.org/torbrowser.git/blob/HEAD:/src/current-patches/firefox/0021-Do-not-expose-physical-screen-info.-via-window-and-w.patch
js = self.marionette.execute_script
# check that availWidth and availHeight are equal to window innerWidth and innerHeight
self.assertEqual(True, js("return screen.availWidth === window.innerWidth"))
self.assertEqual(True, js("return screen.availHeight === window.innerHeight"))
# check that screen width and height are equal to availWidth and availHeight
self.assertEqual(True, js("return screen.width === screen.availWidth"))
self.assertEqual(True, js("return screen.height === screen.availHeight"))
# check that innerWidth and innerHeight are equal to outerWidth and outerHeight
self.assertEqual(True, js("return window.innerWidth === window.outerWidth"))
self.assertEqual(True, js("return window.innerHeight === window.outerHeight"))
from marionette_driver import By
from marionette_driver.errors import MarionetteException
from firefox_ui_harness import FirefoxTestCase
class Test(FirefoxTestCase):
def test_useragent(self):
with self.marionette.using_context('content'):
self.marionette.navigate('about:robots')
js = self.marionette.execute_script
# Check that useragent string is as expected
# We better know the ESR version we're testing
self.assertEqual("Mozilla/5.0 (Windows NT 6.1; rv:38.0) Gecko/20100101 Firefox/38.0",
js("return navigator.userAgent"))
#!/usr/bin/python
import unittest, time, re
import tbbtest
class Test(tbbtest.TBBTest):
def test_check_tpo(self):
driver = self.driver
driver.get("http://check.torproject.org/")
self.assertEqual("Congratulations. This browser is configured to use Tor.", driver.find_element_by_css_selector("h1.on").text)
#!/usr/bin/python
import tbbtest
class Test(tbbtest.TBBTest):
def test_plugins(self):
driver = self.driver
js = driver.execute_script
# Check that plugins are disabled
self.assertEqual(True, js("return navigator.plugins.length === 0"))
self.assertEqual(True, js("return navigator.mimeTypes.length === 0"))
\ No newline at end of file
#!/usr/bin/python
import tbbtest
class Test(tbbtest.TBBTest):
def test_screen_coords(self):
# https://gitweb.torproject.org/torbrowser.git/blob/HEAD:/src/current-patches/firefox/0021-Do-not-expose-physical-screen-info.-via-window-and-w.patch
driver = self.driver
js = driver.execute_script
# check that screenX, screenY are 0
self.assertEqual(True, js("return screenX === 0"))
self.assertEqual(True, js("return screenY === 0"))
# check that mozInnerScreenX, mozInnerScreenY are 0
self.assertEqual(True, js("return mozInnerScreenX === 0"))
self.assertEqual(True, js("return mozInnerScreenY === 0"))
# check that screenLeft, screenTop are 0
self.assertEqual(True, js("return screen.left === 0"))
self.assertEqual(True, js("return screen.top === 0"))
# check that availLeft, availTop are 0
self.assertEqual(True, js("return screen.availLeft === 0"))
self.assertEqual(True, js("return screen.availTop === 0"))
#!/usr/bin/python
import tbbtest
class Test(tbbtest.TBBTest):
def test_screen_dims(self):
# https://gitweb.torproject.org/torbrowser.git/blob/HEAD:/src/current-patches/firefox/0021-Do-not-expose-physical-screen-info.-via-window-and-w.patch
driver = self.driver
js = driver.execute_script
# check that availWidth and availHeight are equal to window innerWidth and innerHeight
self.assertEqual(True, js("return screen.availWidth === window.innerWidth"))
self.assertEqual(True, js("return screen.availHeight === window.innerHeight"))
# check that screen width and height are equal to availWidth and availHeight
self.assertEqual(True, js("return screen.width === screen.availWidth"))
self.assertEqual(True, js("return screen.height === screen.availHeight"))
# check that innerWidth and innerHeight are equal to outerWidth and outerHeight
self.assertEqual(True, js("return window.innerWidth === window.outerWidth"))
self.assertEqual(True, js("return window.innerHeight === window.outerHeight"))
#!/usr/bin/python
import tbbtest
class Test(tbbtest.TBBTest):
def test_useragent(self):
driver = self.driver
js = driver.execute_script
# Check that useragent string is as expected
# We better know the ESR version we're testing
self.assertEqual("Mozilla/5.0 (Windows NT 6.1; rv:38.0) Gecko/20100101 Firefox/38.0",
js("return navigator.userAgent"))
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