Test Web extension on Android

Unfortunately Extension Auto-Installer will only work for Firefox up to including version 56.

With the current APIs it won’t be possible to port it as a WebExtension. It needs to:

  • listen on a port
  • install an extension (from a Blob or something)

It would be nice if Mozilla would offer a replacement.

I need a sync storage to be able to solve a problem and support version above and below 53. chrome.storage is async and you cannot get information in a sync way.

I enable all the logs all the time, see the image:
https://i.imgur.com/o9RcKlF.png

Still I cannot get no output from the background script.

I can install my extension wthout signing it, you can find information in the link you gave me earlier:

https://developer.mozilla.org/en-US/Add-ons/WebExtensions/Developing_WebExtensions_for_Firefox_for_Android

My only problem is to not be able to get logs from background scripts.

Dammit :neutral_face:

I think the only thing you can do is to file a bug on bugzilla. And waiting for a solution in next Firefox versions (maybe), I recommend you to verify the Android compatibility of each function you use on mozzila website. Sometimes, with localStorage for example, you will need to adapt your code with an alternative solution. For example :


//Browser compatibility
var browser = browser || chrome;
var android = !browser.windows;

if(android){
    browser.storage.local.get(function(storage){
	//Your Android code here
        console.log(storage.test);
    });
}
else{
    //Your Desktop code here
    console.log(localStorage.getItem("test"));
}

Thanks but what you wrote will not be good because I need to access the result of the aync chrome.storage from an async event.

Baptistou Baptiste Thémine
October 23

Unfortunately Extension Auto-Installer will only work for Firefox up to including version 56.

NilkasG:
Dammit :neutral_face:

I need a sync storage to be able to solve a problem and support version above and below 53. chrome.storage is async and you cannot get information in a sync way.

log69:
I think the only thing you can do is to file a bug on bugzilla. And waiting for a solution in next Firefox versions (maybe), I recommend you to verify the Android compatibility of each function you use on mozzila website. Sometimes, with localStorage for example, you will need to adapt your code with an alternative solution. For example :

> 
> //Browser compatibility
> var browser = browser || chrome;
> var android = !browser.windows; if(android){ browser.storage.local.get(function(storage){ //Your Android code here console.log(storage.test); });
> }
> else{ //Your Desktop code here console.log(localStorage.getItem("test"));
> }

This is not a problem as browser.storage.sync is not supported on Firefox Android too. See compatibility table on https://developer.mozilla.org/fr/Add-ons/WebExtensions/API/storage.
In all case you will have to do an alternative code for Android :confused:

That I am aware of :slight_smile: But I can keep this code base just like in the case of desktop version 52 using only localStorage because sync is supported from 53 on. I tested and it works on 52. So my code fallbacks to local only if no sync available.

I’m curious if there will be any answer of how we can read the log for background scripts and I’m anxious to see what works on Android and what not from what I’d like to do. Still digging for answers…

Meanwhile I’ve taken a try with this addon but it didn’t help, no log messages from my script:

https://addons.mozilla.org/en-US/android/addon/console/

I think you could solve your problem with sync vs async storage functions and Android miscompatibility with a more object-oriented approach. I created a pull request on your GitHub and tested it on Firefox and Chrome which worked well but not yet on Firefox Android :wink:

I’ll take a look at it around weekend, thanks.

Good news ! I tested my code on Firefox Android Nightly and it is working ! :grinning: