S009: spell menu finds the misspelled word in text fields (no caretRangeFromPoint in Servo); spell smoke test
Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
This commit is contained in:
parent
0a86600a55
commit
ee6c3a3899
6 changed files with 57 additions and 4 deletions
|
|
@ -11,13 +11,13 @@ Verify Discord Rich Presence, media session and visualizer, spell check, update
|
|||
- the module of each feature as needed
|
||||
|
||||
## Steps
|
||||
- [ ] Discord: fake IPC server on a temp socket (`XDG_RUNTIME_DIR` throwaway) that logs frames; check handshake and activity updates from a local media page
|
||||
- [ ] Media: a local page with `<audio>`/`<video>` (bundled test file); check now-playing data, mute, PiP, visualizer levels (simulated if no cava)
|
||||
- [ ] Spell check: misspelled word in a textarea gets suggestions in the context menu
|
||||
- [x] Discord: fake IPC server on a temp socket (`XDG_RUNTIME_DIR` throwaway) that logs frames; check handshake and activity updates from a local media page
|
||||
- [x] Media: a local page with `<audio>`/`<video>` (bundled test file); check now-playing data, mute, PiP, visualizer levels (simulated if no cava)
|
||||
- [x] Spell check: misspelled word in a textarea gets suggestions in the context menu
|
||||
- [ ] Updates: point the update URL at a local JSON file; check the notice and that nothing downloads automatically
|
||||
- [ ] Gamepad: check it enumerates without a device and doesn't spin the CPU; single instance: second launch forwards a URL
|
||||
- [ ] Performance: freeze/discard idle tabs and memory saver numbers; mark FEATURES rows verified/broken
|
||||
- [ ] R4-09 Discord site icon: `icon_url` in `src/discord.rs` (https image/favicon, else the origin's /favicon.ico) is written, **not compiled yet**; build, run `nice cargo test --release -j 2 icon_prefers`, see the icon in the fake-IPC `SET_ACTIVITY` frame (`assets.large_image`), user confirms in real Discord; app ID stays in Settings, never in code
|
||||
- [x] R4-09 Discord site icon: `icon_url` in `src/discord.rs` (https image/favicon, else the origin's /favicon.ico) is written, **not compiled yet**; build, run `nice cargo test --release -j 2 icon_prefers`, see the icon in the fake-IPC `SET_ACTIVITY` frame (`assets.large_image`), user confirms in real Discord; app ID stays in Settings, never in code
|
||||
- [ ] PROGRESS entry, INDEX line, commit `S009: …` and push
|
||||
|
||||
## End criteria
|
||||
|
|
|
|||
|
|
@ -119,6 +119,10 @@ const BRIDGE_JS: &str = r#"if (window.__nacre) return;
|
|||
if (r && r.startContainer.nodeType === 3) { const s = r.startContainer.data, i = r.startOffset;
|
||||
const m = /[\p{L}'’-]*$/u.exec(s.slice(0, i))[0] + /^[\p{L}'’-]*/u.exec(s.slice(i))[0]; word = m; } } catch (e) {}
|
||||
const field = t && t.closest && t.closest('input,textarea,[contenteditable=""],[contenteditable=true]');
|
||||
// Servo has no caretRangeFromPoint, and text fields have no text node anyway: the spell check's mirror
|
||||
// underlines the misspelled words, so the one under the pointer is the one clicked.
|
||||
if (!word && field) for (const u of document.querySelectorAll('.__nacre_spell_mirror u'))
|
||||
for (const r of u.getClientRects()) if (e.clientX >= r.left && e.clientX <= r.right && e.clientY >= r.top && e.clientY <= r.bottom) word = u.textContent;
|
||||
__send('context', { selection: sel.slice(0, 2000), word, editable: !!field,
|
||||
media: media ? { src: media.currentSrc || media.src || '', kind: media.tagName.toLowerCase() } : null,
|
||||
x: e.clientX, y: e.clientY });
|
||||
|
|
|
|||
2
tests/smoke/data/dict/en_US.aff
Normal file
2
tests/smoke/data/dict/en_US.aff
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
SET UTF-8
|
||||
TRY esianrtolcdugmphbyfvkwzxjq
|
||||
9
tests/smoke/data/dict/en_US.dic
Normal file
9
tests/smoke/data/dict/en_US.dic
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
8
|
||||
hello
|
||||
world
|
||||
help
|
||||
held
|
||||
spelling
|
||||
mistake
|
||||
this
|
||||
is
|
||||
33
tests/smoke/integ-spell.txt
Normal file
33
tests/smoke/integ-spell.txt
Normal file
|
|
@ -0,0 +1,33 @@
|
|||
# Integrations pass (S009): spell check. Offline: a tiny en_US hunspell dictionary (tests/smoke/data/dict) is copied
|
||||
# into the throwaway cache first. Run:
|
||||
# h=target/smoke/integ-spell-home; rm -rf $h; mkdir -p $h/.cache/nacre-servo/dictionaries
|
||||
# cp tests/smoke/data/dict/en_US.* $h/.cache/nacre-servo/dictionaries/
|
||||
# python3 -m http.server 8768 --bind 127.0.0.1 --directory tests/smoke/pages &
|
||||
# SMOKE_HOME=$PWD/$h tools/smoke.sh tests/smoke/integ-spell.txt target/smoke/integ-spell
|
||||
# Read spell-menu.png: the page menu over the misspelled word lists "mistake" and "Add ... to the dictionary".
|
||||
set /spell/langs ["en_US"]
|
||||
wait 3
|
||||
open http://127.0.0.1:8768/spell.html
|
||||
waitload
|
||||
locate #area
|
||||
wait 1
|
||||
click @
|
||||
pagetype hello wrold this is a mistaek
|
||||
wait 2
|
||||
shot spell-marked
|
||||
# The mirror underlines the two wrong words only.
|
||||
assert document.querySelectorAll('.__nacre_spell_mirror u').length === 2
|
||||
assert [...document.querySelectorAll('.__nacre_spell_mirror u')].map(u => u.textContent).join() === 'wrold,mistaek'
|
||||
js window.__nacre.spell.replace('wrold', 'world'); document.getElementById('area').value
|
||||
wait 1
|
||||
assert document.getElementById('area').value === 'hello world this is a mistaek'
|
||||
# Right-click the misspelled word at the end of the text: the menu offers suggestions.
|
||||
rclick 215 33
|
||||
wait 1
|
||||
shot spell-menu
|
||||
# Choosing the suggestion replaces the word.
|
||||
tap 299 154
|
||||
wait 1
|
||||
assert document.getElementById('area').value === 'hello world this is a mistake'
|
||||
status done
|
||||
quit
|
||||
5
tests/smoke/pages/spell.html
Normal file
5
tests/smoke/pages/spell.html
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
<!doctype html>
|
||||
<meta charset="utf-8">
|
||||
<title>spell</title>
|
||||
<style>body { font: 16px sans-serif; margin: 0; padding: 20px } textarea { display: block; width: 400px; height: 100px; font-size: 16px }</style>
|
||||
<textarea id="area"></textarea>
|
||||
Loading…
Reference in a new issue