SpellCheckCustomDictionary — addWords / removeWords
Note on the difference between add and remove refresh. addWords()
clears the squiggle for those words across the whole document right away.
removeWords() does not re-flag every editable from the call
itself: it invalidates the per-document spell-check cache and a fresh check then
runs on each editable when that editable is focused by a user gesture .
So to verify removal, click into each field — the squiggle should
return without typing. See
crrev.com/c/7837649 .
Gating the refresh on a user gesture is a privacy defense. See also
user-dictionary-leaks .
1. Add suppresses the squiggle, remove restores it (LTR and RTL)
1a. Latin (LTR) word. The misspelled nonsense word
wugzz below should have a red spelling squiggle to
start with.
This wugzz is misspelled.
addWords(["wugzz"])
removeWords(["wugzz"])
Precondition for 1b: enable the Hebrew spellcheck
dictionary (Settings › Languages). Chrome only squiggles Hebrew text
when a Hebrew (he) or Persian (fa) dictionary is
on; with only Latin dictionaries enabled the word below is never flagged
and there is nothing to observe.
1b. Hebrew (RTL) word. The misspelled Hebrew nonsense word
שלוס below should have a red spelling squiggle to
start with.
זה שלוס לא נכון.
addWords(["שלוס"])
removeWords(["שלוס"])
For each word (wugzz and
שלוס ), confirm it is underlined as misspelled.
Click that word's addWords button. Its squiggle should disappear
immediately, with no further interaction.
Click that word's removeWords button, then click back into the field.
The squiggle should come back as soon as you focus the field —
without you having to type .
2. The dictionary is per-document
Both regions below contain flooble .
A flooble in a contenteditable.
addWords(["flooble"])
removeWords(["flooble"])
Confirm flooble is squiggled in both regions.
Click addWords once. The squiggle should clear in both regions
immediately.
Click removeWords , then click into each region in turn. Each
region's squiggle should reappear as soon as you focus it — without
typing . Note the asymmetry with add: removal is not applied to every
editable from the one button click. Re-checking is driven per editable when it
gains focus (via a user gesture), so you confirm each region by visiting it.
Seeing both re-flag confirms the per-document removal reached every editable.
3. Added words are language-agnostic
This step needs two or more spellcheck languages enabled in Settings.
It verifies the word set is consulted independently of language order.
brilligzzz and brilligzzz
addWords(["brilligzzz"])
removeWords(["brilligzzz"])
Enable a second spellcheck language. Confirm brilligzzz is squiggled.
Click addWords . The squiggle should clear.
Switch the field's language (change the lang attribute via DevTools,
or change the dominant language of the typed text), then click into the field
to force a fresh check: brilligzzz should stay unflagged
under the other language too.
4. Per-document cap is enforced (20000 words / 128 bytes per word)
Run this test last. The per-document word set is shared by every test on
this page and persists for the document's lifetime, and the bulk step below fills
it permanently. If you run Test 4 before Tests 1–3, their addWords
calls will be silently rejected (cap full) and those tests will appear to fail.
The per-document set is capped at 20000 words and 128 bytes per word. Once the
cap is reached, further additions are silently dropped .
Field A contains zzzzzqqqqq ; field B contains
capwordzz . Both start squiggled.
zzzzzqqqqq is misspelled.
capwordzz is misspelled.
A: addWords(["zzzzzqqqqq"])
Fill cap: addWords(21000 words + 1 over-long word)
B: addWords(["capwordzz"])
Below the cap. Click A: addWords(["zzzzzqqqqq"]) . Its squiggle
should clear — the dictionary works normally below the cap.
Fill the cap. Click Fill cap . The page must not throw and must
stay responsive, and the DevTools console should show exactly one warning:
“per-document word limit reached…”
Above the cap. Click B: addWords(["capwordzz"]) . The squiggle on
capwordzz should stay — the word is
rejected because the per-document set is full. (If it clears, the cap is not
being enforced.)