I've found some pointers to this.
First, check what program the system uses for a PDF file.
Then, there is the horrible mimetypes.rdf file which stores Firefox preferences for opening applications. It is somewhere in your /home/you/.mozilla profile directory.
Then, when something is 'unknown' it will be opened by some kind of guessing algorithm.
To change this, I heard you can do this:
sed 's#.*octet-stream.*#application/octet-stream=xdg-open#' ~/.local/share/applications/mimeapps.list -i
Just tested this myself and found xdg-open will correctly guess the file type.
You can also edit the mimeapps.list by hand. Just set it to 'xdg-open' (no need to append .desktop unless you want it to open via a .desktop link). The application/octet-stream is often used by sites that do not correctly set their mimetype when sending you a file.