[Pkg-mozext-commits] [SCM] torbutton Debian packaging branch, master, updated. debian/1.4.6.3-1
Jérémy Bobbio
lunar at debian.org
Tue Oct 16 20:35:08 UTC 2012
The following commit has been merged in the master branch:
commit 4302a4221a3a5170df54a344b60a49c445e98d8a
Merge: 1066a84d73f2471528b337b7cf422e9b722af553 7a85d55d18a5e6c467343afa9cb7443c47a14c1c
Author: Jérémy Bobbio <lunar at debian.org>
Date: Tue Oct 16 11:00:16 2012 +0200
Merge commit 'upstream/1.4.6.3'
diff --combined src/chrome/content/preferences.js
index 2d90f34,e8f6f27..19e74ce
--- a/src/chrome/content/preferences.js
+++ b/src/chrome/content/preferences.js
@@@ -1,3 -1,5 +1,5 @@@
+ // Bug 1506 P1: Most of this code needs to go away. See also Bug 3100.
+
// PREFERences dialog functions
// torbutton_prefs_set_field_attributes() -- initialize dialog fields
// torbutton_prefs_init() -- on dialog load
@@@ -34,7 -36,7 +36,7 @@@ function torbutton_prefs_set_field_attr
proxy_port = 0;
} else {
if (doc.getElementById('torbutton_usePrivoxy').checked) {
- proxy_host = '127.0.0.1';
+ proxy_host = 'localhost';
proxy_port = 8118;
} else {
proxy_host = '';
diff --combined src/chrome/content/torbutton.js
index 8dc9ee9,e629102..374f403
--- a/src/chrome/content/torbutton.js
+++ b/src/chrome/content/torbutton.js
@@@ -1,3 -1,8 +1,8 @@@
+ // Bug 1506 P0-P5: This is the main Torbutton overlay file. Much needs to be
+ // preserved here, but in an ideal world, most of this code should perhaps be
+ // moved into an XPCOM service, and much can also be tossed. See also
+ // individual 1506 comments for details.
+
// TODO: check for leaks: http://www.mozilla.org/scriptable/avoiding-leaks.html
// TODO: Double-check there are no strange exploits to defeat:
// http://kb.mozillazine.org/Links_to_local_pages_don%27t_work
@@@ -18,12 -23,15 +23,15 @@@ var m_tb_ff3 = false
var m_tb_ff35 = false;
var m_tb_ff36 = false;
var m_tb_ff4 = false;
+ var m_tb_ff15 = false;
+ var m_tb_ff10_8 = false;
var m_tb_tbb = false;
var m_tb_control_port = null;
var m_tb_control_host = null;
var m_tb_control_pass = null;
+ // Bug 1506 P1: This object is only for updating the UI for toggling and style
var torbutton_window_pref_observer =
{
register: function()
@@@ -66,6 -74,10 +74,10 @@@
}
}
+ // Bug 1506 P2: This object keeps Firefox prefs in sync with Torbutton prefs.
+ // It probably could stand some simplification (See #3100). It also belongs
+ // in a component, not the XUL overlay. There also are a lot of toggle-triggering
+ // prefs here..
var torbutton_unique_pref_observer =
{
register: function()
@@@ -342,7 -354,7 +354,7 @@@
}
}
-
+ // Bug 1506 P1
function torbutton_set_panel_view() {
var o_statuspanel = false;
var o_prefbranch = false;
@@@ -352,20 -364,13 +364,21 @@@
if (!o_statuspanel || !o_prefbranch) return;
// Firefox 4 has no toolbar panel
- var display_panel = o_prefbranch.getBoolPref('display_panel')
- && !m_tb_ff4;
+ var display_panel = o_prefbranch.getBoolPref('display_panel');
torbutton_log(2, 'setting panel visibility');
o_statuspanel.setAttribute('collapsed', !display_panel);
+
+ // Prevent the FF4 nav bar from making our menu invisible...
+ var o_toolbutton = torbutton_get_toolbutton();
+ if (o_toolbutton) {
+ var context = document.getElementById('torbutton-context-menu');
+ context.style.visibility = "visible";
+ context.hidden = false;
+ torbutton_log(3, "Set new context menu.");
+ }
}
+ // Bug 1506 P1
function torbutton_set_panel_style() {
var o_statuspanel = false;
var o_prefbranch = false;
@@@ -379,6 -384,7 +392,7 @@@
o_statuspanel.setAttribute('class','statusbarpanel-' + panel_style);
}
+ // Bug 1506 P0: Die toggle, die!
function torbutton_toggle(force) {
var o_toolbutton = false;
@@@ -405,6 -411,7 +419,7 @@@
}
}
+ // Bug 1506 P0: Die toggle, die!
function torbutton_set_status() {
var state = false;
if (torbutton_check_status()) {
@@@ -473,18 -480,40 +488,30 @@@
}
}
+ // Bug 1506 P0: Die toggle die
function torbutton_init_toolbutton()
{
try {
torbutton_log(3, "Initializing the Torbutton button.");
- // Prevent the FF4 status bar from making our menu invisible...
- /* Not needed
- var o_toolbutton = torbutton_get_toolbutton();
- if (o_toolbutton) {
- var context = document.getElementById('torbutton-context-menu');
- context.style.visibility = "visible";
- context.hidden = false;
- torbutton_log(3, "Set new context menu.");
- }
- */
torbutton_update_toolbutton(torbutton_check_status());
} catch(e) {
torbutton_log(4, "Error Initializing Torbutton button: "+e);
}
}
+ // Bug 1506 P2-P4: This code sets some version variables that are irrelevant.
+ // It does read out some important environment variables, though. It is
+ // called once per browser window.. This might belong in a component.
function torbutton_init() {
torbutton_log(3, 'called init()');
+
+ if (m_tb_wasinited) {
+ return;
+ }
+ m_tb_wasinited = true;
+
+ m_tb_prefs = Components.classes["@mozilla.org/preferences-service;1"]
+ .getService(Components.interfaces.nsIPrefBranch);
// Determine if we are firefox 3 or not.
var appInfo = Components.classes["@mozilla.org/xre/app-info;1"]
@@@ -492,6 -521,19 +519,19 @@@
var versionChecker = Components.classes["@mozilla.org/xpcom/version-comparator;1"]
.getService(Components.interfaces.nsIVersionComparator);
+ if(versionChecker.compare(appInfo.version, "15.0a1") >= 0) {
+ m_tb_ff15 = true;
+ } else {
+ m_tb_ff15 = false;
+ }
+
+ if(versionChecker.compare(appInfo.version, "10.0.8") >= 0
+ && versionChecker.compare(appInfo.version, "11.0a1") < 0) {
+ m_tb_ff10_8 = true;
+ } else {
+ m_tb_ff10_8 = false;
+ }
+
if(versionChecker.compare(appInfo.version, "4.0a1") >= 0) {
m_tb_ff4 = true;
} else {
@@@ -516,15 -558,20 +556,20 @@@
m_tb_ff36 = false;
}
+ try {
+ var test = m_tb_prefs.getCharPref("torbrowser.version");
+ m_tb_tbb = true;
+ torbutton_log(3, "This is a Tor Browser");
+ } catch(e) {
+ torbutton_log(3, "This is not a Tor Browser: "+e);
+ }
+
+ // Bug 1506 P4: These vars are very important for New Identity
var environ = Components.classes["@mozilla.org/process/environment;1"]
.getService(Components.interfaces.nsIEnvironment);
if (environ.exists("TOR_CONTROL_PASSWD")) {
m_tb_control_pass = environ.get("TOR_CONTROL_PASSWD");
-
- // FIXME: We might want a check to use to set this in the future,
- // but this works fine for now.
- m_tb_tbb = true;
} else if (environ.exists("TOR_CONTROL_COOKIE_AUTH_FILE")) {
var cookie_path = environ.get("TOR_CONTROL_COOKIE_AUTH_FILE");
try {
@@@ -555,19 -602,10 +600,10 @@@
// listen for our toolbar button being added so we can initialize it
torbutton_init_toolbutton();
- if (!m_tb_wasinited) {
- // Runs every time a new window is opened
- m_tb_prefs = Components.classes["@mozilla.org/preferences-service;1"]
- .getService(Components.interfaces.nsIPrefBranch);
-
- torbutton_init_jshooks();
+ torbutton_init_jshooks();
- torbutton_log(1, 'registering pref observer');
- torbutton_window_pref_observer.register();
- m_tb_wasinited = true;
- } else {
- torbutton_log(1, 'skipping pref observer init');
- }
+ torbutton_log(1, 'registering pref observer');
+ torbutton_window_pref_observer.register();
//setting up context menu
var contextMenu = document.getElementById("contentAreaContextMenu");
@@@ -605,6 -643,9 +641,9 @@@
torbutton_log(3, 'init completed');
}
+ // Bug 1506 P3: This code asks the user once if they want to spoof their
+ // language to English.
+ //
// Asks the user whether Torbutton should make "English requests", and updates
// the extensions.torbutton.spoof_english preference accordingly.
function torbutton_prompt_for_language_preference() {
@@@ -649,6 -690,9 +688,9 @@@ function torbutton_inform_about_tbb()
m_tb_prefs.setBoolPref("extensions.torbutton.prompt_torbrowser", !checkbox.value);
}
+ // Bug 1506 P0: This code only matters in toggle mode (for tor:// urls).
+ // Kill it.
+ //
//this function checks to see if the context menu is being clicked on a link.
//if it is, then we show the two context menu items
function torbutton_check_contextmenu() {
@@@ -658,6 -702,8 +700,8 @@@
torurl.hidden = tortab.hidden = torwin.hidden = (document.popupNode.localName != "A")
}
+ // Bug 1506 P0: This code only matters in toggle mode (for tor:// urls).
+ // Kill it.
function torbutton_copy_link() {
var element = document.popupNode;
var myURI = Components.classes["@mozilla.org/network/io-service;1"]
@@@ -672,6 -718,9 +716,9 @@@
return;//unsupported scheme
torbutton_copyToClipboard(myURI.spec);
}
+
+ // Bug 1506 P0: This code only matters in toggle mode (for tor:// urls).
+ // Kill it.
function torbutton_copyToClipboard(copyThis) {
var str = Components.classes["@mozilla.org/supports-string;1"].createInstance(Components.interfaces.nsISupportsString);
@@@ -691,6 -740,9 +738,9 @@@
clip.setData(trans, null, clipid.kGlobalClipboard);
return true;
}
+
+ // Bug 1506 P0: This code only matters in toggle mode (for tor:// urls).
+ // Kill it.
//opens new tab with link with tor:// protocol
function torbutton_open_link_as_tor(tabFlag) {
var element = document.popupNode;
@@@ -719,12 -771,12 +769,12 @@@
-
+ // Bug 1506 P0: Our prefs should be handled by Tor Browser. Even if they're
+ // not, they should be vastly simplified from this. See also #3100.
+ //
// this function duplicates a lot of code in preferences.js for deciding our
// recommended settings. figure out a way to eliminate the redundancy.
// TODO: Move it to torbutton_util.js?
-
- // XXX: Still doesn't help torbrowser...
function torbutton_init_prefs() {
var torprefs = false;
var proxy_port;
@@@ -743,7 -795,7 +793,7 @@@
torprefs.setBoolPref('use_privoxy', true);
if (torprefs.getBoolPref('use_privoxy')) {
- proxy_host = '127.0.0.1';
+ proxy_host = 'localhost';
proxy_port = 8118;
} else {
proxy_host = '';
@@@ -779,6 -831,7 +829,7 @@@
torbutton_log(1, 'http_port='+torprefs.getIntPref('http_port'));
}
+ // Bug 1506 P2: It might be nice to let people move the button around, I guess?
function torbutton_get_button_from_toolbox() {
var toolbox = document.getElementById("navigator-toolbox");
for (var child = toolbox.palette.firstChild; child; child = child.nextSibling)
@@@ -788,6 -841,7 +839,7 @@@
return torbutton_get_toolbutton();
}
+ // Bug 1506 P2: It might be nice to let people move the button around, I guess?
function torbutton_get_toolbutton() {
var o_toolbutton = false;
@@@ -818,6 -872,7 +870,7 @@@ function torbutton_get_statuspanel()
return o_statuspanel;
}
+ // Bug 1506 P0: Toggle. Kill kill kill.
function torbutton_save_nontor_settings()
{
var liveprefs = false;
@@@ -857,6 -912,7 +910,7 @@@
torbutton_log(2, 'Non-tor settings saved');
}
+ // Bug 1506 P0: Toggle. Kill kill kill.
function torbutton_restore_nontor_settings()
{
var liveprefs = false;
@@@ -905,11 -961,14 +959,14 @@@
torbutton_log(2, 'settings restored');
}
+ // Bug 1506 P4: Checking for Tor Browser updates is pretty important,
+ // probably even as a fallback if we ever do get a working updater.
function torbutton_do_async_versioncheck() {
if (!m_tb_tbb || !m_tb_prefs.getBoolPref("extensions.torbutton.versioncheck_enabled")) {
return;
}
- torbutton_log(3, "Checking version");
+ torbutton_log(3, "Checking version with socks port: "
+ +m_tb_prefs.getIntPref("extensions.torbutton.socks_port"));
try {
var req = Components.classes["@mozilla.org/xmlextras/xmlhttprequest;1"]
.createInstance(Components.interfaces.nsIXMLHttpRequest);
@@@ -970,6 -1029,7 +1027,7 @@@
}
+ // Bug 1506 P0: Deprecated by the async version.
function torbutton_check_version() {
torbutton_log(3, "Checking version");
try {
@@@ -1016,7 -1076,8 +1074,8 @@@
return -1;
}
-
+ // Bug 1506 P2: Probably a good idea to have some way to test everything,
+ // but will need to be decoupled from the toggle logic :/
function torbutton_test_settings() {
var wasEnabled = true;
var ret = 0;
@@@ -1091,12 -1152,14 +1150,14 @@@
return ret;
}
+ // Bug 1506 P0: Toggle must die.
function torbutton_disable_tor()
{
torbutton_log(3, 'called disable_tor()');
torbutton_restore_nontor_settings();
}
+ // Bug 1506 P0: Toggle must die.
function torbutton_enable_tor(force)
{
torbutton_log(3, 'called enable_tor()');
@@@ -1116,6 -1179,7 +1177,7 @@@
torbutton_activate_tor_settings();
}
+ // Bug 1506 P0: Toggle must die.
function torbutton_update_toolbutton(mode)
{
var o_toolbutton = torbutton_get_toolbutton();
@@@ -1134,6 -1198,7 +1196,7 @@@
}
}
+ // Bug 1506 P0: Toggle must die.
function torbutton_update_statusbar(mode)
{
var o_statuspanel = torbutton_get_statuspanel();
@@@ -1159,6 -1224,9 +1222,9 @@@
}
}
+ // Bug 1506 P0: This is support code for preserving user prefs during
+ // toggle.
+ //
// XXX: Hrmm, this may not always be called with ints (see bug 1006).
// Possibly because some other addon sets odd values for a pref
// that can be either int or char? Can maybe just wrap in try block
@@@ -1190,6 -1258,8 +1256,8 @@@ function torbutton_setIntPref(pref, sav
}
}
+ // Bug 1506 P0: This is support code for preserving user prefs during
+ // toggle.
function torbutton_setCharPref(pref, save, val, mode, changed) {
if(!changed) return; // Handle the pref change cases via observers
try {
@@@ -1217,6 -1287,8 +1285,8 @@@
}
}
+ // Bug 1506 P0: This is support code for preserving user prefs during
+ // toggle.
function torbutton_setBoolPref(pref, save, val, mode, changed) {
if(!changed) return; // Handle the pref change cases via observers
try {
@@@ -1244,6 -1316,7 +1314,7 @@@
}
}
+ // Bug 1506 P4: Timezone spoofing is pretty important
function torbutton_set_timezone(mode, startup) {
/* Windows doesn't call tzset() automatically.. Linux and MacOS
* both do though.. FF3.5 now calls _tzset() for us on windows.
@@@ -1307,6 -1380,7 +1378,7 @@@
}
}
+ // Bug 1506 P3: Support code for language+uagent spoofing
function torbutton_get_general_useragent_locale() {
try {
var locale = m_tb_prefs.getCharPref("general.useragent.locale");
@@@ -1321,6 -1395,9 +1393,9 @@@
}
}
+ // Bug 1506 P3: Useragent spoofing code.. Important, but perhaps
+ // we only need to do this in code for toggling. Can probably be
+ // directly in prefs.js
function torbutton_set_uagent() {
try {
var torprefs = torbutton_get_prefbranch('extensions.torbutton.');
@@@ -1372,6 -1449,7 +1447,7 @@@
}
}
+ // Bug 1506 P4: Control port interaction. Needed for New Identity.
function torbutton_socket_readline(input) {
var str = "";
var bytes;
@@@ -1381,6 -1459,7 +1457,7 @@@
return str;
}
+ // Bug 1506 P4: Control port interaction. Needed for New Identity.
function torbutton_read_authentication_cookie(path) {
var file = Components.classes['@mozilla.org/file/local;1']
.createInstance(Components.interfaces.nsILocalFile);
@@@ -1397,11 -1476,15 +1474,15 @@@
return torbutton_array_to_hexdigits(array);
}
+ // Bug 1506 P4: Control port interaction. Needed for New Identity.
function torbutton_array_to_hexdigits(array) {
return array.map(function(c) {
return String("0" + c.toString(16)).slice(-2)
}).join('');
};
+
+ // Bug 1506 P4: Control port interaction. Needed for New Identity.
+ //
// Executes a command on the control port.
// Return 0 in error, 1 for success.
function torbutton_send_ctrl_cmd(command) {
@@@ -1443,6 -1526,7 +1524,7 @@@
}
}
+ // Bug 1506 P4: Needed for New Identity.
function torbutton_new_identity() {
try {
torbutton_do_new_identity();
@@@ -1471,6 -1555,7 +1553,7 @@@
*
* XXX: intermediate SSL certificates are not cleared.
*/
+ // Bug 1506 P4: Needed for New Identity.
function torbutton_do_new_identity() {
var wm = Components.classes["@mozilla.org/appshell/window-mediator;1"]
.getService(Components.interfaces.nsIWindowMediator);
@@@ -1641,6 -1726,9 +1724,9 @@@
window.close();
}
+ // Bug 1506 P5: Despite the name, this is the way we disable
+ // plugins for Tor Browser, too.
+ //
// toggles plugins: true for disabled, false for enabled
function torbutton_toggle_plugins(disable_plugins) {
if (m_tb_tbb) {
@@@ -1653,6 -1741,17 +1739,17 @@@
}
+ // Bug 1506 P1/P4: This code is *mostly* a toggle-relic.
+ //
+ // For full browser implementations, this function is P1, and you should
+ // just use https://gitweb.torproject.org/torbrowser.git/blob/HEAD:/build-scripts/config/prefs.js
+ //
+ // For native Firefox implementations, this code might be P4, since you'll
+ // need to set all those prefs, as well as preserve people's originals for
+ // uninstall. There are also two prefs that should be set in a native
+ // Firefox implementation at level P5. I believe Proxy Mobile already
+ // sets them, though.
+ //
// NOTE: If you touch any additional prefs in here, be sure to update
// the list in torbutton_util.js::torbutton_reset_browser_prefs()
function torbutton_update_status(mode, force_update) {
@@@ -1698,6 -1797,8 +1795,8 @@@
// thread
torbutton_log(2, 'Toggling JS state');
+ // Bug 1506 P5: You want to call torbutton_toggle_plugins, but during
+ // startup, not toggle.
torbutton_toggle_plugins(mode && torprefs.getBoolPref("no_tor_plugins"));
torbutton_toggle_jsplugins(mode,
@@@ -2047,6 -2148,7 +2146,7 @@@
// being pwnt. This is a pretty darn ugly hack, too. But because of #5863,
// we really don't care about preserving the user's values for this.
if (!m_tb_tbb) {
+ // Bug 1506 P5: You have to set these two for non-TBB Firefoxen
m_tb_prefs.setBoolPref("network.websocket.enabled", false);
m_tb_prefs.setBoolPref("dom.indexedDB.enabled", false);
}
@@@ -2169,6 -2271,7 +2269,7 @@@
torbutton_log(3, "Settings applied for mode: "+mode);
}
+ // Bug 1506 P4: Despite the name, it is used on new identity
function torbutton_close_on_toggle(mode, newnym) {
var close_tor = m_tb_prefs.getBoolPref("extensions.torbutton.close_tor");
var close_nontor = m_tb_prefs.getBoolPref("extensions.torbutton.close_nontor");
@@@ -2230,6 -2333,8 +2331,8 @@@
torbutton_log(3, "Closed all tabs");
}
+ // Bug 1506 P2: This code is only important for disabling
+ // New Identity where it is not supported (ie no control port).
function torbutton_check_protections()
{
var cookie_pref = m_tb_prefs.getBoolPref("extensions.torbutton.cookie_protections");
@@@ -2245,15 -2350,19 +2348,19 @@@
}
}
+ // Bug 1506 P2: I think cookie protections is a neat feature.
function torbutton_open_cookie_dialog() {
window.openDialog('chrome://torbutton/content/torcookiedialog.xul','Cookie Protections',
'centerscreen,chrome,dialog,modal,resizable');
}
+
+ // Bug 1506 P2/P3: Prefs are handled differently on android, I guess?
function torbutton_open_prefs_dialog() {
window.openDialog("chrome://torbutton/content/preferences.xul","torbutton-preferences","centerscreen, chrome");
torbutton_log(2, 'opened preferences window');
}
+ // Bug 1506 P0: Support code for checking Firefox versions. Not needed.
function torbutton_gecko_compare(aVersion) {
var ioService = Components.classes["@mozilla.org/network/io-service;1"]
.getService(Components.interfaces.nsIIOService);
@@@ -2272,6 -2381,8 +2379,8 @@@
return versionComparator.compare(aVersion, geckoVersion);
}
+ // Bug 1506 P0: Code to attempt to grey out browser proxy prefs. Doesn't
+ // actually seem to work?
function torbutton_browser_proxy_prefs_init()
{
var _elementIDs = ["networkProxyType",
@@@ -2301,6 -2412,7 +2410,7 @@@
}
// -------------- HISTORY & COOKIES ---------------------
+ // Bug 1506 P0: Only used by toggle. Kill it.
function torbutton_clear_history() {
torbutton_log(2, 'called torbutton_clear_history');
var hist = Components.classes["@mozilla.org/browser/global-history;2"]
@@@ -2334,6 -2446,8 +2444,8 @@@
}
}
+ // Bug 1506 P4: Used by New Identity if cookie protections are
+ // not in use.
function torbutton_clear_cookies() {
torbutton_log(2, 'called torbutton_clear_cookies');
var cm = Components.classes["@mozilla.org/cookiemanager;1"]
@@@ -2342,7 -2456,7 +2454,7 @@@
cm.removeAll();
}
-
+ // Bug 1506 P0: Toggle-only. Kill it.
function torbutton_jar_cookies(mode) {
var selector =
Components.classes["@torproject.org/cookie-jar-selector;1"]
@@@ -2374,6 -2488,7 +2486,7 @@@
}
}
+ // Bug 1506 P0: Toggle-only. Kill it.
function torbutton_jar_cert_type(mode, treeView, name, type) {
var certdb = Components.classes["@mozilla.org/security/x509certdb;1"]
.getService(Components.interfaces.nsIX509CertDB2);
@@@ -2490,6 -2605,7 +2603,7 @@@
torbutton_log(2, "Wrote "+outList.length+" "+name+" certificates to "+outFile.path);
}
+ // Bug 1506 P0: Toggle-only. Kill it.
function torbutton_bytearray_to_string(ba) {
var ret = "";
for(var i = 0; i < ba.length; i++) {
@@@ -2498,6 -2614,7 +2612,7 @@@
return ret;
}
+ // Bug 1506 P0: Toggle-only. Kill it.
function torbutton_unjar_cert_type(mode, treeView, name, type) {
var unjared_certs = 0;
var certdb = Components.classes["@mozilla.org/security/x509certdb;1"]
@@@ -2591,6 -2708,7 +2706,7 @@@
return unjared_certs;
}
+ // Bug 1506 P0: Toggle-only. Kill it.
function torbutton_jar_certs(mode) {
var tot_certs = 0;
var certCache =
@@@ -2742,7 -2860,7 +2858,7 @@@
// -------------- JS/PLUGIN HANDLING CODE ---------------------
-
+ // Bug 1506 P0: Toggle-only. Kill it.
function torbutton_check_js_tag(tabbrowser, browser, tor_enabled, js_enabled) {
var eventSuppressor = null;
if (typeof(browser.__tb_tor_fetched) == 'undefined') {
@@@ -2794,6 -2912,8 +2910,8 @@@
}
}
+ // Bug 1506 P3: The JS-killing bits of this are used by
+ // New Identity as a defense-in-depth measure.
function torbutton_toggle_win_jsplugins(win, tor_enabled, js_enabled, isolate_dyn,
kill_plugins) {
var browser = win.getBrowser();
@@@ -2843,6 -2963,9 +2961,9 @@@
}
}
+ // Bug 1506 P3: The JS-killing bits of this are used by
+ // New Identity as a defense-in-depth measure.
+ //
// This is an ugly beast.. But unfortunately it has to be so..
// Looping over all tabs twice is not somethign we wanna do..
function torbutton_toggle_jsplugins(tor_enabled, isolate_dyn, kill_plugins) {
@@@ -2858,6 -2981,7 +2979,7 @@@
}
}
+ // Bug 1506 P0: Toggle garbage.
function tbHistoryListener(browser) {
this.browser = browser;
@@@ -2878,6 -3002,7 +3000,7 @@@
};
}
+ // Bug 1506 P0: Toggle garbage.
tbHistoryListener.prototype = {
QueryInterface: function(iid) {
// XXX: Is this the right way to handle weak references from JS?
@@@ -2897,6 -3022,11 +3020,11 @@@
OnHistoryReload: function(uri,flags) { return this.f1(); }
};
+ // Bug 1506 P1: Technically, tags are still used by New Identity as
+ // defense-in-depth, but they are very expensive to enforce and requires
+ // an nsIConentPolicy, which is broken on Android last I checked.
+ // Killing this is fine, but be sure to watch out for other places
+ // where tab tags are referenced.
function torbutton_apply_tab_tag(tabbrowser, browser, tag) {
if (typeof(browser["__tb_tor_fetched"]) == "undefined" ||
browser.__tb_tor_fetched != tag) {
@@@ -2929,6 -3059,7 +3057,7 @@@
return oldtag != tag;
}
+ // Bug 1506 P1: Tagging is pretty much toggle-only. See above.
function torbutton_tag_new_browser(browser, tor_tag, no_plugins) {
if (!tor_tag && no_plugins && !m_tb_tbb) {
browser.docShell.allowPlugins = tor_tag;
@@@ -2972,6 -3103,7 +3101,7 @@@
}
}
+ // Bug 1506 P0: This has been deprecated in favor of an async check
function torbutton_do_versioncheck() {
if (m_tb_tbb && m_tb_prefs.getBoolPref("extensions.torbutton.versioncheck_enabled")) {
var is_updated = torbutton_check_version();
@@@ -2991,12 -3123,17 +3121,17 @@@
}
}
+ // Bug 1506 P2: We may want to replace this with a XUl solution.
+ // See #6096.
function torbutton_reload_homepage() {
var homepage = m_tb_prefs.getComplexValue("browser.startup.homepage",
Components.interfaces.nsIPrefLocalizedString).data;
+
+ torbutton_log(3, "Reloading homepage: "+homepage);
gBrowser.loadURI(homepage, null, null);
}
+ // Bug 1506 P0: There are no states, only Tor.
function torbutton_set_launch_state(state, session_restore) {
if (!m_tb_wasinited) torbutton_init();
var no_plugins = m_tb_prefs.getBoolPref("extensions.torbutton.no_tor_plugins");
@@@ -3078,6 -3215,7 +3213,7 @@@
}
}
+ // Bug 1506 P0: Toggle, kill it.
function torbutton_restore_cookies(tor_enabled)
{
var selector =
@@@ -3101,6 -3239,7 +3237,7 @@@
}
}
+ // Bug 1506 P0: We only care about crashes in a toggle world. Kill this.
function torbutton_crash_recover()
{
if (!m_tb_wasinited) torbutton_init();
@@@ -3193,6 -3332,9 +3330,9 @@@
// ---------------------- Event handlers -----------------
+ // Bug 1506 P0: This observer was due to a hack to try to get rid
+ // of Google captchas.. It didn't work. Kill it.
+ //
// Observer to handle regeneration of google pref cookies
var torbutton_cookie_observer = {
observe: function(subject, topic, data) {
@@@ -3240,6 -3382,8 +3380,8 @@@ unregister: function()
};
+ // Bug 1506 P0: This function was due to a hack to try to get rid
+ // of Google captchas.. It didn't work. Kill it.
function torbutton_new_google_cookie() {
var regen = m_tb_prefs.getBoolPref("extensions.torbutton.regen_google_cookies");
var reset = m_tb_prefs.getBoolPref("extensions.torbutton.reset_google_cookies");
@@@ -3269,6 -3413,8 +3411,8 @@@
}
}
+ // Bug 1506 P0: This function was due to a hack to try to get rid
+ // of Google captchas.. It didn't work. Kill it.
function torbutton_init_hidden_browser() {
var loaderBox = document.createElement("hbox");
loaderBox.setAttribute("style", "overflow: hidden; visibility: hidden;");
@@@ -3311,6 -3457,8 +3455,8 @@@
torbutton_log(3, "Created hidden browser.");
}
+ // Bug 1506 P0: This function was due to a hack to try to get rid
+ // of Google captchas.. It didn't work. Kill it.
var torbutton_google_cookie_regen_listener = {
QueryInterface: function(aIID)
{
@@@ -3339,6 -3487,8 +3485,8 @@@
onLinkIconAvailable: function() {return 0;}
};
+ // Bug 1506 P0: This function was due to a hack to try to get rid
+ // of Google captchas.. It didn't work. Kill it.
function torbutton_regen_google_cookie() {
// Only fire if tor fully enabled...
if (m_tb_prefs.getBoolPref("extensions.torbutton.proxies_applied")) {
@@@ -3366,6 -3516,8 +3514,8 @@@
}
}
+ // Bug 1506 P0: This function was due to a hack to try to get rid
+ // of Google captchas.. It didn't work. Kill it.
function torbutton_reset_google_cookie() {
// Only fire if tor is fully enabled..
if (m_tb_prefs.getBoolPref("extensions.torbutton.proxies_applied")) {
@@@ -3423,7 -3575,9 +3573,9 @@@ function torbutton_filter_cookies(filte
}
*/
-
+ // Bug 1506 P1: This function was due to a hack to try to limit
+ // Google captchas.. It might help, but it's probably not worth
+ // it.
function torbutton_xfer_google_cookies(subject, topic, data) {
// Only fire if tor is fully enabled
if (m_tb_prefs.getBoolPref("extensions.torbutton.proxies_applied")) {
@@@ -3559,6 -3713,7 +3711,7 @@@
}
}
+ // Bug 1506 P2: Google captchas really suck. This is still useful
/* Redirect the user to a different search engine if Google is blocking Tor */
function torbutton_check_google_captcha(subject, topic, data) {
if (!m_tb_prefs.getBoolPref("extensions.torbutton.proxies_applied"))
@@@ -3655,6 -3810,9 +3808,9 @@@
// to deal with firefox bug 401296
// TODO: One of these days we should probably unify these http observers
// with our content policy, like NoScript does.
+ //
+ // Bug 1506 P2: Most of this is toggle/plugin protections, however
+ // the google captcha redirect is also in here.
var torbutton_http_observer = {
observe : function(subject, topic, data) {
torbutton_eclog(2, 'Examine response: '+subject.name);
@@@ -3705,6 -3863,8 +3861,8 @@@
}
if (topic == "http-on-examine-response") {
+ // Bug 1506 P2: This is the only observer topic you might want
+ // to keep in this object
torbutton_eclog(3, 'Definitaly Examine response: '+subject.name);
if (m_tb_prefs.getBoolPref("extensions.torbutton.dodge_google_captcha")
&& subject instanceof Ci.nsIHttpChannel) {
@@@ -3747,6 -3907,8 +3905,8 @@@ unregister : function()
}
}
+ // Bug 1506 P0: Forces torbutton updates over tor when in non-tor mode.
+ // Actually, this observer is already disabled due to being irrelevant.
var torbutton_proxyservice = {
applyFilter : function(ps, uri, proxy) {
try {
@@@ -3846,6 -4008,8 +4006,8 @@@
}
}
+ // Bug 1506 P1/P3: This removes any platform-specific junk
+ // from the omnibox. In Tor Browser, it should not be needed.
function torbutton_wrap_search_service()
{
var ss = Cc["@mozilla.org/browser/search-service;1"]
@@@ -3891,6 -4055,8 +4053,8 @@@
}
}
+ // Bug 1506 P1-P3: Most of these observers aren't very important.
+ // See their comments for details
function torbutton_do_main_window_startup()
{
torbutton_log(3, "Torbutton main window startup");
@@@ -3913,12 -4079,16 +4077,16 @@@
torbutton_unique_pref_observer.register();
torbutton_http_observer.register();
torbutton_cookie_observer.register();
- torbutton_proxyservice.register();
+ // Not needed
+ //torbutton_proxyservice.register();
- // XXX: We should fold this into our code
+ // Bug 1506: This is probably the most important observer in this function
+ // XXX: We should fold this into our code/move it to its own component
SSC_startup();
}
+ // Bug 1506 P0: We should always start with Tor enabled based on
+ // prefs.js. We probably don't need this code to enforce it.
function torbutton_set_initial_state() {
if(m_tb_prefs.getBoolPref("extensions.torbutton.noncrashed")) {
var restore_tor = m_tb_prefs.getBoolPref("extensions.torbutton.restore_tor");
@@@ -3936,6 -4106,8 +4104,8 @@@
}
}
+ // Bug 1506 P1: This is a relic of the need to sync up user prefs to
+ // tor prefs. See #3100 for a more generalized approach
function torbutton_do_fresh_install()
{
if(m_tb_prefs.getBoolPref("extensions.torbutton.fresh_install")) {
@@@ -3965,6 -4137,10 +4135,10 @@@
}
}
+ // Bug 1506 P4: Most of this function is now useless, save
+ // for the very important SOCKS environment vars at the end.
+ // Those could probably be rolled into a function with the
+ // control port vars, though. See 1506 comments inside.
function torbutton_do_startup()
{
if(m_tb_prefs.getBoolPref("extensions.torbutton.startup")) {
@@@ -3985,6 -4161,7 +4159,7 @@@
m_tb_prefs.setBoolPref('extensions.torbutton.clear_cookies', false);
}
+ // Bug 1506: Should probably be moved to an XPCOM component
torbutton_do_main_window_startup();
// This is due to Bug 908: UserAgent Switcher is resetting
@@@ -4006,6 -4183,7 +4181,7 @@@
}
}
+ // Bug 1506: Still want to do this
torbutton_set_timezone(tor_enabled, true);
// FIXME: This is probably better done by reimplementing the
@@@ -4022,6 -4200,7 +4198,7 @@@
}
}
+ // Bug 1506: Still want to do this
torbutton_toggle_plugins(tor_enabled
&& m_tb_prefs.getBoolPref("extensions.torbutton.no_tor_plugins"));
@@@ -4031,27 -4210,6 +4208,6 @@@
torbutton_new_google_cookie();
}
- var environ = Components.classes["@mozilla.org/process/environment;1"]
- .getService(Components.interfaces.nsIEnvironment);
-
- if (environ.exists("TOR_SOCKS_PORT")) {
- m_tb_prefs.setIntPref('extensions.torbutton.socks_port', parseInt(environ.get("TOR_SOCKS_PORT")));
- if (m_tb_tbb) {
- m_tb_prefs.setIntPref('network.proxy.socks_port', parseInt(environ.get("TOR_SOCKS_PORT")));
- }
- } else if (m_tb_prefs.getCharPref('extensions.torbutton.settings_method') == 'recommended') {
- m_tb_prefs.setIntPref('extensions.torbutton.socks_port', 9050);
- }
-
- if (environ.exists("TOR_SOCKS_HOST")) {
- m_tb_prefs.setCharPref('extensions.torbutton.socks_host', environ.get("TOR_SOCKS_HOST"));
- if (m_tb_tbb) {
- m_tb_prefs.setCharPref('network.proxy.socks', environ.get("TOR_SOCKS_HOST"));
- }
- } else if (m_tb_prefs.getCharPref('extensions.torbutton.settings_method') == 'recommended') {
- m_tb_prefs.setCharPref('extensions.torbutton.socks_host', '127.0.0.1');
- }
-
if (!m_tb_tbb && m_tb_prefs.getBoolPref("extensions.torbutton.prompt_torbrowser")) {
var o_stringbundle = torbutton_get_stringbundle();
var warning = o_stringbundle.GetStringFromName("torbutton.popup.short_torbrowser");
@@@ -4064,6 -4222,7 +4220,7 @@@
}
}
+ // Bug 1506 P0: Old way of blocking plugins. Kill it
function torbutton_get_plugin_mimetypes()
{
m_tb_plugin_mimetypes = { null : null };
@@@ -4079,6 -4238,9 +4236,9 @@@
}
+ // Bug 1506 P0: Has some tagging code (can be removed)
+ // and the language prompt (probably the wrong place for the
+ // call)
function torbutton_new_tab(event)
{
// listening for new tabs
@@@ -4104,6 -4266,8 +4264,8 @@@
}
}
+ // Bug 1506 P3: Used to decide if we should resize the window.
+ //
// Returns true if the window wind is neither maximized, full screen,
// ratpoisioned/evilwmed, nor minimized.
function torbutton_is_windowed(wind) {
@@@ -4128,6 -4292,8 +4290,8 @@@
return true;
}
+ // Bug 1506 P0: Kill this
+ //
// XXX: This function is unused. We can't make it work
// without a way to tell when the user has stopped resizing..
function torbutton_do_resize(ev)
@@@ -4161,6 -4327,7 +4325,7 @@@
m_tb_window_width = window.outerWidth;
}
+ // Bug 1506 P0: Kill this
// XXX: unused. Use torbutton_set_window_size instead
function torbutton_check_round(browser)
{
@@@ -4186,6 -4353,8 +4351,8 @@@
}
}
+ // Bug 1506 P1/P3: Setting a fixed window size is important, but
+ // probably not for android.
function torbutton_set_window_size(bWin) {
if (!bWin || typeof(bWin) == "undefined") {
torbutton_log(5, "No initial browser content window?");
@@@ -4238,6 -4407,9 +4405,9 @@@
}
}
+ // Bug 1506 P3: This is needed pretty much only for the version check
+ // and the window resizing. See comments for individual functions for
+ // details
function torbutton_new_window(event)
{
torbutton_log(3, "New window");
@@@ -4273,6 -4445,8 +4443,8 @@@
torbutton_do_async_versioncheck();
}
+ // Bug 1506 P2: This is only needed because we have observers
+ // in XUL that should be in an XPCOM component
function torbutton_close_window(event) {
torbutton_window_pref_observer.unregister();
@@@ -4304,7 -4478,8 +4476,8 @@@
torbutton_unique_pref_observer.unregister();
torbutton_http_observer.unregister();
torbutton_cookie_observer.unregister();
- torbutton_proxyservice.unregister();
+ // Not needed
+ //torbutton_proxyservice.unregister();
// XXX: We should fold this into our code..
SSC_controller.removeListener();
@@@ -4327,7 -4502,7 +4500,7 @@@ window.addEventListener('unload', torbu
// ----------- JAVASCRIPT HOOKING + EVENT HANDLERS ----------------
-
+ // Bug 1506 P1: All of our JS hooks should be redone in patch form (#5856)
function torbutton_init_jshooks() {
torbutton_log(2, "torbutton_init_jshooks()");
var nsio = Components.classes["@mozilla.org/network/io-service;1"]
@@@ -4348,6 -4523,7 +4521,7 @@@
istream.close();
}
+ // Bug 1506 P1: All of our JS hooks should be redone in patch form (#5856)
function torbutton_getbody(doc) {
if (doc.body)
return doc.body;
@@@ -4360,10 -4536,12 +4534,12 @@@
* nebulous scoping/parsing/evaluations issues. Having this as
* a standalone statement seems to cause the flag
* to become defined after just parsing, not execution */
+ // Bug 1506 P1: All of our JS hooks should be redone in patch form (#5856)
function torbutton_set_flag(obj, flag) {
obj[flag] = true;
}
+ // Bug 1506 P1: All of our JS hooks should be redone in patch form (#5856)
function torbutton_check_flag(obj, flag) {
try {
return (typeof(obj[flag]) != 'undefined');
@@@ -4373,6 -4551,7 +4549,7 @@@
}
}
+ // Bug 1506 P1: All of our JS hooks should be redone in patch form (#5856)
function torbutton_is_same_origin(win, source, target) { // unused.
var fixup = Components.classes["@mozilla.org/docshell/urifixup;1"]
.getService(Components.interfaces.nsIURIFixup);
@@@ -4398,7 -4577,8 +4575,8 @@@
}
}
-
+ // Bug 1506 P1: All of our JS hooks should be redone in patch form (#5856)
+ // Also, tagging can be deprecated.
function torbutton_update_tags(win, new_loc) {
var tag_change = false;
torbutton_eclog(2, "Updating tags.");
@@@ -4534,7 -4714,15 +4712,15 @@@
// - http://swik.net/User:Staple/JavaScript+Popup+Windows+Generation+and+Testing+Tutorials
// - pure javascript pages/non-text/html pages
// - Messing with variables/existing hooks
+ // Bug 1506 P1: All of our JS hooks should be redone in patch form (#5856)
+ // Also, tagging can be deprecated.
function torbutton_hookdoc(win, doc, state_change, referrer) {
+ /* Firefox 15 broke the last of our JS hooks.
+ * So did 10.0.8-ESR... */
+ if (m_tb_ff15 || m_tb_ff10_8) {
+ return;
+ }
+
if(typeof(win.wrappedJSObject) == 'undefined') {
torbutton_eclog(3, "No JSObject: "+win.location);
return;
@@@ -4660,6 -4848,8 +4846,8 @@@
// of its being called so early. Need to find a quick way to check if
// aProgress and aRequest are actually fully initialized
// (without throwing exceptions)
+ // Bug 1506 P0: This is to block full page plugins. Not needed anymore
+ // due to better (but non-toggle-friendly) plugin APIs)
function torbutton_check_progress(aProgress, aRequest, aFlags, new_loc) {
if (!m_tb_wasinited) {
torbutton_init();
@@@ -4845,7 -5035,10 +5033,10 @@@
// Warning: These can also fire when the 'debuglogger' extension
// updates its window. Typically for this, doc.domain is null. Do not
// log in this case (until we find a better way to filter those
- // events out). Use torbutton_eclog for common-path stuff.
+ // events out). Use torbutton_eclog for common-path stuff.]
+ //
+ // Bug 1506 P0: This listener is for blocking plugins and installing JS hooks.
+ // It can be eliminated.
var torbutton_weblistener =
{
QueryInterface: function(aIID)
--
torbutton Debian packaging
More information about the Pkg-mozext-commits
mailing list