Skip to content

Commit

Permalink
fix: issue 88 testing edit and typos
Browse files Browse the repository at this point in the history
  • Loading branch information
saintsebastian committed Dec 19, 2016
1 parent 9ad8304 commit 2e2dec0
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 12 deletions.
15 changes: 8 additions & 7 deletions src/firefox/preferences.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@ import {WebExtError, UsageError} from '../errors';
import {createLogger} from '../util/logger';

const log = createLogger(__filename);
export const nonOverridablePreferences = [
'devtools.debugger.remote-enabled', 'devtools.debugger.prompt-connection',
'xpinstall.signatures.required',
];

// Flow Types

Expand Down Expand Up @@ -142,14 +146,11 @@ export function coerceCLICustomPreference(
value = (value === 'true');
}

let defaultProps = ['devtools.debugger.remote-enabled',
'devtools.debugger.prompt-connection', 'xpinstall.signatures.required'];
if (defaultProps.includes(key)) {
log.info(`Setting '${key}' is important for the work of WebExtensions` +
' and can not be customized');
} else {
customPrefs[`${key}`] = value;
if (nonOverridablePreferences.includes(key)) {
log.warn(`'${key}' preference cannot be customized.`);
continue;
}
customPrefs[`${key}`] = value;
}

return customPrefs;
Expand Down
3 changes: 2 additions & 1 deletion src/program.js
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,8 @@ export class Program {

const argv = this.yargs.argv;
const cmd = argv._[0];
//Command line option (pref) renamed for internal use (customPref)

// Command line option (pref) renamed for internal use (customPref).
argv.customPrefs = argv.pref;

let runCommand = this.commands[cmd];
Expand Down
11 changes: 8 additions & 3 deletions tests/unit/test-firefox/test.preferences.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import {assert} from 'chai';

import {WebExtError, UsageError} from '../../../src/errors';
import {
getPrefs, coerceCLICustomPreference,
getPrefs, coerceCLICustomPreference, nonOverridablePreferences,
} from '../../../src/firefox/preferences';


Expand Down Expand Up @@ -69,8 +69,13 @@ describe('firefox/preferences', () => {
});

it('does not allow certain default preferences to be customized', () => {
const prefs = coerceCLICustomPreference('xpinstall.signatures.required');
assert.equal(typeof(prefs['xpinstall.signatures.required']), 'undefined');
const nonChangeablePrefs = nonOverridablePreferences.map((prop) => {
return prop += '=true';
});
const prefs = coerceCLICustomPreference(nonChangeablePrefs);
for (var pref of nonChangeablePrefs) {
assert.equal(typeof(prefs[pref]), 'undefined');
}
});

it('throws an error for invalid preferences', () => {
Expand Down
2 changes: 1 addition & 1 deletion tests/unit/test.program.js
Original file line number Diff line number Diff line change
Expand Up @@ -327,7 +327,7 @@ describe('program.main', () => {
});
});

it('converts custom prefernces into object', () => {
it('converts custom preferences into an object', () => {
const fakeCommands = fake(commands, {
run: () => Promise.resolve(),
});
Expand Down

0 comments on commit 2e2dec0

Please sign in to comment.