Source code
Revision control
Copy as Markdown
Other Tools
Test Info: Errors
- This test gets skipped with pattern: os == 'android'
- This test failed 1 times in the preceding 30 days. quicksearch this test
- Manifest: editor/spellchecker/tests/mochitest.toml
<!DOCTYPE HTML>
<html>
<!--
-->
<head>
<meta charset="utf-8">
<script src="/tests/SimpleTest/SimpleTest.js"></script>
<script src="/tests/SimpleTest/EventUtils.js"></script>
<script src="spellcheck.js"></script>
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
</head>
<body>
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=1497480">Mozilla Bug 1497480</a>
<p id="display"></p>
<div id="light"></div>
<script>
let gMisspeltWords = [];
let { maybeOnSpellCheck } = SpecialPowers.ChromeUtils.importESModule(
);
const template = document.createElement("template");
template.innerHTML = `<div id="target" contenteditable>Test</div>`;
let shadow = document.getElementById("light").attachShadow({mode: "closed"});
shadow.appendChild(template.content.cloneNode(true));
let target = shadow.getElementById("target");
let outOfTarget = document.getElementById("outOfTarget");
function getEditor() {
var win = window;
var editingSession = SpecialPowers.wrap(win).docShell.editingSession;
return editingSession.getEditorForWindow(win);
}
// Wait for the page to be ready for testing
add_task(async function() {
await new Promise((resolve) => {
SimpleTest.waitForFocus(() => {
SimpleTest.executeSoon(resolve);
}, window);
});
// Wait for first full spell-checking.
synthesizeMouseAtCenter(outOfTarget, {}, window);
await new Promise((resolve) => {
maybeOnSpellCheck(outOfTarget, function() {
resolve();
});
});
});
// Should perform spell-checking when anchor navigates away from ShadowDOM.
add_task(async function() {
synthesizeMouseAtCenter(target, {}, window);
sendString(" spellechek");
gMisspeltWords.push("spellechek");
synthesizeMouseAtCenter(outOfTarget, {}, window);
await new Promise((resolve) => {
maybeOnSpellCheck(target, function() {
ok(isSpellingCheckOk(getEditor(), gMisspeltWords),
"Spell-checking should be performed when anchor navigates away from ShadowDOM");
SimpleTest.executeSoon(resolve);
});
});
});
// Should perform spell-checking when pressing enter in contenteditable in ShadowDOM.
add_task(async function() {
synthesizeMouseAtCenter(target, {}, window);
sendString(" spellechck");
gMisspeltWords.push("spellechck");
synthesizeKey("KEY_Enter", {}, window);
await new Promise((resolve) => {
maybeOnSpellCheck(target, function() {
ok(isSpellingCheckOk(getEditor(), gMisspeltWords),
"Spell-checking should be performed when pressing enter in contenteditable in ShadowDOM");
SimpleTest.executeSoon(resolve);
});
});
});
</script>
</body>
</html>