Debug WebExtensions in android

I’d really like to be able to properly debug my WebExtensions in Firefox for Android.

Connecting the WebIDE to my Android phone via adb was amazingly easy, but I could only attach it’s debugger to web pages. I found no option to sideload extensions or even debug their background scripts.

Is there a was to do that?
If can I at least get console messages from the background scripts somehow?
Is there any way to load WebExtensions into the release or beta build of fennec without signing them? (Aurora is somewhat unstable, and signing each new blind attempt is quite annoying)
All ideas and hacks are welcome!

1 Like

I have experimented a bit, and this works quite well:

  1. Connect the WebIDE to your phone from the PC

    • I already had adb set up such that adb devices listed my phone
    • then I followed this guide
  2. Set up Extension Auto-Installer on the phone

    • install the add-on from AMO
    • in the WebIDE, click Device Preferences on the right and append the local IP of your PC to extensions.autoinstaller.allowedIPs
  3. Select the Main Process as the debug target in the WebIDE

    • to run console scripts in the background page, select it like a frame at the top right of the debugger panel
  4. Push the extension package from the PC

    • pack your extension as a zip as you usually do
    • push it to your phones local IP
      • the add-on page suggests to use wget or curl
      • I do it from within my build script in node.js, on success the HTTP status is (sometimes?) 399
  5. Accept the extension on the phone

    • if everything works so far, dismiss the message that says Blocked Add-on
    • tap the new notification to install as a temporary unsigned add-on
  6. Have fun debugging. Repeat steps 4 and 5 as needed.

I did this with Firefox 52 beta x64 on my Windows 10 computer and a OnePlus X running CM 13 (Android 6.0.1), Firefox 52 beta and Extension Auto-Installer 1.3.

3 Likes

These details are extremely helpful! Thanks so much for it! May you please share the node script, or part of it, that does this. I have always uploaded my extension to a cloud storage then downloaded it on my android, I hate this tedious process.

This is the post section of my build tool. options is read from the command line as a JSON5 object.
The tools API is neither stable nor documented, but I an sure you can read it. You can use it as per MPL-2.0.

You will also need to add the es6lib and xhr2 dependencies as I do in the project’s package.json.

And the return code really is 399.

1 Like

Love it when people answer their own questions on the Internet. Thank you!