UrlbarInput sets textbox.clickSelectsAll (from the clickSelectsAll pref) in its constructor, but the problem here is that it doesn't keep that property updated when the pref changes. That breaks this test because the test toggles the pref and expects it to change how selection behaves. It's not a problem with the awesomebar because it does in fact have a pref observer that keeps textbox.clickSelectsAll up to date.
So UrlbarInput needs a pref observer. Importantly, the observer either needs to be removed when the input goes away, or it needs to be weak, so that the input isn't held onto when its window closes. What's the best way to do that? We already have UrlbarPrefs, and it already adds itself as a prefs observer. So using UrlbarPrefs as the actual nsIObserver and hooking up a lightweight observer via UrlbarPrefs seems natural. But, UrlbarPrefs is a global singleton that never goes away, so we need to be careful that it doesn't hold on to UrlbarInput or its observer indefinitely. There's WeakSet, but unfortunately it doesn't support iteration, so UrlbarPrefs can't use it to weakly hold observers. There's nsIWeakReference, but that's XPCOM. So there needs to be a removeObserver method. When to call it? UrlbarInput doesn't currently have a notion of a destructor like the awesomebar does. So I added one and call it when the browser window closes.
That all seems like the most straightforward nice way to do this... An alternative would be to make UrlbarInput itself the nsIObserver and nsISupportsWeakReference and skip UrlbarPrefs entirely.