Firefox started getting a nasty habit of opening some files in gedit. Of course, there’s a bug report. In there, there’s a workaround:
I found a strange entry in ~/.local/share/applications/mimeapps.list
application/octet-stream=gedit.desktop;
This means open almost any kind of binary file in gedit. Perhaps you have something similar. Deleting that line has solved the problem for me, until next time.
I had that line too. Deleting that changed Firefox’s behaviour to something less prone to gedit’s madness.