From bdceea6acaf87c61e4284ceca0ac8f8292d1f27a Mon Sep 17 00:00:00 2001 From: Jeremy Apthorp Date: Tue, 10 Jul 2018 12:43:39 -0700 Subject: [PATCH] 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]: https://chromium.googlesource.com/chromium/src/+/03563dd1635a028d286beaf8b4f3d637cc4a8830 --- .../api/atom_api_spell_check_client.cc | 4 ++++ .../api/atom_api_spell_check_client.h | 1 + spec/api-web-frame-spec.js | 20 +++++++++++++++++++ spec/fixtures/pages/webframe-spell-check.html | 13 ++++++++++++ 4 files changed, 38 insertions(+) create mode 100644 spec/fixtures/pages/webframe-spell-check.html diff --git a/atom/renderer/api/atom_api_spell_check_client.cc b/atom/renderer/api/atom_api_spell_check_client.cc index ddadc671ba76..5f7985be2f82 100644 --- a/atom/renderer/api/atom_api_spell_check_client.cc +++ b/atom/renderer/api/atom_api_spell_check_client.cc @@ -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() { diff --git a/atom/renderer/api/atom_api_spell_check_client.h b/atom/renderer/api/atom_api_spell_check_client.h index 92f631d6bb64..c8b5f7f4ab16 100644 --- a/atom/renderer/api/atom_api_spell_check_client.h +++ b/atom/renderer/api/atom_api_spell_check_client.h @@ -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; diff --git a/spec/api-web-frame-spec.js b/spec/api-web-frame-spec.js index 5a03ca22685e..b8fd10b5d3f1 100644 --- a/spec/api-web-frame-spec.js +++ b/spec/api-web-frame-spec.js @@ -1,8 +1,14 @@ const assert = require('assert') +const chai = require('chai') +const dirtyChai = require('dirty-chai') const path = require('path') const {closeWindow} = require('./window-helpers') const {remote, webFrame} = require('electron') 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 */ /* eslint-disable standard/no-callback-literal */ @@ -138,4 +144,18 @@ describe('webFrame module', function () { 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) + }) }) diff --git a/spec/fixtures/pages/webframe-spell-check.html b/spec/fixtures/pages/webframe-spell-check.html new file mode 100644 index 000000000000..db83964e55fd --- /dev/null +++ b/spec/fixtures/pages/webframe-spell-check.html @@ -0,0 +1,13 @@ + + + + + +