[PDFHistory] Fix "Warning: Unhandled rejection: [Exception... "The operation is insecure."" in Firefox 25

Apparently PR #3934 causes issues in __Firefox 25__ (the current release version), which I missed since I didn't test using that version. Note that Firefox version 26 (and above) already works as they should.

This patch should solve the issue. Unfortunately this means that the code becomes slightly more difficult to read, but I don't think that can be avoided.

Fixes #3959.