Skip to content
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

fix: Use .BrowserApp as default reference browser apk component #2069

Merged
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions src/firefox/package-identifiers.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,7 @@ export default [
'org.mozilla.firefox',
'org.mozilla.reference.browser',
];

export const defaultApkComponents = {
'org.mozilla.reference.browser': '.BrowserActivity',
};
7 changes: 6 additions & 1 deletion src/util/adb.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@ import {
WebExtError,
} from '../errors';
import {createLogger} from '../util/logger';
import packageIdentifiers from '../firefox/package-identifiers';
import packageIdentifiers, {
defaultApkComponents,
} from '../firefox/package-identifiers';

export const DEVICE_DIR_BASE = '/sdcard/';
export const ARTIFACTS_DIR_PREFIX = 'web-ext-artifacts-';
Expand Down Expand Up @@ -313,6 +315,9 @@ export default class ADBUtils {

if (!apkComponent) {
apkComponent = '.App';
if (defaultApkComponents[apk]) {
apkComponent = defaultApkComponents[apk];
}
} else if (!apkComponent.includes('.')) {
apkComponent = `.${apkComponent}`;
}
Expand Down
35 changes: 35 additions & 0 deletions tests/unit/test-util/test.adb.js
Original file line number Diff line number Diff line change
Expand Up @@ -935,6 +935,41 @@ describe('utils/adb', () => {
);
});

it('start reference browser without APK component', async () => {
const adb = getFakeADBKit({
adbClient: {
startActivity: sinon.spy(() => Promise.resolve()),
},
adbkitUtil: {
readAll: sinon.spy(() => Promise.resolve(Buffer.from('\n'))),
},
});
const adbUtils = new ADBUtils({adb});

const promise = adbUtils.startFirefoxAPK(
'device1',
'org.mozilla.reference.browser',
undefined, // firefoxApkComponent
'/fake/custom/profile/path',
);

await assert.isFulfilled(promise);

sinon.assert.calledOnce(adb.fakeADBClient.startActivity);
sinon.assert.calledWithMatch(
adb.fakeADBClient.startActivity, 'device1', {
action: 'android.activity.MAIN',
component: 'org.mozilla.reference.browser/' +
'org.mozilla.reference.browser.BrowserActivity',
extras: [{
key: 'args',
value: '-profile /fake/custom/profile/path',
}],
wait: true,
}
);
});

ankushduacodes marked this conversation as resolved.
Show resolved Hide resolved
it('starts without specifying an APK component', async () => {
const adb = getFakeADBKit({
adbClient: {
Expand Down