mozilla/pdf.js — pull request #3437 by Rob--W (2013-07-02 15:38:11+00:00)
Title: Download PDF from cache for non-Firefox add-on

This feature relies on URL.createObjectURL, which is supported by
- Firefox 4
- Chrome 8
- Opera 15
- Internet Explorer 10

If the feature is missing, it falls back to downloading the file directly from the server.

The environment-specific code are put in ifdef's. Two methods are defined:
- `noData`
This function is used as a fallback in case of failure, it triggers a download directly from the server.
- `triggerSaveAs(String url, optional String blob)`
This function attempts to show a Save As dialog for a given URL.
It attempts to use the [a.download](http://caniuse.com/download) attribute, if available, and falls back to `window.open(, '_parent')` if unavailable.

---

Side note: If I'm not mistaken, we're generating the blob-URL by first passing the data over the Web Worker, followed by createObjectURL. This can be implemented more efficiently by directly calling `URL.createObjectURL` inside the Web Worker. This feature is supported by most major browsers:

- Firefox 21 - https://developer.mozilla.org/en-US/docs/Mozilla/Firefox/Releases/21#Worker
- Chrome / Safari - https://bugs.webkit.org/show_bug.cgi?id=74386 (closed in October 2012)
- Opera 15

(`URL.createObjectURL` is supported in Internet Explorer 10, but not inside Web Workers (`` isn't supported either...))