this won't work in a lot of cases but i think we'll need support from gecko. I'll work on this in Bug 877718.