hypothesis / browser-extension

The Hypothesis browser extensions.
BSD 2-Clause "Simplified" License
483 stars 127 forks source link

Firefox extension does not work with local PDF files #100

Open robertknight opened 7 years ago

robertknight commented 7 years ago

Steps to reproduce

  1. Download latest and install latest build of Firefox extension (eg. from the link at the bottom of the build output here). Note: You'll need to download the .xpi file first and then load it via File -> Open File
  2. Open a local PDF file in Firefox
  3. Activate Hypothesis

    Expected behaviour

Hypothesis should load the PDF in a new tab using its bundled version of PDF.js

Actual behaviour

Hypothesis fails to activate and displays an error icon on the badge. Additionally clicking the badge does not show the error details page.

Browser/system information

Firefox Nightly v52a1

Additional details

Same steps but with a PDF hosted on a HTTP URL works

klemay commented 6 years ago

Zendesk ticket: https://hypothesis.zendesk.com/agent/tickets/2420

I tried showing the hypothes.is pane by default, but then it is visually unappealing and more importantly makes it impossible to see the actual content on mobile.

Would it be possible to work on a way to integrate hypothes.is into a webpage via the included javascript that has stronger signifiers without totally wiping out the content?

diegodlh commented 4 years ago

This issue persists on Firefox 76.0 on Linux. The reason seems to be that Firefox is more restrictive than Chrome regarding whether extensions can open local files. See here. Apparently, they don't plan to implement isAllowedFileSchemeAccess to give "read-only access to any file in the operating environment" because of its "security concerns". See also here ("Firefox will always return false"), and here.

Additionally clicking the badge does not show the error details page.

It does show an error page now (help/index.html#no-file-access), but it is Chrome-specific. Alternatively, it could suggest to use the bookmarklet instead, or open the extension's PDF viewer without a file and advise the user to open or drag and drop the file themselves.

Same steps but with a PDF hosted on a HTTP URL works

I imagine this no longer works since around FF60, as reported here. A possible fix has been proposed here.