New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: Support Firefox for Android via --target=firefox-android and related CLI options #868
feat: Support Firefox for Android via --target=firefox-android and related CLI options #868
Conversation
8735b18
to
3849731
Compare
The travis build is currently failing because of https://travis-ci.org/rpl/web-ext/jobs/212115440#L1234-L1237 I've reported this issue to the upstream in openstf/adbkit#67 |
3849731
to
2515845
Compare
This is very cool! I only took a quick look so here are some initial thoughts. This is the first time we will be introducing a new To achieve multiple targets like this, you'd probably want to fold your code into the already existing abstraction around running and watching/reloading. That code is a bit hairy though. The command line option should probably signify "firefox" in some way since Chrome for Android may also support add-ons in the future. So maybe |
Hey! I am really sorry if this is not the right place to ask this question. |
@Shatur Thanks for trying this PR, I didn't tried it on a real device yet (I was trying to ensure that it will not be destructive first ;-)), did the issue show any visible error (e.g. adb logcat)? Thanks again for your help. |
Hey @kumar303, thanks for this first round of comments, I like the idea of preparing the CLI options to be able to turn "web-ext run" into a multi-target command. Also, my initial intention was to add the android support into the cmd/run.js module, but I had the immediate feeling that it needs a refactoring first and so I though to defer the refactoring a bit by starting with creating a new module (but preventing any duplication of shared feature between the two) and, so that we could take a look at the different workflows/needs of the two targets in this PR and then refactor the two modules accordingly (possibly before landing this feature). I'll take a look at both asap. (Another reason why I deferred the refactoring is that we have a couple of pending PRs from contributors that would be affected by a refactoring on the "./cmd/run.js" module, and so I opted to wait a bit, so that I can rebase my change on top of them and start the refactoring from there). |
Hey @rpl! |
90ddaba
to
77d7795
Compare
77d7795
to
74dc926
Compare
@Shatur my apologies for not being able to come back to this sooner (it turned out that it would have been better to refactor the I suspect that the issue could be something related to something that is installed only on the rooted devices and that can prevent it from working correctly (I did most of the testing while working on this on a rooted emulator and it didn't have any issue, and so I think that the reason is not that the devices are "rooted" but something that is installed only on the "rooted" devices used to test it). Another possible issue can be related to the specific Android versions (the emulator I used was an Android 4.3 AOSP), I'll try to put together a bit more variegated testing environment before landing it. also, thank you a lot for testing it on some non-rooted devices, that was definitely an important scenario, that I didn't have tested yet this branch on. |
56624e3
to
31550fe
Compare
31550fe
to
9c13336
Compare
42fb0ce
to
2254994
Compare
98863b6
to
59403a8
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This patch is working great for me. We should ship it asap! Sorry for the delay in re-reviewing this.
My main concern is that building to the artifacts dir might be disruptive for some people. I offered a solution.
My other comments are mostly about cleaning up the console.
src/cmd/run.js
Outdated
ignoreFiles, | ||
asNeeded: false, | ||
// TODO: choose a different artifactsDir for additional safety? | ||
overwriteDest: true, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When testing it, I see this in the console:
Destination exists, overwriting: /Users/kumar/dev/webextensions-examples/window-manipulator/web-ext-artifacts/window_manipulator-1.0.zip
Shouldn't this be using a temp dir? You could do it like:
{
artifactsDir: tmpDir.path(),
...
}
That's how the sign command does it.
|
||
/** | ||
* This module provide an ExtensionRunner subclass that manage an extension executed | ||
* in a Firefox for Desktop instance. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It should say Firefox for Android, right? I think maybe this comment is a duplicate anyway? I see the correct comment up above.
|
||
// Create profile prefs (with enabled remote RDP server), prepare the | ||
// artifacts and temporary directory on the selected device, and | ||
// push the profile preferences to the remote profile dir. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These detailed comments are helpful, thanks.
await adbUtils.clearArtifactsDir(selectedAdbDevice); | ||
} | ||
|
||
// Call all the registered clenaup callbacks. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
typo: cleanup
devices = await adbUtils.discoverDevices(); | ||
|
||
if (devices.length === 0) { | ||
throw new UsageError('No Android device found through ADB.'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would it be helpful to provide some hints? How about this:
No Android device found through ADB. Make sure the device is connected and USB debugging is enabled.
src/util/adb.js
Outdated
|
||
this.artifactsDirMap.delete(deviceId); | ||
|
||
await this.runShellCommand(deviceId, [ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It would be nice to precede this with a debug message saying that we are about to delete ${artifactsDir}
src/util/adb.js
Outdated
await adbClient.push(deviceId, localPath, devicePath) | ||
.then(function(transfer) { | ||
return new Promise((resolve) => { | ||
// TODO(rpl): optionally show progress in the console |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it's so fast over USB that we don't need a progress indicator
src/util/adb.js
Outdated
async setupForward(deviceId: string, remote: string, local: string) { | ||
const {adbClient} = this; | ||
|
||
// TODO(rpl): we should use adb.listForwards and reuse the existent one if any (especially |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
typo: ...and reuse the existing one if any...
tests/unit/test-util/test.adb.js
Outdated
package:org.some.other.software | ||
`; | ||
|
||
const fakeSocketFilePrefix = ( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you add a comment about this? Did you copy it from a real file?
tests/unit/test-util/test.adb.js
Outdated
new Buffer(` | ||
android.permission.READ_EXTERNAL_STORAGE: granted=true | ||
android.permission.WRITE_EXTERNAL_STORAGE: granted=true | ||
`) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this indent looks off
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
r+wc
Looking good! I just had a few test cleanup requests.
|
||
await runnerInstance.reloadExtensionBySourceDir( | ||
'/non-existent/source-dir' | ||
).then((results) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since you're using await
, this call to then()
could be removed.
await runnerInstance.run(); | ||
|
||
await runnerInstance.reloadAllExtensions() | ||
.then((results) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It looks like you can remove this call to then()
as well
tests/unit/test-util/test.adb.js
Outdated
`; | ||
|
||
// Enable chai-as-promised plugin. | ||
chai.use(chaiAsPromised); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this making a global change to the test suite? If so, I think it would be better in tests/unit/runner.js
-- would that work?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
…un-cmd-on-android
This PR contains an initial prototype of "web-ext run" support on Firefox for Android and it should fix #737 by providing mostly the same "addon developer experience" and features supported by "web-ext run" on Firefox Desktop (e.g. run Firefox for Android in a temporary Firefox profile, watch the sources and then rebuild and reinstall the addon on changes, show a desktop notification when the build or install is failing with errors).
The current implementation already passes the eslint and flow type checks, and it doesn't break any of the existent tests, and I'm going to create some additional tests for the android support module asap.
In the meantime, you can watch the following demo screencast and/or build web-ext from this branch if you want to use it immediately and provide some preliminary feedback, that will be very much appreciated :-)
https://youtu.be/C_R1C2s3AWQ
Testing a WebExtension on Android is never been so easy!
\o/ Enjoy!
TODO List
of the setup steps in parallel)
Followups List