Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support to test native spelling|grammar errors #30863

Open
mrego opened this issue Sep 20, 2021 · 5 comments
Open

Add support to test native spelling|grammar errors #30863

mrego opened this issue Sep 20, 2021 · 5 comments

Comments

@mrego
Copy link
Member

mrego commented Sep 20, 2021

I haven't found an easy and consistent way to test if a browser is showing or not a spelling|grammar error marker in some editable content. Some browsers use lazy strategies in order to paint these error markers, so it's not possible to know if they have painted them or not in a test.

It'd be nice to have some way to do this, maybe some kind of API or anything like that, that could tell browsers to show them on demand.

@delan
Copy link
Member

delan commented Sep 20, 2021

To expand on this… while implementing these features in Blink, we’ve found a few problems stopping us from reliably testing spelling/grammar errors with portable tests. Some of these are probably impl-specific:

  1. Spell checking doesn’t seem to work in content_shell, which Chromium CI uses to run tests. WPT CI uses the full browser though, so that’s just a problem on our end.
  2. We haven’t been able to get squiggly lines to reliably appear in test results. We’ve tried to work around Blink’s lazy spell checking with some success, but @mrego’s recent work has found that this might not be enough. Digging into the impl side might reveal a cleaner solution.

But some are more fundamental:

  1. There’s no portable way to guarantee that some text under test is a spelling error or grammar error. We can get close with spelling errors (spellcheck contenteditable lang="en" and a misspelled English word like “quikc”), but that still assumes that the browser has a working English spelling dictionary (and I guess that “quikc” never becomes a word). So it would be nice if there was some kind of standard API, even if only allowed in tests, for intentionally marking something as an error. Maybe even a pair of special language tags where everything is an error?

@foolip
Copy link
Member

foolip commented Sep 20, 2021

What would be a simple fix for this? Perhaps a test_driver.spellcheck() that resolves when all squiggles that could appear have appeared?

@delan
Copy link
Member

delan commented Sep 20, 2021

Hmm, checking what I said in problem 3, the specs only say that user agents “may” use the lang attribute to control the language that spell checking is done in, which I guess makes sense, as only the user really knows what language they’re typing in.

What would be a simple fix for this? Perhaps a test_driver.spellcheck() that resolves when all squiggles that could appear have appeared?

That could work, at least as a solution to problem 2, and it would eliminate the assumption that spell checking is automatic and continuous (html #spelling-and-grammar-checking, “user agent could offer on-demand checking, could perform continuous checking while the checking is enabled, or could use other interfaces”).

@delan
Copy link
Member

delan commented Apr 20, 2022

@foolip, https://web-platform-tests.org/writing-tests/testdriver.html says:

[testdriver.js] is currently supported only for testharness.js tests.

Do you know how feasible it would be to extend this support to reftests?

As for problem 3, guaranteeing that some text under test is a spelling or grammar error, we could probably design something similar to Chromium’s chrome.internals.setMarker(), which would be simpler and more flexible than something like magic language tags. Impls should then disable any real spelling/grammar language data while running tests.

@foolip
Copy link
Member

foolip commented Apr 20, 2022

@delan that's the topic of #13183 and I think it's feasible, but hasn't seemed like a big priority so far. If you (or anyone) has time to spend on it, please poke that issue for advice.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants