Fix javascript bug with popups

Dynamic themes applies the current main frame theme to the browser
tree frame without checking if it actually exists in the current
window.

Thispatch fix the resulting javascript error, breaking any other
following code.