Skip to content

Commit

Permalink
fix(firefox-android): Support abstract sockets for RDB (#1391)
Browse files Browse the repository at this point in the history
New versions of firefox-android (>= 63) appear to use abstract unix sockets instead of filesystem sockets for the debugging connection. 

This change ensures support for both the original filesystem namespace and also the abstract namespace.
  • Loading branch information
Andrew Miller authored and rpl committed Nov 8, 2018
1 parent 7f90caa commit 46f0cfe
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 2 deletions.
6 changes: 5 additions & 1 deletion src/extension-runners/firefox-android.js
Original file line number Diff line number Diff line change
Expand Up @@ -578,9 +578,13 @@ export class FirefoxAndroidExtensionRunner {
// to connect the Firefox DevTools to the Firefox for Android instance).
log.info(`You can connect to this Android device on TCP port ${tcpPort}`);

const forwardSocketSpec = this.selectedRDPSocketFile.startsWith('@') ?
`localabstract:${this.selectedRDPSocketFile.substr(1)}`
: `localfilesystem:${this.selectedRDPSocketFile}`;

await adbUtils.setupForward(
selectedAdbDevice,
`localfilesystem:${this.selectedRDPSocketFile}`,
forwardSocketSpec,
`tcp:${tcpPort}`
);

Expand Down
38 changes: 37 additions & 1 deletion tests/unit/test-extension-runners/test.firefox-android.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,10 @@ const fakeRDPUnixSocketFile = (
'/data/data/org.mozilla.firefox/firefox-debugger-socket'
);

const fakeRDPUnixAbstractSocketFile = (
'@org.mozilla.firefox/firefox-debugger-socket'
);

type PrepareParams = {
params?: Object,
debuggerPort?: number,
Expand Down Expand Up @@ -101,7 +105,8 @@ function prepareExtensionRunnerParams({
};
}

function prepareSelectedDeviceAndAPKParams(overriddenProperties = {}) {
function prepareSelectedDeviceAndAPKParams(
overriddenProperties = {}, adbOverrides = {}) {
const fakeADBUtils = {
discoverDevices: sinon.spy(() => Promise.resolve([
'emulator-1', 'emulator-2',
Expand All @@ -124,6 +129,7 @@ function prepareSelectedDeviceAndAPKParams(overriddenProperties = {}) {
clearArtifactsDir: sinon.spy(() => Promise.resolve()),
setUserAbortDiscovery: sinon.spy(() => {}),
ensureRequiredAPKRuntimePermissions: sinon.spy(() => Promise.resolve()),
...adbOverrides,
};

const {params} = prepareExtensionRunnerParams({
Expand Down Expand Up @@ -397,6 +403,36 @@ describe('util/extension-runners/firefox-android', () => {
);
});

it('discovers the RDP abstract unix socket and forward it on',
async () => {
const {
params, fakeADBUtils,
} = prepareSelectedDeviceAndAPKParams({}, {
discoverRDPUnixSocket: sinon.spy(
() => Promise.resolve(fakeRDPUnixAbstractSocketFile)
)});

const runnerInstance = new FirefoxAndroidExtensionRunner(params);
await runnerInstance.run();

sinon.assert.calledWithMatch(
fakeADBUtils.discoverRDPUnixSocket,
'emulator-1', 'org.mozilla.firefox'
);

sinon.assert.calledWithMatch(
fakeADBUtils.setupForward,
'emulator-1',
'localabstract:org.mozilla.firefox/firefox-debugger-socket',
`tcp:${runnerInstance.selectedTCPPort}`,
);

sinon.assert.callOrder(
fakeADBUtils.discoverRDPUnixSocket,
fakeADBUtils.setupForward
);
});

it('installs the build extension as a temporarily installed addon',
async () => {
const {
Expand Down

0 comments on commit 46f0cfe

Please sign in to comment.