[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

Re: [tor-bugs] #13198 [Tor Browser]: clean up torbutton use of Mozilla services



#13198: clean up torbutton use of Mozilla services
---------------------------------+------------------------------
     Reporter:  arthuredelstein  |      Owner:  tbb-team
         Type:  defect           |     Status:  needs_review
     Priority:  normal           |  Milestone:
    Component:  Tor Browser      |    Version:
   Resolution:                   |   Keywords:  MikePerry201409R
Actual Points:                   |  Parent ID:
       Points:                   |
---------------------------------+------------------------------

Comment (by arthuredelstein):

 Replying to [comment:2 mikeperry]:
 > Hrmm. I'm a little worried about the scoping here for the changes in
 src/chrome/content/torbutton.js. This block at the top in particular:
 > {{{
 > let { getBoolPref, setBoolPref, getCharPref, setCharPref,
 >       getIntPref, setIntPref, clearUserPref, prefHasUserValue
 >       addObserver : addPrefObserver , removeObserver :
 removePrefObserver } = Services.prefs;
 > }}}
 >
 > I know 'let' uses block scoping, but in this case, we're at the top
 level of the torbutton.js file and not technically in a block. This is the
 browser XUL tag's 'window' scope, and is shared with all other browser
 scripts and extension bindings. Does 'let' also make this scope local to
 torbutton.js, considering torbutton.js to be a block (even though it's not
 explicitly one)? Because if it ends up in 'window' scope, then we're
 risking collisions with other addons variable names in 'window'.

 Good point. We could enclose the whole torbutton.js file in a scope like:
 {{{
 /* api methods */ = (function() {
   /* torbutton.js code */
   return api_methods;
 })();
 }}}
 which would help avoid any collisions. But for now I'll just leave out
 that `let` statement at the top and instead use `m_tb_prefs` as an alias
 for `Services.prefs` (which reduces the number of changes in the patch).

--
Ticket URL: <https://trac.torproject.org/projects/tor/ticket/13198#comment:3>
Tor Bug Tracker & Wiki <https://trac.torproject.org/>
The Tor Project: anonymity online
_______________________________________________
tor-bugs mailing list
tor-bugs@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-bugs