Commit 3bc0074a authored by Arthur Edelstein's avatar Arthur Edelstein Committed by Alex Catarineu
Browse files

Bug 12620: TorBrowser regression tests

Regression tests for Bug #2950: Make Permissions Manager memory-only

Regression tests for TB4: Tor Browser's Firefox preference overrides.

Note: many more functional tests could be made here

Regression tests for #2874: Block Components.interfaces from content

Bug 18923: Add a script to run all Tor Browser specific tests

Regression tests for Bug #16441: Suppress "Reset Tor Browser" prompt.
parent e29c2b2c
# This script runs all the Mochitest tests that have been added or
# modified since the last ffxbld commit.
# It does not currently run XPCShell tests. We should change this if we
# start using this type or other types of tests.
# The logs of the tests are stored in the tbb-tests.log file.
# Ignored tests are listed in the tbb-tests-ignore.txt file.
if [ -n "$USE_TESTS_LIST" ] && [ -f tbb-tests-list.txt ]
echo "Using tests list from file tbb-tests-list.txt"
tests=($(cat tbb-tests-list.txt))
ffxbld_commit=$(git log -500 --format='%an %H' | grep '^ffxbld ' \
| head -1 | cut -d ' ' -f 2)
tests=($(git diff --name-status "$ffxbld_commit" HEAD | \
grep -e '^[AM].*/test_[^/]\+\.\(html\|xul\)$' \
-e '^[AM].*/browser_[^/]\+\.js$' \
| sed 's/^[AM]\s\+//'))
echo 'The following tests will be run:'
for i in "${!tests[@]}"
if [ -z "$USE_TESTS_LIST" ] \
&& grep -q "^${tests[$i]}$" tbb-tests-ignore.txt
unset "tests[$i]"
echo "- ${tests[$i]}"
if [ -n "$WRITE_TESTS_LIST" ]
rm -f tbb-tests-list.txt
for i in "${!tests[@]}"
echo "${tests[$i]}" >> tbb-tests-list.txt
exit 0
rm -f tbb-tests.log
echo $'\n''Starting tests'
./mach mochitest --log-tbpl tbb-tests.log --setpref security.nocertdb=false \
echo "*************************"
echo "*************************"
echo "Summary of failed tests:"
grep --color=never TEST-UNEXPECTED-FAIL tbb-tests.log
// # Test for TB4: Tor Browser's Firefox preference overrides
// Simple regression tests to check the value of each pref and
// decides if it is set as expected.
// TODO: Write unit tests to check that each pref setting here
// causes the browser to have the desired behavior (a big task).
function test() {
let expectedPrefs = [
// Disable browser auto updaters and associated homepage notifications
["", false],
["app.update.enabled", false],
["", false],
["browser.rights.3.shown", true],
["browser.startup.homepage_override.mstone", "ignore"],
["startup.homepage_welcome_url", ""],
["startup.homepage_override_url", ""],
// Disable the "Refresh" prompt that is displayed for stale profiles.
["browser.disableResetPrompt", true],
// Disk activity: Disable Browsing History Storage
["browser.privatebrowsing.autostart", true],
["browser.cache.disk.enable", false],
["browser.cache.offline.enable", false],
["dom.indexedDB.enabled", false],
["permissions.memory_only", true],
["network.cookie.lifetimePolicy", 2],
["security.nocertdb", true],
// Disk activity: TBB Directory Isolation
["", false],
["", false],
["", false],
// Misc privacy: Disk
["signon.rememberSignons", false],
["browser.formfill.enable", false],
["signon.autofillForms", false],
["browser.sessionstore.privacy_level", 2],
["media.cache_size", 0],
// Misc privacy: Remote
["browser.send_pings", false],
["geo.enabled", false],
["geo.wifi.uri", ""],
["", false],
["browser.safebrowsing.malware.enabled", false],
["extensions.ui.lastCategory", "addons://list/extension"],
["datareporting.healthreport.uploadEnabled", false],
["datareporting.policy.dataSubmissionEnabled", false],
["security.mixed_content.block_active_content", false], // Disable until is patched
["browser.syncPromoViewsLeftMap", "{\"addons\":0, \"passwords\":0, \"bookmarks\":0}"], // Don't promote sync
["services.sync.engine.prefs", false], // Never sync prefs, addons, or tabs with other browsers
["services.sync.engine.addons", false],
["services.sync.engine.tabs", false],
["extensions.getAddons.cache.enabled", false], //
// Fingerprinting
["webgl.min_capability_mode", true],
["webgl.disable-extensions", true],
["dom.battery.enabled", false], // fingerprinting due to differing OS implementations
["gfx.downloadable_fonts.fallback_delay", -1],
["browser.startup.homepage_override.buildID", "20100101"],
// Third party stuff
["network.cookie.cookieBehavior", 1],
["security.enable_tls_session_tickets", false],
["network.http.spdy.enabled", false], // Stores state and may have keepalive issues (both fixable)
["network.http.spdy.enabled.v2", false], // Seems redundant, but just in case
["network.http.spdy.enabled.v3", false], // Seems redundant, but just in case
// Proxy and proxy security
["network.proxy.socks", ""],
["network.proxy.socks_port", 9150],
["network.proxy.socks_remote_dns", true],
["network.proxy.no_proxies_on", ""], // For fingerprinting and local service vulns (#10419)
["network.proxy.type", 1],
["", "9050,9051,9150,9151"],
["network.dns.disablePrefetch", true],
["network.protocol-handler.external-default", false],
["network.protocol-handler.external.mailto", false],
["", false],
["network.protocol-handler.external.nntp", false],
["network.protocol-handler.external.snews", false],
["network.protocol-handler.warn-external.mailto", true],
["", true],
["network.protocol-handler.warn-external.nntp", true],
["network.protocol-handler.warn-external.snews", true],
// Network and performance
["network.http.pipelining", true],
["network.http.pipelining.aggressive", true],
["network.http.pipelining.maxrequests", 12],
["network.http.pipelining.ssl", true],
["network.http.proxy.pipelining", true],
["security.ssl.enable_false_start", true],
["network.http.keep-alive.timeout", 20],
["network.http.connection-retry-timeout", 0],
["network.http.max-persistent-connections-per-proxy", 256],
["network.http.pipelining.reschedule-timeout", 15000],
["", 60000],
// Hacked pref: Now means "Attempt to pipeline at least this many requests together"
["network.http.pipelining.max-optimistic-requests", 3],
["security.disable_session_identifiers", true],
// Extension support
["extensions.autoDisableScopes", 0],
["extensions.bootstrappedAddons", "{}"],
["extensions.checkCompatibility.4.*", false],
["extensions.databaseSchema", 3],
["extensions.enabledAddons", ",%7B73a6fe31-595d-460b-a920-fcc0f8843232%7D:,,,%7B972ce4c6-7e08-4474-a285-3208198ce6fd%7D:17.0.5"],
["extensions.enabledItems", ",{73a6fe31-595d-460b-a920-fcc0f8843232}:,{e0204bd5-9d31-402b-a99d-a6aa8ffebdca}:1.2.4,{972ce4c6-7e08-4474-a285-3208198ce6fd}:3.5.8"],
["extensions.enabledScopes", 1],
["extensions.pendingOperations", false],
["xpinstall.whitelist.add", ""],
["xpinstall.whitelist.add.36", ""],
// Omnibox settings
["keyword.URL", ""],
// Hacks/workarounds: Direct2D seems to crash w/ lots of video cards w/ MinGW?
// Nvida cards also experience crashes without the second pref set to disabled
["gfx.direct2d.disabled", true],
["layers.acceleration.disabled", true],
// Security enhancements
["javascript.options.ion.content", false],
["javascript.options.baselinejit.content", false],
["javascript.options.asmjs", false],
["javascript.options.typeinference", false],
// Enable TLS 1.1 and 1.2:
["security.tls.version.max", 3],
// Version placeholder
["torbrowser.version", "UNKNOWN"],
let getPref = function (prefName) {
let type = gPrefService.getPrefType(prefName);
if (type === gPrefService.PREF_INT) return gPrefService.getIntPref(prefName);
if (type === gPrefService.PREF_BOOL) return gPrefService.getBoolPref(prefName);
if (type === gPrefService.PREF_STRING) return gPrefService.getCharPref(prefName);
// Something went wrong.
throw new Error("Can't access pref " + prefName);
let testPref = function([key, expectedValue]) {
let foundValue = getPref(key);
is(foundValue, expectedValue, "Pref '" + key + "' should be '" + expectedValue +"'.");
} // end function test()
// # Regression tests for tor Bug #2950, Make Permissions Manager memory-only
// Ensures that permissions.sqlite file in profile directory is not written to,
// even when we write a value to Firefox's permissions database.
// The requisite test() function.
function test() {
// Needed because of asynchronous part later in the test.
// Shortcut
let Ci = Components.interfaces;
// ## utility functions
// __uri(spec)__.
// Creates an nsIURI instance from a spec
// (string address such as "").
let uri = spec =>, null, null);
// __setPermission(spec, key, value)__.
// Sets the site permission of type key to value, for the site located at address spec.
let setPermission = (spec, key, value) => SitePermissions.set(uri(spec), key, value);
// __getPermission(spec, key)__.
// Reads the site permission value for permission type key, for the site
// located at address spec.
let getPermission = (spec, key) => SitePermissions.get(uri(spec), key);
// __profileDirPath__.
// The Firefox Profile directory. Expected location of various persistent files.
let profileDirPath = Services.dirsvc.get("ProfD", Components.interfaces.nsIFile).path;
// __fileInProfile(fileName)__.
// Returns an nsIFile instance corresponding to a file in the Profile directory.
let fileInProfile = fileName => FileUtils.File(profileDirPath + "/" + fileName);
// ## Now let's run the test.
let SITE = "",
KEY = "popup";
let permissionsFile = fileInProfile("permissions.sqlite"),
lastModifiedTime = null,
newModifiedTime = null;
if (permissionsFile.exists()) {
lastModifiedTime = permissionsFile.lastModifiedTime;
// Read the original value of the permission.
let originalValue = getPermission(SITE, KEY);
// We need to delay by at least 1000 ms, because that's the granularity
// of file time stamps, it seems.
function () {
// Set the permission to a new value.
setPermission(SITE, KEY, (originalValue === 0) ? 1 : 0);
// Now read back the permission value again.
let newReadValue = getPermission(SITE, KEY);
// Compare to confirm that the permission
// value was successfully changed.
isnot(newReadValue, originalValue, "Set a value in permissions db (perhaps in memory).");;
// If file existed or now exists, get the current time stamp.
if (permissionsFile.exists()) {
newModifiedTime = permissionsFile.lastModifiedTime;
// If file was created or modified since we began this test,
// then permissions db is not memory only. Complain!
is(lastModifiedTime, newModifiedTime, "Don't write to permissions.sqlite file on disk.");
// We are done with the test.
}, 1100);
} // test()
# -*- Mode: python; c-basic-offset: 4; indent-tabs-mode: nil; tab-width: 40 -*-
# vim: set filetype=python:
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at
MOCHITEST_MANIFESTS += ['mochitest.ini']
BROWSER_CHROME_MANIFESTS += [ 'browser.ini' ]
Tor bug
<meta charset="utf-8">
<title>Test for Tor Bug 2874</title>
<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
<script type="application/javascript">
is(typeof Components, 'undefined', "The global window object should not expose a Components property to untrusted content.");
<a target="_blank" href="">Tor Bug 2874</a>
<p id="display"></p>
<div id="content" style="display: none">
<pre id="test">
......@@ -96,7 +96,8 @@ if CONFIG['MOZ_WEBRTC'] and CONFIG['COMPILE_ENVIRONMENT']:
DIRS += ['/testing/specialpowers']
DIRS += ['/testing/specialpowers',
DIRS += [
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