@@ -590,8 +590,37 @@ HTTPSEverywhere.prototype = {
590590 } ;
591591 if ( ! shown && ! enabled )
592592 ssl_observatory . registerProxyTestNotification ( obs_popup_callback ) ;
593+
594+ if ( shown && enabled )
595+ this . maybeCleanupObservatoryPrefs ( ssl_observatory ) ;
593596 } ,
594597
598+ maybeCleanupObservatoryPrefs : function ( ssl_observatory ) {
599+ // Recover from a past UI processing bug that would leave the Obsevatory
600+ // accidentally disabled for some users
601+ // https://trac.torproject.org/projects/tor/ticket/10728
602+ var clean = ssl_observatory . myGetBoolPref ( "clean_config" ) ;
603+ if ( clean ) return ;
604+
605+ // unchanged: returns true if a pref has not been modified
606+ var unchanged = function ( p ) { return ! ssl_observatory . prefs . prefHasUserValue ( "extensions.https_everywhere._observatory." + p ) } ;
607+ var cleanup_obsprefs_callback = function ( tor_avail ) {
608+ // we only run this once
609+ ssl_observatory . prefs . setBoolPref ( "extensions.https_everywhere._observatory.clean_config" , true ) ;
610+ if ( ! tor_avail ) {
611+ // use_custom_proxy is the variable that is often false when it should be true;
612+ if ( ! ssl_observatory . myGetBoolPref ( "use_custom_proxy" ) ) {
613+ // however don't do anything if any of the prefs have been set by the user
614+ if ( unchanged ( "alt_roots" ) && unchanged ( "self_signed" ) && unchanged ( "send_asn" ) && unchanged ( "priv_dns" ) ) {
615+ ssl_observatory . prefs . setBoolPref ( "extensions.https_everywhere._observatory.use_custom_proxy" , true ) ;
616+ }
617+ }
618+ }
619+ }
620+ ssl_observatory . registerProxyTestNotification ( cleanup_obsprefs_callback ) ;
621+ } ,
622+
623+
595624 getExperimentalFeatureCohort : function ( ) {
596625 // This variable is used for gradually turning on features for testing and
597626 // scalability purposes. It is a random integer [0,N_COHORTS) generated
0 commit comments