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 c516c0ce authored by boklm's avatar boklm
Browse files

Convert slider_settings tests to marionette

parent 79f8d58a
......@@ -267,8 +267,8 @@ our @tests = (
},
{
name => 'slider_settings_1',
mozmill_test => 'slider_settings',
type => 'mozmill',
marionette_test => 'slider_settings',
type => 'marionette',
descr => 'Check that settings are set according to security slider mode',
slider_mode => 1,
pre => \&set_slider_mode,
......@@ -277,8 +277,8 @@ our @tests = (
},
{
name => 'slider_settings_2',
mozmill_test => 'slider_settings',
type => 'mozmill',
marionette_test => 'slider_settings',
type => 'marionette',
descr => 'Check that settings are set according to security slider mode',
slider_mode => 2,
pre => \&set_slider_mode,
......@@ -287,8 +287,8 @@ our @tests = (
},
{
name => 'slider_settings_3',
mozmill_test => 'slider_settings',
type => 'mozmill',
marionette_test => 'slider_settings',
type => 'marionette',
descr => 'Check that settings are set according to security slider mode',
slider_mode => 3,
pre => \&set_slider_mode,
......@@ -297,8 +297,8 @@ our @tests = (
},
{
name => 'slider_settings_4',
mozmill_test => 'slider_settings',
type => 'mozmill',
marionette_test => 'slider_settings',
type => 'marionette',
descr => 'Check that settings are set according to security slider mode',
slider_mode => 4,
pre => \&set_slider_mode,
......
from marionette_driver import By
from marionette_driver.errors import MarionetteException
from firefox_ui_harness import FirefoxTestCase
import testsuite
class Test(FirefoxTestCase):
def setUp(self):
FirefoxTestCase.setUp(self)
ts = testsuite.TestSuite()
self.ts = ts
# The torbutton_sec_* variables have been copy pasted from
# torbutton/src/chrome/content/torbutton.js
self.torbutton_sec_ml_bool_prefs = {
"javascript.options.ion.content" : False,
"javascript.options.typeinference" : False,
"javascript.options.asmjs" : False,
"noscript.forbidMedia" : True,
"media.webaudio.enabled" : False,
"network.jar.block-remote-files" : True,
"mathml.disabled" : True
}
self.torbutton_sec_mh_bool_prefs = {
"javascript.options.baselinejit.content" : False,
"gfx.font_rendering.opentype_svg.enabled" : False,
"noscript.global" : False,
"noscript.globalHttpsWhitelist" : True
}
self.torbutton_sec_h_bool_prefs = {
"noscript.forbidFonts" : True,
"noscript.global" : False,
"svg.in-content.enabled" : False
};
def test_slider_settings(self):
with self.marionette.using_context('content'):
self.marionette.navigate('about:robots')
slider_mode = int(self.ts.t['test']['slider_mode'])
self.assertEqual(slider_mode,
self.prefs.get_pref('extensions.torbutton.security_slider'),
msg='Slider mode is not set correctly')
expected_prefs = {}
if slider_mode == 1:
for name, val in self.torbutton_sec_ml_bool_prefs.iteritems():
expected_prefs[name] = val
for name, val in self.torbutton_sec_mh_bool_prefs.iteritems():
expected_prefs[name] = val
# noscript.globalHttpsWhitelist is special: We don't want it in this
# mode.
if name == "noscript.globalHttpsWhitelist":
expected_prefs[name] = not val
for name, val in self.torbutton_sec_h_bool_prefs.iteritems():
expected_prefs[name] = val
elif slider_mode == 2:
for name, val in self.torbutton_sec_ml_bool_prefs.iteritems():
expected_prefs[name] = val
# Order matters here as both the high mode and the medium-high mode
# share some preferences/values. So, let's revert the high mode
# preferences first and set the medium-high mode ones afterwards.
for name, val in self.torbutton_sec_h_bool_prefs.iteritems():
expected_prefs[name] = not val
for name, val in self.torbutton_sec_mh_bool_prefs.iteritems():
expected_prefs[name] = val
elif slider_mode == 3:
for name, val in self.torbutton_sec_ml_bool_prefs.iteritems():
expected_prefs[name] = val
for name, val in self.torbutton_sec_mh_bool_prefs.iteritems():
expected_prefs[name] = not val
for name, val in self.torbutton_sec_h_bool_prefs.iteritems():
expected_prefs[name] = not val
elif slider_mode == 4:
for name, val in self.torbutton_sec_ml_bool_prefs.iteritems():
expected_prefs[name] = not val
for name, val in self.torbutton_sec_mh_bool_prefs.iteritems():
expected_prefs[name] = not val
for name, val in self.torbutton_sec_h_bool_prefs.iteritems():
expected_prefs[name] = not val
errors = ''
for name, val in expected_prefs.iteritems():
if self.prefs.get_pref(name) != val:
errors += "%s: %s != %s\n" % (name, self.prefs.get_pref(name), val)
self.assertEqual(errors, '', msg=errors)
"use strict";
Cu.import("resource://gre/modules/Services.jsm");
var {expect} = require("../mozilla-mozmill-tests/lib/assertions");
var prefs = require("../mozilla-mozmill-tests/firefox/lib/prefs");
var testsuite = require("../lib/testsuite");
// The torbutton_sec_* variables have been copy pasted from
// torbutton/src/chrome/content/torbutton.js
var torbutton_sec_ml_bool_prefs = {
"javascript.options.ion.content" : false,
"javascript.options.typeinference" : false,
"javascript.options.asmjs" : false,
"noscript.forbidMedia" : true,
"media.webaudio.enabled" : false,
"network.jar.block-remote-files" : true,
"mathml.disabled" : true
};
var torbutton_sec_mh_bool_prefs = {
"javascript.options.baselinejit.content" : false,
"gfx.font_rendering.opentype_svg.enabled" : false,
"noscript.global" : false,
"noscript.globalHttpsWhitelist" : true
};
var torbutton_sec_h_bool_prefs = {
"noscript.forbidFonts" : true,
"noscript.global" : false,
"svg.in-content.enabled" : false
};
////////////////////////////////////
var setupModule = function(aModule) {
aModule.controller = mozmill.getBrowserController();
}
var testTBBSettingsSlider = function() {
var prefSrv = prefs.preferences;
var slider_mode = prefSrv.getPref('extensions.torbutton.security_slider', 1);
expect.equal(parseInt(testsuite.test.slider_mode), slider_mode, 'slider mode');
expect.equal(prefSrv.getPref('extensions.torbutton.security_custom', true), false, 'security_custom');
var expected_prefs = {};
switch (slider_mode) {
case 1:
for (p in torbutton_sec_ml_bool_prefs) {
expected_prefs[p] = torbutton_sec_ml_bool_prefs[p];
}
for (p in torbutton_sec_mh_bool_prefs) {
expected_prefs[p] = torbutton_sec_mh_bool_prefs[p];
// noscript.globalHttpsWhitelist is special: We don't want it in this
// mode.
if (p === "noscript.globalHttpsWhitelist") {
expected_prefs[p] = !torbutton_sec_mh_bool_prefs[p];
}
}
for (p in torbutton_sec_h_bool_prefs) {
expected_prefs[p] = torbutton_sec_h_bool_prefs[p];
}
break;
case 2:
for (p in torbutton_sec_ml_bool_prefs) {
expected_prefs[p] = torbutton_sec_ml_bool_prefs[p];
}
// Order matters here as both the high mode and the medium-high mode
// share some preferences/values. So, let's revert the high mode
// preferences first and set the medium-high mode ones afterwards.
for (p in torbutton_sec_h_bool_prefs) {
expected_prefs[p] = !torbutton_sec_h_bool_prefs[p];
}
for (p in torbutton_sec_mh_bool_prefs) {
expected_prefs[p] = torbutton_sec_mh_bool_prefs[p];
}
break;
case 3:
for (p in torbutton_sec_ml_bool_prefs) {
expected_prefs[p] = torbutton_sec_ml_bool_prefs[p];
}
for (p in torbutton_sec_mh_bool_prefs) {
expected_prefs[p] = !torbutton_sec_mh_bool_prefs[p];
}
for (p in torbutton_sec_h_bool_prefs) {
expected_prefs[p] = !torbutton_sec_h_bool_prefs[p];
}
break;
case 4:
for (p in torbutton_sec_ml_bool_prefs) {
expected_prefs[p] = !torbutton_sec_ml_bool_prefs[p];
}
for (p in torbutton_sec_mh_bool_prefs) {
expected_prefs[p] = !torbutton_sec_mh_bool_prefs[p];
}
for (p in torbutton_sec_h_bool_prefs) {
expected_prefs[p] = !torbutton_sec_h_bool_prefs[p];
}
break;
}
for (var p in expected_prefs) {
var value = prefSrv.getPref(p, !expected_prefs[p]);
expect.equal(expected_prefs[p], value, p);
}
}
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