Skip to content

Commit

Permalink
docs: developing with Firefox for Android
Browse files Browse the repository at this point in the history
  • Loading branch information
lidel committed Feb 1, 2018
1 parent 2c43e75 commit e5a42c9
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 4 deletions.
34 changes: 34 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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=<device ID>
```

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 <debug 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:
Expand Down
6 changes: 3 additions & 3 deletions add-on/src/lib/ipfs-companion.js
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
3 changes: 2 additions & 1 deletion test/functional/lib/ipfs-companion.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit e5a42c9

Please sign in to comment.