feat: enable more granular a11y feature management (#48625)
* feat: enable more granular a11y feature management Co-authored-by: Shelley Vohr <shelley.vohr@gmail.com> * Update docs/api/app.md Co-authored-by: John Kleinschmidt <jkleinsc@electronjs.org> Co-authored-by: Shelley Vohr <shelley.vohr@gmail.com> --------- Co-authored-by: trop[bot] <37223003+trop[bot]@users.noreply.github.com> Co-authored-by: Shelley Vohr <shelley.vohr@gmail.com>
This commit is contained in:
parent
4fda94be9b
commit
1056280b0a
4 changed files with 213 additions and 2 deletions
|
|
@ -1019,7 +1019,7 @@ describe('app module', () => {
|
|||
});
|
||||
});
|
||||
|
||||
ifdescribe(process.platform !== 'linux')('accessibilitySupportEnabled property', () => {
|
||||
ifdescribe(process.platform !== 'linux')('accessibility support functionality', () => {
|
||||
it('is mutable', () => {
|
||||
const values = [false, true, false];
|
||||
const setters: Array<(arg: boolean) => void> = [
|
||||
|
|
@ -1037,6 +1037,61 @@ describe('app module', () => {
|
|||
}
|
||||
}
|
||||
});
|
||||
|
||||
it('getAccessibilitySupportFeatures returns an array with accessibility properties', () => {
|
||||
const values = [
|
||||
'nativeAPIs',
|
||||
'webContents',
|
||||
'inlineTextBoxes',
|
||||
'extendedProperties',
|
||||
'screenReader',
|
||||
'html',
|
||||
'labelImages',
|
||||
'pdfPrinting'
|
||||
];
|
||||
|
||||
app.setAccessibilitySupportEnabled(false);
|
||||
|
||||
const disabled = app.getAccessibilitySupportFeatures();
|
||||
expect(disabled).to.be.an('array');
|
||||
expect(disabled.includes('complete')).to.equal(false);
|
||||
|
||||
app.setAccessibilitySupportEnabled(true);
|
||||
const enabled = app.getAccessibilitySupportFeatures();
|
||||
expect(enabled).to.be.an('array').with.length.greaterThan(0);
|
||||
|
||||
const boolEnabled = app.isAccessibilitySupportEnabled();
|
||||
if (boolEnabled) {
|
||||
expect(enabled.some(f => values.includes(f))).to.equal(true);
|
||||
}
|
||||
});
|
||||
|
||||
it('setAccessibilitySupportFeatures can enable a subset of features', () => {
|
||||
app.setAccessibilitySupportEnabled(false);
|
||||
expect(app.isAccessibilitySupportEnabled()).to.equal(false);
|
||||
expect(app.getAccessibilitySupportFeatures()).to.be.an('array').that.is.empty();
|
||||
|
||||
const subsetA = ['webContents', 'html'];
|
||||
app.setAccessibilitySupportFeatures(subsetA);
|
||||
const afterSubsetA = app.getAccessibilitySupportFeatures();
|
||||
expect(afterSubsetA).to.deep.equal(subsetA);
|
||||
|
||||
const subsetB = [
|
||||
'nativeAPIs',
|
||||
'webContents',
|
||||
'inlineTextBoxes',
|
||||
'extendedProperties'
|
||||
];
|
||||
app.setAccessibilitySupportFeatures(subsetB);
|
||||
const afterSubsetB = app.getAccessibilitySupportFeatures();
|
||||
expect(afterSubsetB).to.deep.equal(subsetB);
|
||||
});
|
||||
|
||||
it('throws when an unknown accessibility feature is requested', () => {
|
||||
expect(() => {
|
||||
app.setAccessibilitySupportFeatures(['unknownFeature']);
|
||||
}).to.throw('Unknown accessibility feature: unknownFeature');
|
||||
});
|
||||
});
|
||||
|
||||
ifdescribe(process.platform === 'win32')('setJumpList(categories)', () => {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue