diff options
Diffstat (limited to 'testing/web-platform/tests/html/editing/editing-0/spelling-and-grammar-checking')
13 files changed, 285 insertions, 0 deletions
diff --git a/testing/web-platform/tests/html/editing/editing-0/spelling-and-grammar-checking/references/spelling-markers-001-ref.html b/testing/web-platform/tests/html/editing/editing-0/spelling-and-grammar-checking/references/spelling-markers-001-ref.html new file mode 100644 index 0000000000..68dcc54702 --- /dev/null +++ b/testing/web-platform/tests/html/editing/editing-0/spelling-and-grammar-checking/references/spelling-markers-001-ref.html @@ -0,0 +1,7 @@ +<!DOCTYPE html> +<html lang="en"> +<meta charset="utf-8"> +<title>Reference file for spellcheck tests</title> + +<div>This test passes if there is no visual marker indicating the spellinnnnnggg mistake in this sentence, and fails otherwise.</div> + diff --git a/testing/web-platform/tests/html/editing/editing-0/spelling-and-grammar-checking/spellcheck-enumerated-ascii-case-insensitive.html b/testing/web-platform/tests/html/editing/editing-0/spelling-and-grammar-checking/spellcheck-enumerated-ascii-case-insensitive.html new file mode 100644 index 0000000000..9f00f1dff1 --- /dev/null +++ b/testing/web-platform/tests/html/editing/editing-0/spelling-and-grammar-checking/spellcheck-enumerated-ascii-case-insensitive.html @@ -0,0 +1,27 @@ +<!DOCTYPE html> +<meta charset="utf-8"> +<link rel="help" href="https://html.spec.whatwg.org/#attr-spellcheck"> +<link rel="help" href="https://html.spec.whatwg.org/#enumerated-attribute"> +<meta name="assert" content="@spellcheck values are ASCII case-insensitive"> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<!-- + While <div> and <span> aren’t defined as “checkable for the purposes of this + feature”, this has no effect on the attribute’s state. + + We wrap the <span> elements under test with <div> elements so the checking + enabled algorithm stops at step 4 (ancestor content attribute), before steps + relying on user-agent-defined behavior (see [#concept-spellcheck-default]). +--> +<div spellcheck="true"><span spellcheck="false"></span></div> +<div spellcheck="true"><span spellcheck="FaLsE"></span></div> +<div spellcheck="true"><span spellcheck="falſe"></span></div> +<script> +const span = document.querySelectorAll("span"); + +test(() => { + assert_equals(span[0].spellcheck, false, "lowercase valid"); + assert_equals(span[1].spellcheck, false, "mixed case valid"); + assert_equals(span[2].spellcheck, true, "non-ASCII invalid"); +}, "keyword false"); +</script> diff --git a/testing/web-platform/tests/html/editing/editing-0/spelling-and-grammar-checking/spelling-markers-001.html b/testing/web-platform/tests/html/editing/editing-0/spelling-and-grammar-checking/spelling-markers-001.html new file mode 100644 index 0000000000..7dd891374b --- /dev/null +++ b/testing/web-platform/tests/html/editing/editing-0/spelling-and-grammar-checking/spelling-markers-001.html @@ -0,0 +1,17 @@ +<!DOCTYPE html> +<html lang="en"> +<meta charset="utf-8"> +<title>Turning off spellcheck on editing hosts</title> +<link rel=match href="references/spelling-markers-001-ref.html"> +<link rel=help href="https://html.spec.whatwg.org/multipage/interaction.html#spelling-and-grammar-checking"> +<meta name=assert content="Spellchecking stops applying to editing hosts when they become non editable"> + +<div id="test" contenteditable=true>This test passes if there is no visual marker indicating the spellinnnnnggg mistake in this sentence, and fails otherwise.</div> + +<script> + var test = document.getElementById("test"); + // Force spellcheck by focus and then blur + test.focus(); + test.blur(); + test.removeAttribute("contenteditable"); +</script> diff --git a/testing/web-platform/tests/html/editing/editing-0/spelling-and-grammar-checking/spelling-markers-002.html b/testing/web-platform/tests/html/editing/editing-0/spelling-and-grammar-checking/spelling-markers-002.html new file mode 100644 index 0000000000..b361b93040 --- /dev/null +++ b/testing/web-platform/tests/html/editing/editing-0/spelling-and-grammar-checking/spelling-markers-002.html @@ -0,0 +1,18 @@ +<!DOCTYPE html> +<html lang="en"> +<meta charset="utf-8"> +<title>Turning off spellcheck on editable elements</title> +<link rel=match href="references/spelling-markers-001-ref.html"> +<link rel=help href="https://html.spec.whatwg.org/multipage/interaction.html#spelling-and-grammar-checking"> +<meta name=assert content="Spellchecking stops applying to editable elements when they become non editable"> + +<div id="test" contenteditable=true>This test passes if there is no visual marker indicating the <span id=child>spellinnnnnggg</span> mistake in this sentence, and fails otherwise.</div> + +<script> + var test = document.getElementById("test"); + // Force spellcheck by focus and then blur + test.focus(); + test.blur(); + var child = document.getElementById("child"); + child.setAttribute("contenteditable", false); +</script> diff --git a/testing/web-platform/tests/html/editing/editing-0/spelling-and-grammar-checking/spelling-markers-003.html b/testing/web-platform/tests/html/editing/editing-0/spelling-and-grammar-checking/spelling-markers-003.html new file mode 100644 index 0000000000..d1a6aa3a9b --- /dev/null +++ b/testing/web-platform/tests/html/editing/editing-0/spelling-and-grammar-checking/spelling-markers-003.html @@ -0,0 +1,17 @@ +<!DOCTYPE html> +<html lang="en"> +<meta charset="utf-8"> +<title>Turning off spellcheck on editing hosts while keeping them editable</title> +<link rel=match href="references/spelling-markers-001-ref.html"> +<link rel=help href="https://html.spec.whatwg.org/multipage/interaction.html#spelling-and-grammar-checking"> +<meta name=assert content="Spellchecking stops applying to editing hosts when the spellcheck attribute becomes false"> + +<div id="test" spellcheck=true contenteditable=true>This test passes if there is no visual marker indicating the spellinnnnnggg mistake in this sentence, and fails otherwise.</div> + +<script> + var test = document.getElementById("test"); + // Force spellcheck by focus and then blur + test.focus(); + test.blur(); + test.setAttribute("spellcheck", false); +</script> diff --git a/testing/web-platform/tests/html/editing/editing-0/spelling-and-grammar-checking/spelling-markers-004.html b/testing/web-platform/tests/html/editing/editing-0/spelling-and-grammar-checking/spelling-markers-004.html new file mode 100644 index 0000000000..c718e77bb8 --- /dev/null +++ b/testing/web-platform/tests/html/editing/editing-0/spelling-and-grammar-checking/spelling-markers-004.html @@ -0,0 +1,18 @@ +<!DOCTYPE html> +<html lang="en"> +<meta charset="utf-8"> +<title>Turning off spellcheck on editable elements while keeping them editable</title> +<link rel=match href="references/spelling-markers-001-ref.html"> +<link rel=help href="https://html.spec.whatwg.org/multipage/interaction.html#spelling-and-grammar-checking"> +<meta name=assert content="Spellchecking stops applying to editable elements when the spellcheck attribute becomes false"> + +<div id="test" spellcheck=true contenteditable=true>This test passes if there is no visual marker indicating the <span id=child>spellinnnnnggg</span> mistake in this sentence, and fails otherwise.</div> + +<script> + var test = document.getElementById("test"); + // Force spellcheck by focus then blur + test.focus(); + test.blur(); + var child = document.getElementById("child"); + child.setAttribute("spellcheck", false); +</script> diff --git a/testing/web-platform/tests/html/editing/editing-0/spelling-and-grammar-checking/spelling-markers-005.html b/testing/web-platform/tests/html/editing/editing-0/spelling-and-grammar-checking/spelling-markers-005.html new file mode 100644 index 0000000000..705ee7b67f --- /dev/null +++ b/testing/web-platform/tests/html/editing/editing-0/spelling-and-grammar-checking/spelling-markers-005.html @@ -0,0 +1,18 @@ +<!DOCTYPE html> +<html lang="en"> +<meta charset="utf-8"> +<title>Turning off spellcheck on editable elements via an ancestor</title> +<link rel=match href="references/spelling-markers-001-ref.html"> +<link rel=help href="https://html.spec.whatwg.org/multipage/interaction.html#spelling-and-grammar-checking"> +<meta name=assert content="Spellchecking stops applying to editable elements when the spellcheck attribute becomes false on an ancestor"> + +<div id="test" contenteditable=true>This test passes if there is no visual marker indicating the <span id=child><span>spellinnnnnggg</span></span> mistake in this sentence, and fails otherwise.</div> + +<script> + var test = document.getElementById("test"); + // Force spellcheck by focus then blur + test.focus(); + test.blur(); + var child = document.getElementById("child"); + child.setAttribute("spellcheck", false); +</script> diff --git a/testing/web-platform/tests/html/editing/editing-0/spelling-and-grammar-checking/spelling-markers-006.html b/testing/web-platform/tests/html/editing/editing-0/spelling-and-grammar-checking/spelling-markers-006.html new file mode 100644 index 0000000000..512d473f13 --- /dev/null +++ b/testing/web-platform/tests/html/editing/editing-0/spelling-and-grammar-checking/spelling-markers-006.html @@ -0,0 +1,20 @@ +<!DOCTYPE html> +<html lang="en"> +<meta charset="utf-8"> +<title>Turning off spellcheck via an ancestor of the editing host</title> +<link rel=match href="references/spelling-markers-001-ref.html"> +<link rel=help href="https://html.spec.whatwg.org/multipage/interaction.html#spelling-and-grammar-checking"> +<meta name=assert content="Spellchecking stops applying when the spellcheck attribute becomes false on an ancestor, without restrcting the search to the nearest editing host"> + +<div id=parent> + <div id=test contenteditable=true>This test passes if there is no visual marker indicating the spellinnnnnggg mistake in this sentence, and fails otherwise.</div> +</div> + +<script> + var test = document.getElementById("test"); + // Force spellcheck by focus then blur + test.focus(); + test.blur(); + var p = document.getElementById("parent"); + p.setAttribute("spellcheck", false); +</script> diff --git a/testing/web-platform/tests/html/editing/editing-0/spelling-and-grammar-checking/spelling-markers-007.html b/testing/web-platform/tests/html/editing/editing-0/spelling-and-grammar-checking/spelling-markers-007.html new file mode 100644 index 0000000000..31b3755f3a --- /dev/null +++ b/testing/web-platform/tests/html/editing/editing-0/spelling-and-grammar-checking/spelling-markers-007.html @@ -0,0 +1,27 @@ +<!DOCTYPE html> +<html lang="en"> +<meta charset="utf-8"> +<title>Turning off spellcheck by making textareas readonly</title> +<link rel=match href="references/spelling-markers-001-ref.html"> +<link rel=help href="https://html.spec.whatwg.org/multipage/interaction.html#spelling-and-grammar-checking"> +<meta name=assert content="Spellchecking stops applying to textareas when they become readonly"> + +<style> +#test { + /* Match the ref */ + all: initial; + width: 100%; + display: block; + font-family: inherit; +} +</style> + +<textarea id=test>This test passes if there is no visual marker indicating the spellinnnnnggg mistake in this sentence, and fails otherwise.</textarea> + +<script> + var test = document.getElementById("test"); + // Force spellcheck by focus then blur + test.focus(); + test.blur(); + test.setAttribute("readonly", true); +</script> diff --git a/testing/web-platform/tests/html/editing/editing-0/spelling-and-grammar-checking/spelling-markers-008.html b/testing/web-platform/tests/html/editing/editing-0/spelling-and-grammar-checking/spelling-markers-008.html new file mode 100644 index 0000000000..f891acff42 --- /dev/null +++ b/testing/web-platform/tests/html/editing/editing-0/spelling-and-grammar-checking/spelling-markers-008.html @@ -0,0 +1,27 @@ +<!DOCTYPE html> +<html lang="en"> +<meta charset="utf-8"> +<title>Turning off spellcheck by making textareas disabled</title> +<link rel=match href="references/spelling-markers-001-ref.html"> +<link rel=help href="https://html.spec.whatwg.org/multipage/interaction.html#spelling-and-grammar-checking"> +<meta name=assert content="Spellchecking stops applying to textareas when they become disabled"> + +<style> +#test { + /* Match the ref */ + all: initial; + width: 100%; + display: block; + font-family: inherit; +} +</style> + +<textarea id=test>This test passes if there is no visual marker indicating the spellinnnnnggg mistake in this sentence, and fails otherwise.</textarea> + +<script> + var test = document.getElementById("test"); + // Force spellcheck by focus then blur + test.focus(); + test.blur(); + test.setAttribute("disabled", true); +</script> diff --git a/testing/web-platform/tests/html/editing/editing-0/spelling-and-grammar-checking/spelling-markers-009.html b/testing/web-platform/tests/html/editing/editing-0/spelling-and-grammar-checking/spelling-markers-009.html new file mode 100644 index 0000000000..96eb87d2f4 --- /dev/null +++ b/testing/web-platform/tests/html/editing/editing-0/spelling-and-grammar-checking/spelling-markers-009.html @@ -0,0 +1,27 @@ +<!DOCTYPE html> +<html lang="en"> +<meta charset="utf-8"> +<title>Turning off spellcheck by making input elements readonly</title> +<link rel=match href="references/spelling-markers-001-ref.html"> +<link rel=help href="https://html.spec.whatwg.org/multipage/interaction.html#spelling-and-grammar-checking"> +<meta name=assert content="Spellchecking stops applying to input elements when they become readonly"> + +<style> +#test { + /* Match the ref */ + all: initial; + width: 100%; + display: block; + font-family: inherit; +} +</style> + +<input type=text id=test value="This test passes if there is no visual marker indicating the spellinnnnnggg mistake in this sentence, and fails otherwise."> + +<script> + var test = document.getElementById("test"); + // Force spellcheck by focus then blur + test.focus(); + test.blur(); + test.setAttribute("readonly", true); +</script> diff --git a/testing/web-platform/tests/html/editing/editing-0/spelling-and-grammar-checking/spelling-markers-010.html b/testing/web-platform/tests/html/editing/editing-0/spelling-and-grammar-checking/spelling-markers-010.html new file mode 100644 index 0000000000..16275f10e9 --- /dev/null +++ b/testing/web-platform/tests/html/editing/editing-0/spelling-and-grammar-checking/spelling-markers-010.html @@ -0,0 +1,27 @@ +<!DOCTYPE html> +<html lang="en"> +<meta charset="utf-8"> +<title>Turning off spellcheck by making input elements disabled</title> +<link rel=match href="references/spelling-markers-001-ref.html"> +<link rel=help href="https://html.spec.whatwg.org/multipage/interaction.html#spelling-and-grammar-checking"> +<meta name=assert content="Spellchecking stops applying to input elements when they become disabled"> + +<style> +#test { + /* Match the ref */ + all: initial; + width: 100%; + display: block; + font-family: inherit; +} +</style> + +<input type=text id=test value="This test passes if there is no visual marker indicating the spellinnnnnggg mistake in this sentence, and fails otherwise."> + +<script> + var test = document.getElementById("test"); + // Force spellcheck by focus then blur + test.focus(); + test.blur(); + test.setAttribute("disabled", true); +</script> diff --git a/testing/web-platform/tests/html/editing/editing-0/spelling-and-grammar-checking/user-interaction-editing-spellcheck.html b/testing/web-platform/tests/html/editing/editing-0/spelling-and-grammar-checking/user-interaction-editing-spellcheck.html new file mode 100644 index 0000000000..c8bdaafdb8 --- /dev/null +++ b/testing/web-platform/tests/html/editing/editing-0/spelling-and-grammar-checking/user-interaction-editing-spellcheck.html @@ -0,0 +1,35 @@ +<!DOCTYPE html> +<html> + <head> + <title>Editing: spellcheck attribute test</title> + <link rel="author" title="Baidu" href="mailto: guopengcheng@baidu.com"/> + <link rel="help" href="https://html.spec.whatwg.org/multipage/#spelling-and-grammar-checking"/> + <script src="/resources/testharness.js"></script> + <script src="/resources/testharnessreport.js"></script> + </head> + <body> + <div id="log"></div> + <textarea id="testText1" spellcheck="true">Test textarea with spellcheck is true</textarea> + <textarea id="testText2" spellcheck="false">Test textarea with spellcheck is false</textarea> + <script type="text/javascript"> + test(function() { + assert_true(document.getElementById("testText1").spellcheck, "check for testText1 spellcheck value"); + assert_false(document.getElementById("testText2").spellcheck, "check for testText2 spellcheck value"); + }, "Getting spellcheck IDL attribute"); + test(function() { + var testElement = document.createElement("testElement"); + testElement.contentEditable = true; + testElement.spellcheck = true; + assert_true(testElement.spellcheck, "check for testElement.spellcheck value"); + assert_equals(testElement.getAttribute("spellcheck"), "true"); + }, "Setting spellcheck IDL attribute to true"); + test(function() { + var testElement = document.createElement("testElement"); + testElement.contentEditable = true; + testElement.spellcheck = false; + assert_false(testElement.spellcheck, "check for testText2 spellcheck value"); + assert_equals(testElement.getAttribute("spellcheck"), "false"); + }, "Setting spellcheck IDL attribute to false"); + </script> + </body> +</html> |