From e5a42c9850e54455b8ee4e581c747b5130baf54f Mon Sep 17 00:00:00 2001 From: Marcin Rataj Date: Mon, 29 Jan 2018 13:47:56 +0100 Subject: [PATCH] docs: developing with Firefox for Android --- CONTRIBUTING.md | 34 ++++++++++++++++++++++ add-on/src/lib/ipfs-companion.js | 6 ++-- test/functional/lib/ipfs-companion.test.js | 3 +- 3 files changed, 39 insertions(+), 4 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index e7ff2311f..f73edd215 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -26,6 +26,8 @@ Submit PR with a new locale or improve existing ones via [Crowdin](https://crowd You will need [NodeJS](https://nodejs.org/) and [Firefox](https://www.mozilla.org/en-US/firefox/developer/). Make sure `npm` and `firefox` are in your `PATH`. +It may be a good idea to use `yarn` instead of `npm`. We provide `yarn.lock` if you choose to do so. + ### Installing Dependencies To install all dependencies into to `node_modules` directory, execute: @@ -52,6 +54,38 @@ npm run build Then open up `chrome://extensions` in Chromium-based browser, enable "Developer mode", click "Load unpacked extension..." and point it at `add-on/manifest.json` +### Firefox for Android + +To run your extension in [Firefox for Android](https://www.mozilla.org/en-US/firefox/mobile/), follow these instructions: + +- [Set up your computer and Android emulator or device](https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/Developing_WebExtensions_for_Firefox_for_Android#Set_up_your_computer_and_Android_emulator_or_device) (enable Developer Mode, USB Debugging etc) + +With device connected to your development computer, run: + +``` +web-ext run -s add-on --target=firefox-android +``` + +It will list all connected devices with their IDs. If the list is empty, go back to the setup step. + +Next, deploy extension to the specific device: + +``` +web-ext run --target=firefox-android --android-device= +``` + +The first time you run this command there may be a popup on your Android device asking if you want to grant access over USB. + +#### Debugging in Firefox for Android + +Remote debug port will be printed to console right after successful deployment: + +``` +You can connect to this Android device on TCP port +``` + +The fastest way to connect is to open `chrome://devtools/content/framework/connect/connect.xhtml` in Firefox the same machine you run web-ext from. + ## Useful Tasks Each `npm` task can be run separately. The most useful ones are: diff --git a/add-on/src/lib/ipfs-companion.js b/add-on/src/lib/ipfs-companion.js index a63bfe82f..438a1b437 100644 --- a/add-on/src/lib/ipfs-companion.js +++ b/add-on/src/lib/ipfs-companion.js @@ -400,10 +400,10 @@ module.exports = async function init () { // ------------------------------------------------------------------- async function updateBrowserActionBadge () { - if (typeof browser.browserAction.setBadgeBackgroundColor === 'undefined') { + if (typeof browser.browserAction.setBadgeBackgroundColor === 'undefined') { // Firefox for Android does not have this UI, so we just skip it - return; - } + return + } let badgeText, badgeColor, badgeIcon badgeText = state.peerCount.toString() diff --git a/test/functional/lib/ipfs-companion.test.js b/test/functional/lib/ipfs-companion.test.js index 5a4449e74..228e606f7 100644 --- a/test/functional/lib/ipfs-companion.test.js +++ b/test/functional/lib/ipfs-companion.test.js @@ -7,7 +7,8 @@ const { optionDefaults } = require('../../../add-on/src/lib/options') describe('init', () => { let init - before(() => { + before(function () { + this.timeout = 1000 * 10 global.window = {} global.browser = browser global.URL = URL