fix: enable spell checking, which broke in upgrade to ch66
Chromium commit [03563dd163][1] changed the way that the
spellcheck-enabled status was checked, defaulting to false.
Added the first (!) test for spellchecking, too.
Fixes #13608.
[1]: 03563dd163
This commit is contained in:
parent
6fbec9d5a9
commit
bdceea6aca
4 changed files with 38 additions and 0 deletions
|
@ -115,6 +115,10 @@ void SpellCheckClient::RequestCheckingOfText(
|
||||||
base::Owned(pending_request_param_.release())));
|
base::Owned(pending_request_param_.release())));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool SpellCheckClient::IsSpellCheckingEnabled() const {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
void SpellCheckClient::ShowSpellingUI(bool show) {}
|
void SpellCheckClient::ShowSpellingUI(bool show) {}
|
||||||
|
|
||||||
bool SpellCheckClient::IsShowingSpellingUI() {
|
bool SpellCheckClient::IsShowingSpellingUI() {
|
||||||
|
|
|
@ -46,6 +46,7 @@ class SpellCheckClient : public blink::WebSpellCheckPanelHostClient,
|
||||||
void RequestCheckingOfText(
|
void RequestCheckingOfText(
|
||||||
const blink::WebString& textToCheck,
|
const blink::WebString& textToCheck,
|
||||||
blink::WebTextCheckingCompletion* completionCallback) override;
|
blink::WebTextCheckingCompletion* completionCallback) override;
|
||||||
|
bool IsSpellCheckingEnabled() const override;
|
||||||
|
|
||||||
// blink::WebSpellCheckPanelHostClient:
|
// blink::WebSpellCheckPanelHostClient:
|
||||||
void ShowSpellingUI(bool show) override;
|
void ShowSpellingUI(bool show) override;
|
||||||
|
|
|
@ -1,8 +1,14 @@
|
||||||
const assert = require('assert')
|
const assert = require('assert')
|
||||||
|
const chai = require('chai')
|
||||||
|
const dirtyChai = require('dirty-chai')
|
||||||
const path = require('path')
|
const path = require('path')
|
||||||
const {closeWindow} = require('./window-helpers')
|
const {closeWindow} = require('./window-helpers')
|
||||||
const {remote, webFrame} = require('electron')
|
const {remote, webFrame} = require('electron')
|
||||||
const {BrowserWindow, protocol, ipcMain} = remote
|
const {BrowserWindow, protocol, ipcMain} = remote
|
||||||
|
const {emittedOnce} = require('./events-helpers')
|
||||||
|
|
||||||
|
const {expect} = chai
|
||||||
|
chai.use(dirtyChai)
|
||||||
|
|
||||||
/* Most of the APIs here don't use standard callbacks */
|
/* Most of the APIs here don't use standard callbacks */
|
||||||
/* eslint-disable standard/no-callback-literal */
|
/* eslint-disable standard/no-callback-literal */
|
||||||
|
@ -138,4 +144,18 @@ describe('webFrame module', function () {
|
||||||
webFrame.setLayoutZoomLevelLimits(0, 25)
|
webFrame.setLayoutZoomLevelLimits(0, 25)
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
|
it('calls a spellcheck provider', async () => {
|
||||||
|
w = new BrowserWindow({show: false})
|
||||||
|
w.loadURL(`file://${fixtures}/pages/webframe-spell-check.html`)
|
||||||
|
await emittedOnce(w.webContents, 'did-finish-load')
|
||||||
|
|
||||||
|
const spellCheckerFeedback = emittedOnce(ipcMain, 'spec-spell-check')
|
||||||
|
const misspelledWord = 'spleling'
|
||||||
|
for (const keyCode of [...misspelledWord, ' ']) {
|
||||||
|
w.webContents.sendInputEvent({type: 'char', keyCode})
|
||||||
|
}
|
||||||
|
const [, text] = await spellCheckerFeedback
|
||||||
|
expect(text).to.equal(misspelledWord)
|
||||||
|
})
|
||||||
})
|
})
|
||||||
|
|
13
spec/fixtures/pages/webframe-spell-check.html
vendored
Normal file
13
spec/fixtures/pages/webframe-spell-check.html
vendored
Normal file
|
@ -0,0 +1,13 @@
|
||||||
|
<html>
|
||||||
|
<body>
|
||||||
|
<script type="text/javascript" charset="utf-8">
|
||||||
|
const {ipcRenderer, webFrame} = require('electron')
|
||||||
|
webFrame.setSpellCheckProvider('en-US', true, {
|
||||||
|
spellCheck: text => {
|
||||||
|
ipcRenderer.send('spec-spell-check', text)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
</script>
|
||||||
|
<input autofocus />
|
||||||
|
</body>
|
||||||
|
</html>
|
Loading…
Reference in a new issue