Unverified Commit 7b6192a5 authored by boklm's avatar boklm
Browse files

Add security slider tests (#13682)

parent 4a146c25
...@@ -193,6 +193,46 @@ our @tests = ( ...@@ -193,6 +193,46 @@ our @tests = (
type => 'mozmill', type => 'mozmill',
descr => 'Check that some important settings are correctly set', descr => 'Check that some important settings are correctly set',
}, },
{
name => 'slider_settings_1',
mozmill_test => 'slider_settings',
type => 'mozmill',
descr => 'Check that settings are set according to security slider mode',
slider_mode => 1,
pre => \&set_slider_mode,
post => \&reset_slider_mode,
enable => sub { $_[0]->{version} !~ m/^4.0/ },
},
{
name => 'slider_settings_2',
mozmill_test => 'slider_settings',
type => 'mozmill',
descr => 'Check that settings are set according to security slider mode',
slider_mode => 2,
pre => \&set_slider_mode,
post => \&reset_slider_mode,
enable => sub { $_[0]->{version} !~ m/^4.0/ },
},
{
name => 'slider_settings_3',
mozmill_test => 'slider_settings',
type => 'mozmill',
descr => 'Check that settings are set according to security slider mode',
slider_mode => 3,
pre => \&set_slider_mode,
post => \&reset_slider_mode,
enable => sub { $_[0]->{version} !~ m/^4.0/ },
},
{
name => 'slider_settings_4',
mozmill_test => 'slider_settings',
type => 'mozmill',
descr => 'Check that settings are set according to security slider mode',
slider_mode => 4,
pre => \&set_slider_mode,
post => \&reset_slider_mode,
enable => sub { $_[0]->{version} !~ m/^4.0/ },
},
{ {
name => 'dom-objects-enumeration', name => 'dom-objects-enumeration',
type => 'mozmill', type => 'mozmill',
...@@ -260,6 +300,21 @@ sub toggle_https_everywhere { ...@@ -260,6 +300,21 @@ sub toggle_https_everywhere {
write_file($prefs, @f); write_file($prefs, @f);
} }
sub set_slider_mode {
my ($tbbinfos, $t) = @_;
my $prefs = "$tbbinfos->{ffprofiledir}/preferences/extension-overrides.js";
copy $prefs, "$prefs.slider_backup";
write_file($prefs, {append => 1},
'pref("extensions.torbutton.security_custom", false);' . "\n" .
"pref(\"extensions.torbutton.security_slider\", $t->{slider_mode});\n");
}
sub reset_slider_mode {
my ($tbbinfos, $t) = @_;
my $prefs = "$tbbinfos->{ffprofiledir}/preferences/extension-overrides.js";
move "$prefs.slider_backup", $prefs;
}
sub tbb_binfiles { sub tbb_binfiles {
my ($tbbinfos, $test) = @_; my ($tbbinfos, $test) = @_;
return $tbbinfos->{binfiles} if $tbbinfos->{binfiles}; return $tbbinfos->{binfiles} if $tbbinfos->{binfiles};
......
"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_l_bool_prefs = {
"gfx.font_rendering.opentype_svg.enabled" : false,
};
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,
// XXX: pref for disabling MathML is missing
};
var torbutton_sec_mh_bool_prefs = {
"javascript.options.baselinejit.content" : false,
"noscript.globalHttpsWhitelist" : true,
// XXX: pref for disableing SVG is missing
};
var torbutton_sec_h_bool_prefs = {
"noscript.forbidFonts" : true,
"noscript.global" : false,
"media.ogg.enabled" : false,
"media.opus.enabled" : false,
"media.wave.enabled" : false,
"media.apple.mp3.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');
for (var p in torbutton_sec_l_bool_prefs) {
var value = prefSrv.getPref(p, !torbutton_sec_l_bool_prefs[p]);
expect.equal(torbutton_sec_l_bool_prefs[p], value, p);
}
for (var p in torbutton_sec_ml_bool_prefs) {
var value = prefSrv.getPref(p, !torbutton_sec_ml_bool_prefs[p]);
var b = torbutton_sec_ml_bool_prefs[p];
expect.equal(slider_mode < 2 ? !b : b, value, p);
}
for (var p in torbutton_sec_mh_bool_prefs) {
var value = prefSrv.getPref(p, !torbutton_sec_mh_bool_prefs[p]);
var b = torbutton_sec_mh_bool_prefs[p];
expect.equal(slider_mode < 3 ? !b : b, value, p);
}
for (var p in torbutton_sec_h_bool_prefs) {
var value = prefSrv.getPref(p, !torbutton_sec_h_bool_prefs[p]);
var b = torbutton_sec_h_bool_prefs[p];
expect.equal(slider_mode < 4 ? !b : b, 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