michael@0: // # Test for TB4: Tor Browser's Firefox preference overrides michael@0: // Simple regression tests to check the value of each pref and michael@0: // decides if it is set as expected. michael@0: michael@0: // TODO: Write unit tests to check that each pref setting here michael@0: // causes the browser to have the desired behavior (a big task). michael@0: michael@0: function test() { michael@0: michael@0: let expectedPrefs = [ michael@0: // Disable browser auto updaters and associated homepage notifications michael@0: ["app.update.auto", false], michael@0: ["app.update.enabled", false], michael@0: ["browser.search.update", false], michael@0: ["browser.rights.3.shown", true], michael@0: ["browser.startup.homepage_override.mstone", "ignore"], michael@0: ["startup.homepage_welcome_url", ""], michael@0: ["startup.homepage_override_url", ""], michael@0: michael@0: // Disk activity: Disable Browsing History Storage michael@0: ["browser.privatebrowsing.autostart", true], michael@0: ["browser.cache.disk.enable", false], michael@0: ["browser.cache.offline.enable", false], michael@0: ["dom.indexedDB.enabled", false], michael@0: ["permissions.memory_only", true], michael@0: ["network.cookie.lifetimePolicy", 2], michael@0: ["browser.download.manager.retention", 1], michael@0: ["security.nocertdb", true], michael@0: michael@0: // Disk activity: TBB Directory Isolation michael@0: ["browser.download.useDownloadDir", false], michael@0: ["browser.shell.checkDefaultBrowser", false], michael@0: ["browser.download.manager.addToRecentDocs", false], michael@0: michael@0: // Misc privacy: Disk michael@0: ["signon.rememberSignons", false], michael@0: ["browser.formfill.enable", false], michael@0: ["signon.autofillForms", false], michael@0: ["browser.sessionstore.privacy_level", 2], michael@0: ["media.cache_size", 0], michael@0: michael@0: // Misc privacy: Remote michael@0: ["browser.send_pings", false], michael@0: ["geo.enabled", false], michael@0: ["geo.wifi.uri", ""], michael@0: ["browser.search.suggest.enabled", false], michael@0: ["browser.safebrowsing.enabled", false], michael@0: ["browser.safebrowsing.malware.enabled", false], michael@0: ["browser.download.manager.scanWhenDone", false], // prevents AV remote reporting of downloads michael@0: ["extensions.ui.lastCategory", "addons://list/extension"], michael@0: ["datareporting.healthreport.service.enabled", false], // Yes, all three of these must be set michael@0: ["datareporting.healthreport.uploadEnabled", false], michael@0: ["datareporting.policy.dataSubmissionEnabled", false], michael@0: ["security.mixed_content.block_active_content", false], // Disable until https://bugzilla.mozilla.org/show_bug.cgi?id=878890 is patched michael@0: ["browser.syncPromoViewsLeftMap", "{\"addons\":0, \"passwords\":0, \"bookmarks\":0}"], // Don't promote sync michael@0: ["services.sync.engine.prefs", false], // Never sync prefs, addons, or tabs with other browsers michael@0: ["services.sync.engine.addons", false], michael@0: ["services.sync.engine.tabs", false], michael@0: ["extensions.getAddons.cache.enabled", false], // https://blog.mozilla.org/addons/how-to-opt-out-of-add-on-metadata-updates/ michael@0: michael@0: // Fingerprinting michael@0: ["webgl.min_capability_mode", true], michael@0: ["webgl.disable-extensions", true], michael@0: ["dom.battery.enabled", false], // fingerprinting due to differing OS implementations michael@0: ["dom.network.enabled",false], // fingerprinting due to differing OS implementations michael@0: ["browser.display.max_font_attempts",10], michael@0: ["browser.display.max_font_count",10], michael@0: ["gfx.downloadable_fonts.fallback_delay", -1], michael@0: ["general.appname.override", "Netscape"], michael@0: ["general.appversion.override", "5.0 (Windows)"], michael@0: ["general.oscpu.override", "Windows NT 6.1"], michael@0: ["general.platform.override", "Win32"], michael@0: ["general.useragent.override", "Mozilla/5.0 (Windows NT 6.1; rv:24.0) Gecko/20100101 Firefox/24.0"], michael@0: ["general.productSub.override", "20100101"], michael@0: ["general.buildID.override", "20100101"], michael@0: ["browser.startup.homepage_override.buildID", "20100101"], michael@0: ["general.useragent.vendor", ""], michael@0: ["general.useragent.vendorSub", ""], michael@0: ["dom.enable_performance", false], michael@0: ["plugin.expose_full_path", false], michael@0: ["browser.zoom.siteSpecific", false], michael@0: ["intl.charset.default", "windows-1252"], michael@0: //["intl.accept_languages", "en-us, en"], // Set by Torbutton michael@0: //["intl.accept_charsets", "iso-8859-1,*,utf-8"], // Set by Torbutton michael@0: //["intl.charsetmenu.browser.cache", "UTF-8"], // Set by Torbutton michael@0: michael@0: // Third party stuff michael@0: ["network.cookie.cookieBehavior", 1], michael@0: ["security.enable_tls_session_tickets", false], michael@0: ["network.http.spdy.enabled", false], // Stores state and may have keepalive issues (both fixable) michael@0: ["network.http.spdy.enabled.v2", false], // Seems redundant, but just in case michael@0: ["network.http.spdy.enabled.v3", false], // Seems redundant, but just in case michael@0: michael@0: // Proxy and proxy security michael@0: ["network.proxy.socks", "127.0.0.1"], michael@0: ["network.proxy.socks_port", 9150], michael@0: ["network.proxy.socks_remote_dns", true], michael@0: ["network.proxy.no_proxies_on", ""], // For fingerprinting and local service vulns (#10419) michael@0: ["network.proxy.type", 1], michael@0: ["network.security.ports.banned", "9050,9051,9150,9151"], michael@0: ["network.dns.disablePrefetch", true], michael@0: ["network.protocol-handler.external-default", false], michael@0: ["network.protocol-handler.external.mailto", false], michael@0: ["network.protocol-handler.external.news", false], michael@0: ["network.protocol-handler.external.nntp", false], michael@0: ["network.protocol-handler.external.snews", false], michael@0: ["network.protocol-handler.warn-external.mailto", true], michael@0: ["network.protocol-handler.warn-external.news", true], michael@0: ["network.protocol-handler.warn-external.nntp", true], michael@0: ["network.protocol-handler.warn-external.snews", true], michael@0: ["plugins.click_to_play", true], michael@0: michael@0: // Network and performance michael@0: ["network.http.pipelining", true], michael@0: ["network.http.pipelining.aggressive", true], michael@0: ["network.http.pipelining.maxrequests", 12], michael@0: ["network.http.pipelining.ssl", true], michael@0: ["network.http.proxy.pipelining", true], michael@0: ["security.ssl.enable_false_start", true], michael@0: ["network.http.keep-alive.timeout", 20], michael@0: ["network.http.connection-retry-timeout", 0], michael@0: ["network.http.max-persistent-connections-per-proxy", 256], michael@0: ["network.http.pipelining.reschedule-timeout", 15000], michael@0: ["network.http.pipelining.read-timeout", 60000], michael@0: // Hacked pref: Now means "Attempt to pipeline at least this many requests together" michael@0: ["network.http.pipelining.max-optimistic-requests", 3], michael@0: ["security.disable_session_identifiers", true], michael@0: michael@0: // Extension support michael@0: ["extensions.autoDisableScopes", 0], michael@0: ["extensions.bootstrappedAddons", "{}"], michael@0: ["extensions.checkCompatibility.4.*", false], michael@0: ["extensions.databaseSchema", 3], michael@0: ["extensions.enabledAddons", "https-everywhere%40eff.org:3.1.4,%7B73a6fe31-595d-460b-a920-fcc0f8843232%7D:2.6.6.1,torbutton%40torproject.org:1.5.2,ubufox%40ubuntu.com:2.6,tor-launcher%40torproject.org:0.1.1pre-alpha,%7B972ce4c6-7e08-4474-a285-3208198ce6fd%7D:17.0.5"], michael@0: ["extensions.enabledItems", "langpack-en-US@firefox.mozilla.org:,{73a6fe31-595d-460b-a920-fcc0f8843232}:1.9.9.57,{e0204bd5-9d31-402b-a99d-a6aa8ffebdca}:1.2.4,{972ce4c6-7e08-4474-a285-3208198ce6fd}:3.5.8"], michael@0: ["extensions.enabledScopes", 1], michael@0: ["extensions.pendingOperations", false], michael@0: ["xpinstall.whitelist.add", ""], michael@0: ["xpinstall.whitelist.add.36", ""], michael@0: michael@0: // Omnibox settings michael@0: ["keyword.URL", "https://startpage.com/do/search?q="], michael@0: michael@0: // Hacks/workarounds: Direct2D seems to crash w/ lots of video cards w/ MinGW? michael@0: // Nvida cards also experience crashes without the second pref set to disabled michael@0: ["gfx.direct2d.disabled", true], michael@0: ["layers.acceleration.disabled", true], michael@0: michael@0: // Security enhancements michael@0: // https://trac.torproject.org/projects/tor/ticket/9387#comment:17 michael@0: ["javascript.options.ion.content", false], michael@0: ["javascript.options.baselinejit.content", false], michael@0: ["javascript.options.asmjs", false], michael@0: ["javascript.options.typeinference", false], michael@0: michael@0: // Audio_data is deprecated in future releases, but still present michael@0: // in FF24. This is a dangerous combination (spotted by iSec) michael@0: ["media.audio_data.enabled", false], michael@0: michael@0: // Enable TLS 1.1 and 1.2: michael@0: // https://trac.torproject.org/projects/tor/ticket/11253 michael@0: ["security.tls.version.max", 3], michael@0: michael@0: // Version placeholder michael@0: ["torbrowser.version", "UNKNOWN"], michael@0: michael@0: ]; michael@0: michael@0: michael@0: michael@0: michael@0: let getPref = function (prefName) { michael@0: let type = gPrefService.getPrefType(prefName); michael@0: if (type === gPrefService.PREF_INT) return gPrefService.getIntPref(prefName); michael@0: if (type === gPrefService.PREF_BOOL) return gPrefService.getBoolPref(prefName); michael@0: if (type === gPrefService.PREF_STRING) return gPrefService.getCharPref(prefName); michael@0: // Something went wrong. michael@0: throw new Error("Can't access pref."); michael@0: }; michael@0: michael@0: let testPref = function([key, expectedValue]) { michael@0: let foundValue = getPref(key); michael@0: is(foundValue, expectedValue, "Pref '" + key + "' should be '" + expectedValue +"'."); michael@0: }; michael@0: michael@0: expectedPrefs.map(testPref); michael@0: michael@0: } // end function test()