Thu, 15 Jan 2015 15:59:08 +0100
Implement a real Private Browsing Mode condition by changing the API/ABI;
This solves Tor bug #9701, complying with disk avoidance documented in
https://www.torproject.org/projects/torbrowser/design/#disk-avoidance.
michael@0 | 1 | // # Test for TB4: Tor Browser's Firefox preference overrides |
michael@0 | 2 | // Simple regression tests to check the value of each pref and |
michael@0 | 3 | // decides if it is set as expected. |
michael@0 | 4 | |
michael@0 | 5 | // TODO: Write unit tests to check that each pref setting here |
michael@0 | 6 | // causes the browser to have the desired behavior (a big task). |
michael@0 | 7 | |
michael@0 | 8 | function test() { |
michael@0 | 9 | |
michael@0 | 10 | let expectedPrefs = [ |
michael@0 | 11 | // Disable browser auto updaters and associated homepage notifications |
michael@0 | 12 | ["app.update.auto", false], |
michael@0 | 13 | ["app.update.enabled", false], |
michael@0 | 14 | ["browser.search.update", false], |
michael@0 | 15 | ["browser.rights.3.shown", true], |
michael@0 | 16 | ["browser.startup.homepage_override.mstone", "ignore"], |
michael@0 | 17 | ["startup.homepage_welcome_url", ""], |
michael@0 | 18 | ["startup.homepage_override_url", ""], |
michael@0 | 19 | |
michael@0 | 20 | // Disk activity: Disable Browsing History Storage |
michael@0 | 21 | ["browser.privatebrowsing.autostart", true], |
michael@0 | 22 | ["browser.cache.disk.enable", false], |
michael@0 | 23 | ["browser.cache.offline.enable", false], |
michael@0 | 24 | ["dom.indexedDB.enabled", false], |
michael@0 | 25 | ["permissions.memory_only", true], |
michael@0 | 26 | ["network.cookie.lifetimePolicy", 2], |
michael@0 | 27 | ["browser.download.manager.retention", 1], |
michael@0 | 28 | ["security.nocertdb", true], |
michael@0 | 29 | |
michael@0 | 30 | // Disk activity: TBB Directory Isolation |
michael@0 | 31 | ["browser.download.useDownloadDir", false], |
michael@0 | 32 | ["browser.shell.checkDefaultBrowser", false], |
michael@0 | 33 | ["browser.download.manager.addToRecentDocs", false], |
michael@0 | 34 | |
michael@0 | 35 | // Misc privacy: Disk |
michael@0 | 36 | ["signon.rememberSignons", false], |
michael@0 | 37 | ["browser.formfill.enable", false], |
michael@0 | 38 | ["signon.autofillForms", false], |
michael@0 | 39 | ["browser.sessionstore.privacy_level", 2], |
michael@0 | 40 | ["media.cache_size", 0], |
michael@0 | 41 | |
michael@0 | 42 | // Misc privacy: Remote |
michael@0 | 43 | ["browser.send_pings", false], |
michael@0 | 44 | ["geo.enabled", false], |
michael@0 | 45 | ["geo.wifi.uri", ""], |
michael@0 | 46 | ["browser.search.suggest.enabled", false], |
michael@0 | 47 | ["browser.safebrowsing.enabled", false], |
michael@0 | 48 | ["browser.safebrowsing.malware.enabled", false], |
michael@0 | 49 | ["browser.download.manager.scanWhenDone", false], // prevents AV remote reporting of downloads |
michael@0 | 50 | ["extensions.ui.lastCategory", "addons://list/extension"], |
michael@0 | 51 | ["datareporting.healthreport.service.enabled", false], // Yes, all three of these must be set |
michael@0 | 52 | ["datareporting.healthreport.uploadEnabled", false], |
michael@0 | 53 | ["datareporting.policy.dataSubmissionEnabled", false], |
michael@0 | 54 | ["security.mixed_content.block_active_content", false], // Disable until https://bugzilla.mozilla.org/show_bug.cgi?id=878890 is patched |
michael@0 | 55 | ["browser.syncPromoViewsLeftMap", "{\"addons\":0, \"passwords\":0, \"bookmarks\":0}"], // Don't promote sync |
michael@0 | 56 | ["services.sync.engine.prefs", false], // Never sync prefs, addons, or tabs with other browsers |
michael@0 | 57 | ["services.sync.engine.addons", false], |
michael@0 | 58 | ["services.sync.engine.tabs", false], |
michael@0 | 59 | ["extensions.getAddons.cache.enabled", false], // https://blog.mozilla.org/addons/how-to-opt-out-of-add-on-metadata-updates/ |
michael@0 | 60 | |
michael@0 | 61 | // Fingerprinting |
michael@0 | 62 | ["webgl.min_capability_mode", true], |
michael@0 | 63 | ["webgl.disable-extensions", true], |
michael@0 | 64 | ["dom.battery.enabled", false], // fingerprinting due to differing OS implementations |
michael@0 | 65 | ["dom.network.enabled",false], // fingerprinting due to differing OS implementations |
michael@0 | 66 | ["browser.display.max_font_attempts",10], |
michael@0 | 67 | ["browser.display.max_font_count",10], |
michael@0 | 68 | ["gfx.downloadable_fonts.fallback_delay", -1], |
michael@0 | 69 | ["general.appname.override", "Netscape"], |
michael@0 | 70 | ["general.appversion.override", "5.0 (Windows)"], |
michael@0 | 71 | ["general.oscpu.override", "Windows NT 6.1"], |
michael@0 | 72 | ["general.platform.override", "Win32"], |
michael@0 | 73 | ["general.useragent.override", "Mozilla/5.0 (Windows NT 6.1; rv:24.0) Gecko/20100101 Firefox/24.0"], |
michael@0 | 74 | ["general.productSub.override", "20100101"], |
michael@0 | 75 | ["general.buildID.override", "20100101"], |
michael@0 | 76 | ["browser.startup.homepage_override.buildID", "20100101"], |
michael@0 | 77 | ["general.useragent.vendor", ""], |
michael@0 | 78 | ["general.useragent.vendorSub", ""], |
michael@0 | 79 | ["dom.enable_performance", false], |
michael@0 | 80 | ["plugin.expose_full_path", false], |
michael@0 | 81 | ["browser.zoom.siteSpecific", false], |
michael@0 | 82 | ["intl.charset.default", "windows-1252"], |
michael@0 | 83 | //["intl.accept_languages", "en-us, en"], // Set by Torbutton |
michael@0 | 84 | //["intl.accept_charsets", "iso-8859-1,*,utf-8"], // Set by Torbutton |
michael@0 | 85 | //["intl.charsetmenu.browser.cache", "UTF-8"], // Set by Torbutton |
michael@0 | 86 | |
michael@0 | 87 | // Third party stuff |
michael@0 | 88 | ["network.cookie.cookieBehavior", 1], |
michael@0 | 89 | ["security.enable_tls_session_tickets", false], |
michael@0 | 90 | ["network.http.spdy.enabled", false], // Stores state and may have keepalive issues (both fixable) |
michael@0 | 91 | ["network.http.spdy.enabled.v2", false], // Seems redundant, but just in case |
michael@0 | 92 | ["network.http.spdy.enabled.v3", false], // Seems redundant, but just in case |
michael@0 | 93 | |
michael@0 | 94 | // Proxy and proxy security |
michael@0 | 95 | ["network.proxy.socks", "127.0.0.1"], |
michael@0 | 96 | ["network.proxy.socks_port", 9150], |
michael@0 | 97 | ["network.proxy.socks_remote_dns", true], |
michael@0 | 98 | ["network.proxy.no_proxies_on", ""], // For fingerprinting and local service vulns (#10419) |
michael@0 | 99 | ["network.proxy.type", 1], |
michael@0 | 100 | ["network.security.ports.banned", "9050,9051,9150,9151"], |
michael@0 | 101 | ["network.dns.disablePrefetch", true], |
michael@0 | 102 | ["network.protocol-handler.external-default", false], |
michael@0 | 103 | ["network.protocol-handler.external.mailto", false], |
michael@0 | 104 | ["network.protocol-handler.external.news", false], |
michael@0 | 105 | ["network.protocol-handler.external.nntp", false], |
michael@0 | 106 | ["network.protocol-handler.external.snews", false], |
michael@0 | 107 | ["network.protocol-handler.warn-external.mailto", true], |
michael@0 | 108 | ["network.protocol-handler.warn-external.news", true], |
michael@0 | 109 | ["network.protocol-handler.warn-external.nntp", true], |
michael@0 | 110 | ["network.protocol-handler.warn-external.snews", true], |
michael@0 | 111 | ["plugins.click_to_play", true], |
michael@0 | 112 | |
michael@0 | 113 | // Network and performance |
michael@0 | 114 | ["network.http.pipelining", true], |
michael@0 | 115 | ["network.http.pipelining.aggressive", true], |
michael@0 | 116 | ["network.http.pipelining.maxrequests", 12], |
michael@0 | 117 | ["network.http.pipelining.ssl", true], |
michael@0 | 118 | ["network.http.proxy.pipelining", true], |
michael@0 | 119 | ["security.ssl.enable_false_start", true], |
michael@0 | 120 | ["network.http.keep-alive.timeout", 20], |
michael@0 | 121 | ["network.http.connection-retry-timeout", 0], |
michael@0 | 122 | ["network.http.max-persistent-connections-per-proxy", 256], |
michael@0 | 123 | ["network.http.pipelining.reschedule-timeout", 15000], |
michael@0 | 124 | ["network.http.pipelining.read-timeout", 60000], |
michael@0 | 125 | // Hacked pref: Now means "Attempt to pipeline at least this many requests together" |
michael@0 | 126 | ["network.http.pipelining.max-optimistic-requests", 3], |
michael@0 | 127 | ["security.disable_session_identifiers", true], |
michael@0 | 128 | |
michael@0 | 129 | // Extension support |
michael@0 | 130 | ["extensions.autoDisableScopes", 0], |
michael@0 | 131 | ["extensions.bootstrappedAddons", "{}"], |
michael@0 | 132 | ["extensions.checkCompatibility.4.*", false], |
michael@0 | 133 | ["extensions.databaseSchema", 3], |
michael@0 | 134 | ["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 | 135 | ["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 | 136 | ["extensions.enabledScopes", 1], |
michael@0 | 137 | ["extensions.pendingOperations", false], |
michael@0 | 138 | ["xpinstall.whitelist.add", ""], |
michael@0 | 139 | ["xpinstall.whitelist.add.36", ""], |
michael@0 | 140 | |
michael@0 | 141 | // Omnibox settings |
michael@0 | 142 | ["keyword.URL", "https://startpage.com/do/search?q="], |
michael@0 | 143 | |
michael@0 | 144 | // Hacks/workarounds: Direct2D seems to crash w/ lots of video cards w/ MinGW? |
michael@0 | 145 | // Nvida cards also experience crashes without the second pref set to disabled |
michael@0 | 146 | ["gfx.direct2d.disabled", true], |
michael@0 | 147 | ["layers.acceleration.disabled", true], |
michael@0 | 148 | |
michael@0 | 149 | // Security enhancements |
michael@0 | 150 | // https://trac.torproject.org/projects/tor/ticket/9387#comment:17 |
michael@0 | 151 | ["javascript.options.ion.content", false], |
michael@0 | 152 | ["javascript.options.baselinejit.content", false], |
michael@0 | 153 | ["javascript.options.asmjs", false], |
michael@0 | 154 | ["javascript.options.typeinference", false], |
michael@0 | 155 | |
michael@0 | 156 | // Audio_data is deprecated in future releases, but still present |
michael@0 | 157 | // in FF24. This is a dangerous combination (spotted by iSec) |
michael@0 | 158 | ["media.audio_data.enabled", false], |
michael@0 | 159 | |
michael@0 | 160 | // Enable TLS 1.1 and 1.2: |
michael@0 | 161 | // https://trac.torproject.org/projects/tor/ticket/11253 |
michael@0 | 162 | ["security.tls.version.max", 3], |
michael@0 | 163 | |
michael@0 | 164 | // Version placeholder |
michael@0 | 165 | ["torbrowser.version", "UNKNOWN"], |
michael@0 | 166 | |
michael@0 | 167 | ]; |
michael@0 | 168 | |
michael@0 | 169 | |
michael@0 | 170 | |
michael@0 | 171 | |
michael@0 | 172 | let getPref = function (prefName) { |
michael@0 | 173 | let type = gPrefService.getPrefType(prefName); |
michael@0 | 174 | if (type === gPrefService.PREF_INT) return gPrefService.getIntPref(prefName); |
michael@0 | 175 | if (type === gPrefService.PREF_BOOL) return gPrefService.getBoolPref(prefName); |
michael@0 | 176 | if (type === gPrefService.PREF_STRING) return gPrefService.getCharPref(prefName); |
michael@0 | 177 | // Something went wrong. |
michael@0 | 178 | throw new Error("Can't access pref."); |
michael@0 | 179 | }; |
michael@0 | 180 | |
michael@0 | 181 | let testPref = function([key, expectedValue]) { |
michael@0 | 182 | let foundValue = getPref(key); |
michael@0 | 183 | is(foundValue, expectedValue, "Pref '" + key + "' should be '" + expectedValue +"'."); |
michael@0 | 184 | }; |
michael@0 | 185 | |
michael@0 | 186 | expectedPrefs.map(testPref); |
michael@0 | 187 | |
michael@0 | 188 | } // end function test() |