Refactor how the database is read in ViewHistory

This PR re-factors `ViewHistory` so that reading stored values returns a Promise. It should thus handle any possible errors when either `sessionStorage` or `localStorage` fails (e.g. [bug 1000777](https://bugzilla.mozilla.org/show_bug.cgi?id=1000777) and #4690).

My goal with this PR was to address https://github.com/mozilla/pdf.js/pull/4679#issuecomment-41400533, so the `ViewHistory` will now fail to initialize when the database cannot be read.
As part of the re-factoring, I've also taken the opportunity to simplify the, in my opinion, quite clunky initialization code.
I didn't want to touch too much code, so I refrained from rewriting the entire `ViewHistory` to be Promise friendly and just settled for the necessary part.

Also fixes #4690 (by courtesy of the first commit).