[Browsing history] Remove 'beforeunload' to enable caching and prevent duplicate entries

This PR makes couple of small optimizations of the browsing history implementation in PDF.js:

* Remove the `beforeunload` event listener during unload, i.e. when navigation away from the document.
This partially addresses the current issue, where the PDF file is fetched again when navigating back in the history. With this patch I get the following behaviour when navigating back to the document:
 * Using the web viewer, the document is loaded instantaneously.

 * In the Firefox extension, I get two different behaviours:
     * If range requests are __disabled__, the document is loaded *almost* instantaneously. The loading bar is visible very briefly (maybe for a second), and then the document is immediately rendered. In this case, it seems that when the document is requested, it's fetched from the network cache as it should.

     * If range requests are __enabled__, the entire document is fetched again, forcing you to wait for it to load. To me this indicates that the issue might be that Firefox isn't caching range request as it should.
In this situation, this patch does not improve the current situation. Unfortunately I do not believe that is much more that I can do as far as the browsing history implementation goes.

* A small change that prevents the same destination from being added to the history twice, when navigating back to the document from another page in the browser history. (Note that this will only happen under certain circumstances.)

* Finally, I also added a few more comments in the code. 

/cc @brendandahl, sorry about the wall of text btw!