They sort of aren't a nonprofit anymore. Too much of their money came from the search deal as opposed to donations so they had to spin off the Mozilla Corporation which is completely owned by the nonprofit Mozilla Foundation. The foundation is what does research like this, and they're funded by donations and a certain percent of the corporations profits.
As for "drowning in money," they make ~$500 million a year. Many people think they waste it by doing things like paying their CEO a few million or being located in San Francisco.