Closed Bug 1607960 Opened 5 years ago Closed 5 years ago

Allow to set environment variables for launched GeckoView vehicles on Android

Categories

(Testing :: geckodriver, enhancement, P3)

Version 3
enhancement

Tracking

(firefox74 fixed)

RESOLVED FIXED
mozilla74
Tracking Status
firefox74 --- fixed

People

(Reporter: nalexander, Assigned: nalexander)

References

Details

Attachments

(1 file)

There's no good way right now to set environment variables for Android GeckoView vehicles. geckodriver itself uses the GeckoView configuration file mechanism so it needs to help set the env: section in those files. I don't see any reason to make this Android only; it just hasn't arisen yet on Desktop because generally the device under test and the host are the same, and geckodriver inherits the launching environment.

jesup: this is what you were asking for in various channels yesterday.

Assignee: nobody → nalexander
Status: NEW → ASSIGNED

./mach run has the ability to set env vars (though I haven't tested that on android), and on desktop it's often easy to just set them in your cmdline shell or some app property. However, for automation (like geckodriver) it'd be nice not to have to do it that way. I'm not sure why I was NI'd, but we definitely would like to be able to set env vars for android runs without doing stuff like editing the yaml file by hand and pushing it to the phone.

Flags: needinfo?(rjesup)

(In reply to Randell Jesup [:jesup] (needinfo me) from comment #2)

./mach run has the ability to set env vars (though I haven't tested that on android)

./mach run --setenv foo.bar=1 works on Android: Bug 1557805.

, and on desktop it's often easy to just set them in your cmdline shell or some app property. However, for automation (like geckodriver) it'd be nice not to have to do it that way. I'm not sure why I was NI'd, but we definitely would like to be able to set env vars for android runs without doing stuff like editing the yaml file by hand and pushing it to the phone.

I'm not sure why you were NI'd either. I have a patch for this working locally, I'll push it up in a moment.

In general Desktop platforms can use the launching environment, which
is inherited by geckodriver; but that's not possible on Android, so we
introduce a new env map in Firefox options and ferry it through to
the GeckoView configuration file.

Pushed by nalexander@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/ad9a284706ee Allow to set environment variables in geckodriver. r=whimboo,webdriver-reviewers,ato

The corresponding change to browsertime is up for review at https://github.com/sitespeedio/browsertime/pull/1110.

Nick, please remember to also file a follow-up bug for desktop. Thanks.

Flags: needinfo?(nalexander)
Status: ASSIGNED → RESOLVED
Closed: 5 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla74

(In reply to Henrik Skupin (:whimboo) [⌚️UTC+1] from comment #7)

Nick, please remember to also file a follow-up bug for desktop. Thanks.

Looks like wires are still crossed after discussion in the reviews: I implemented this for Desktop and for Android, so no follow-up is needed.

With https://github.com/sitespeedio/browsertime/issues/1109 (not yet merged), I see MOZ_LOG logging printed to the console on Desktop when running

./mach browsertime -- -n 1 --firefox.geckodriverPath /Users/nalexander/Mozilla/gecko/target/debug/geckodriver https://example.com --firefox.binaryPath /Applications/Firefox\ Nightly.app/Contents/MacOS/firefox -vv --firefox.env='MOZ_LOG=nsHttp:5'

I see MOZ_LOG logging printed to adb logcat on Android when running

./mach browsertime -- --android -n 1 --firefox.binaryPath x --firefox.android.package org.mozilla.geckoview_example --firefox.android.activity .GeckoViewActivity --firefox.geckodriverPath /Users/nalexander/Mozilla/gecko/target/debug/geckodriver https://example.com -vv --firefox.env 'MOZ_LOG=nsHttp:5'
Flags: needinfo?(nalexander)

That is, as long as the harness sets env in the moz:firefoxOptions block, it should make it to the launched process on both Desktop and Android. Try it out!

You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: