It only works for Chrome now, but it should be standardizes for the open web soon.
"Many of us are guilty of constantly switching back to Gmail to check for new messages. And if you’re like me, you’ve probably missed an important chat message because you weren’t looking at your Gmail window when it came in. If you use Google Chrome, these days can be over since we just launched HTML5 desktop notifications which display pop-ups whenever a chat message or new email arrives.
To turn them on, click on the Settings link in the top right corner of Gmail and scroll down to the “Desktop Notifications” section. If you just want to get notified about chat messages, or if you use Priority Inbox and only want to get notifications for important messages, you can customize your settings from there too."