Skip to content

Commit

Permalink
fix: enable spell checking, which broke in upgrade to ch66
Browse files Browse the repository at this point in the history
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 electron#13608.

[1]: https://chromium.googlesource.com/chromium/src/+/03563dd1635a028d286beaf8b4f3d637cc4a8830
  • Loading branch information
nornagon committed Jul 10, 2018
1 parent 4ebe716 commit 0681e4c
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 0 deletions.
4 changes: 4 additions & 0 deletions atom/renderer/api/atom_api_spell_check_client.cc
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,10 @@ void SpellCheckClient::RequestCheckingOfText(
base::Owned(pending_request_param_.release())));
}

bool SpellCheckClient::IsSpellCheckingEnabled() const {
return true;
}

void SpellCheckClient::ShowSpellingUI(bool show) {}

bool SpellCheckClient::IsShowingSpellingUI() {
Expand Down
1 change: 1 addition & 0 deletions atom/renderer/api/atom_api_spell_check_client.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ class SpellCheckClient : public blink::WebSpellCheckPanelHostClient,
void RequestCheckingOfText(
const blink::WebString& textToCheck,
blink::WebTextCheckingCompletion* completionCallback) override;
bool IsSpellCheckingEnabled() const override;

// blink::WebSpellCheckPanelHostClient:
void ShowSpellingUI(bool show) override;
Expand Down
16 changes: 16 additions & 0 deletions spec/api-web-frame-spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -138,4 +138,20 @@ describe('webFrame module', function () {
webFrame.setLayoutZoomLevelLimits(0, 25)
})
})

it('calls a spellcheck provider', function (done) {
w = new BrowserWindow({show: false})
const misspelledWord = 'spleling'
w.webContents.on('did-finish-load', () => {
for (const char of misspelledWord) {
w.webContents.sendInputEvent({type: 'char', keyCode: char})
}
w.webContents.sendInputEvent({type: 'char', keyCode: ' '})
})
ipcMain.once('spec-spell-check', (e, text) => {
assert.equal(text, misspelledWord)
done()
})
w.loadURL(`file://${fixtures}/pages/webframe-spell-check.html`)
})
})
13 changes: 13 additions & 0 deletions spec/fixtures/pages/webframe-spell-check.html
Original file line number Diff line number Diff line change
@@ -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>

0 comments on commit 0681e4c

Please sign in to comment.