feat: Expose renderer spellcheck API (#25060)
This commit is contained in:
parent
321395d96e
commit
05b5c197ae
5 changed files with 88 additions and 2 deletions
|
@ -13,7 +13,10 @@ ifdescribe(features.isBuiltinSpellCheckerEnabled())('spellchecker', () => {
|
|||
|
||||
beforeEach(async () => {
|
||||
w = new BrowserWindow({
|
||||
show: false
|
||||
show: false,
|
||||
webPreferences: {
|
||||
nodeIntegration: true
|
||||
}
|
||||
});
|
||||
await w.loadFile(path.resolve(__dirname, './fixtures/chromium/spellchecker.html'));
|
||||
});
|
||||
|
@ -62,6 +65,20 @@ ifdescribe(features.isBuiltinSpellCheckerEnabled())('spellchecker', () => {
|
|||
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()');
|
||||
// Wait for spellchecker to load
|
||||
await delay(500);
|
||||
|
||||
const callWebFrameFn = (expr: string) => w.webContents.executeJavaScript('require("electron").webFrame.' + expr);
|
||||
|
||||
expect(await callWebFrameFn('isWordMisspelled("test")')).to.equal(false);
|
||||
expect(await callWebFrameFn('isWordMisspelled("testt")')).to.equal(true);
|
||||
expect(await callWebFrameFn('getWordSuggestions("test")')).to.be.empty();
|
||||
expect(await callWebFrameFn('getWordSuggestions("testt")')).to.not.be.empty();
|
||||
});
|
||||
|
||||
describe('custom dictionary word list API', () => {
|
||||
let ses: Session;
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue