Skip to content

Commit

Permalink
Promote the new --devtools command line argument and link to debuggin…
Browse files Browse the repository at this point in the history
…g online documentation
  • Loading branch information
ochameau committed Sep 8, 2022
1 parent 94989fa commit 6f58053
Show file tree
Hide file tree
Showing 4 changed files with 49 additions and 4 deletions.
1 change: 1 addition & 0 deletions src/extension-runners/firefox-desktop.js
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,7 @@ export class FirefoxDesktopExtensionRunner {
firefoxBinary,
binaryArgs,
extensions,
devtools,
});

this.runningInfo.firefox.on('close', () => {
Expand Down
12 changes: 9 additions & 3 deletions src/firefox/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ export type FirefoxRunOptions = {
binaryArgs?: Array<string>,
args?: Array<any>,
extensions: Array<Extension>,
devtools: boolean,
};

/*
Expand All @@ -103,6 +104,7 @@ export async function run(
firefoxBinary,
binaryArgs,
extensions,
devtools,
}: FirefoxRunOptions = {}
): Promise<FirefoxInfo> {

Expand Down Expand Up @@ -164,9 +166,13 @@ export async function run(
throw error;
});

log.info(
'Use --verbose or open Tools > Web Developer > Browser Console ' +
'to see logging');
if (!devtools) {
log.info('Use --verbose or --devtools to see logging');
}
if (devtools) {
log.info('More info about WebExtensions debugging:');
log.info('https://extensionworkshop.com/documentation/develop/debugging/');
}

firefox.stderr.on('data', (data) => {
log.debug(`Firefox stderr: ${data.toString().trim()}`);
Expand Down
1 change: 1 addition & 0 deletions tests/functional/fake-firefox-binary.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ const REQUEST_INSTALL_ADDON = {
to: 'fakeAddonsActor',
type: 'installTemporaryAddon',
addonPath: process.env.addonPath,
openDevTools: false, // Introduced in Firefox 106 (Bug 1787409 / Bug 1789245)
};
const REPLY_INSTALL_ADDON = {
from: 'fakeAddonsActor',
Expand Down
39 changes: 38 additions & 1 deletion tests/unit/test-firefox/test.firefox.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ import {fs} from 'mz';
import * as firefox from '../../../src/firefox/index.js';
import {onlyInstancesOf, UsageError, WebExtError} from '../../../src/errors.js';
import {withTempDir} from '../../../src/util/temp-dir.js';
import {
consoleStream, // instance is imported to inspect logged messages
} from '../../../src/util/logger.js';
import {
basicManifest,
fixturePath,
Expand Down Expand Up @@ -240,6 +243,41 @@ describe('firefox', () => {
});
});

it('logs link to debugging docs', async () => {
const runner = createFakeFxRunner();
consoleStream.flushCapturedLogs();
consoleStream.startCapturing();

const expectedMessage = 'More info about WebExtensions debugging:';
const expectedURLToDocs =
'https://extensionworkshop.com/documentation/develop/debugging/';
await runFirefox({fxRunner: runner, devtools: false});
assert.notOk(consoleStream.capturedMessages.find(
(msg) => msg.includes(expectedMessage)
));
assert.notOk(consoleStream.capturedMessages.find(
(msg) => msg.includes(expectedURLToDocs)
));

consoleStream.flushCapturedLogs();

await runFirefox({fxRunner: runner, devtools: true});
const foundMessage = consoleStream.capturedMessages.find(
(msg) => msg.includes(expectedMessage)
);
const foundDocURL = consoleStream.capturedMessages.find(
(msg) => msg.includes(expectedURLToDocs)
);

// Expect the logs to be found.
assert.ok(foundMessage);
assert.ok(foundDocURL);

// Expected to be emitted as info level logs.
assert.ok(foundMessage?.includes('[info]'));
assert.ok(foundDocURL?.includes('[info]'));
});

});

describe('copyProfile', () => {
Expand Down Expand Up @@ -1003,7 +1041,6 @@ describe('firefox', () => {
sinon.assert.calledOnce(fakeAsyncFsStat);
}
));

});

});

0 comments on commit 6f58053

Please sign in to comment.