JSONovich / jsonovich

A webextension for Firefox. Pretty-prints JSON content in the browser for easy, unobtrusive viewing.
https://addons.mozilla.org/firefox/addon/jsonovich/
Mozilla Public License 2.0
7 stars 3 forks source link

File URIs no longer work #45

Closed buttercookie42 closed 7 years ago

buttercookie42 commented 7 years ago

Testing with Firefox on Android, file URIs (e.g. /data/data/\<package name>/files/mozilla/\<profile name>/sessionstore.js [1]) no longer work. On Firefox 55, the page load seems to hang outright in that case, while in Nightly (and interestingly also in 52ESR on Desktop) it succeeds, but just displays the raw, unformatted file.

I assume this is due to some limitation of webextensions as currently implemented on Firefox, although it'd be interesting to know whether this is bug 1266960, 1341341 or some other, yet to be filed issue.

[1] Where package name is org.mozilla.firefox for Release, _org.mozilla.firefoxbeta for Beta and org.mozilla.fennec or _org.mozilla.fennecaurora (for Play Store installs) for Nightly.

welwood08 commented 7 years ago

Thanks for testing, but I can't reproduce this. Loading .json files from the profile with 1.99.4 from AMO in 55.0.2 works fine on my only available Android test device (there is a short delay while it's generating the page, but not enough to call it a hang).

Note that sessionstore.js is not a .json file, so normally you would have to add the extension in the addon options - unfortunately the options page seems to be broken in Android so you can't. I don't know if the options page ever worked, Android support was originally added without any testing by simply allowing installation. In any case, manually adding it via about:config and restarting the browser I was also able to load sessionstore.js as formatted JSON: sessionstore

Perhaps you have another conflicting addon installed?

buttercookie42 commented 7 years ago

Thanks for looking into this and yes, you're right, in principle it's actually still working. However there is one clear difference - if I install 1.99.1, then local .js files are formatted out of the box (tested with a fresh install on a clean profile), whereas with 1.99.4 indeed only .json files are working with the default configuration.

As for things not working at all, there might be something weird going on, because while I tried systematically de- and reactivating other addons on my regular Android profile on 55, at some point the add-on did seem to work only after a fresh install and stopped working completely (i.e. not even for *.json files) after a restart of Firefox. However currently I can no longer reproduce this, so I'm not sure exactly was going on there - if it ever happens again, I'll try and see if I can find out something.

welwood08 commented 7 years ago

If file://**.js was being formatted as JSON in the default configuration pre-1.99.4 then that sounds like a bug in the old implementation. Perhaps at some level Firefox does some sort of HTTP header emulation that treats it as text/javascript and the old implementation's mimetype hook is in a position to act on that instead of the extension hook. Not worried about it anyway since it's now behaving as intended - I'll revisit formatting .js by default when we have a formatter that can actually do it justice.

Regarding the latter behaviour, I realise now it sounds like this bug I encountered during the 1.99.4 dev cycle. If the webext manifest from 1.99.1 was cached then 1.99.4 would not load the new background scripts containing the webext implementation. I toyed with the idea of moving all the code back into the first background script, but I don't want to risk another long AMO review. Next release combined with 56 should resolve it (assuming uplift to beta), as should the move from embedded to native webext in time for 57.

I don't think there's much more I can do about this. If you have any alternate theories or explanations, please feel free to re-open.