How to change the main window icon of Firefox 26 and above

Firefox is truly a very customizable browser. It has lots of hidden features and options which are not accessible via the browser's preferences UI. Add-ons enable many of these features to be customized in a user friendly way. Others can be tweaked with the built-in configuration editor (about:config). One such secret feature of Firefox is the ability to change the icon of the main window and bookmarks as well as library windows. You can even set your own icon for the downloads library, the bookmarks window, and the view source tool without using any third party tools. Let's see how it can be done.