fix: re-enable the spellchecker when new language list set (#26119)
* fix: re-enable the spellchecker when new language list set Chromium recently added prefs logic to disable the spellchecker if the list of languages is empty, but the logic to re-enable if the languages are provided again lives in another part of Chromium. This change makes it so our API re-enables the spellchecker correctly when required. * chore: fix lint
This commit is contained in:
parent
6181c03df0
commit
9d18f9d54f
3 changed files with 38 additions and 3 deletions
|
@ -15,9 +15,11 @@ ifdescribe(features.isBuiltinSpellCheckerEnabled())('spellchecker', () => {
|
|||
w = new BrowserWindow({
|
||||
show: false,
|
||||
webPreferences: {
|
||||
nodeIntegration: true
|
||||
nodeIntegration: true,
|
||||
partition: `unique-spell-${Date.now()}`
|
||||
}
|
||||
});
|
||||
w.webContents.session.setSpellCheckerLanguages(['en-US']);
|
||||
await w.loadFile(path.resolve(__dirname, './fixtures/chromium/spellchecker.html'));
|
||||
});
|
||||
|
||||
|
@ -65,6 +67,26 @@ ifdescribe(features.isBuiltinSpellCheckerEnabled())('spellchecker', () => {
|
|||
expect(contextMenuParams.dictionarySuggestions).to.have.length.of.at.least(1);
|
||||
});
|
||||
|
||||
ifit(shouldRun)('should detect incorrectly spelled words as incorrect after disabling all languages and re-enabling', async () => {
|
||||
w.webContents.session.setSpellCheckerLanguages([]);
|
||||
await delay(500);
|
||||
w.webContents.session.setSpellCheckerLanguages(['en-US']);
|
||||
await w.webContents.executeJavaScript('document.body.querySelector("textarea").value = "Beautifulllll asd asd"');
|
||||
await w.webContents.executeJavaScript('document.body.querySelector("textarea").focus()');
|
||||
const contextMenuPromise = emittedOnce(w.webContents, 'context-menu');
|
||||
// Wait for spellchecker to load
|
||||
await delay(500);
|
||||
w.webContents.sendInputEvent({
|
||||
type: 'mouseDown',
|
||||
button: 'right',
|
||||
x: 43,
|
||||
y: 42
|
||||
});
|
||||
const contextMenuParams: Electron.ContextMenuParams = (await contextMenuPromise)[1];
|
||||
expect(contextMenuParams.misspelledWord).to.eq('Beautifulllll');
|
||||
expect(contextMenuParams.dictionarySuggestions).to.have.length.of.at.least(1);
|
||||
});
|
||||
|
||||
ifit(shouldRun)('should expose webFrame spellchecker correctly', async () => {
|
||||
await w.webContents.executeJavaScript('document.body.querySelector("textarea").value = "Beautifulllll asd asd"');
|
||||
await w.webContents.executeJavaScript('document.body.querySelector("textarea").focus()');
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue