diff options
Diffstat (limited to 'testing/web-platform/tests/html/editing/editing-0')
27 files changed, 1279 insertions, 0 deletions
diff --git a/testing/web-platform/tests/html/editing/editing-0/autocapitalization/autocapitalize.html b/testing/web-platform/tests/html/editing/editing-0/autocapitalization/autocapitalize.html new file mode 100644 index 0000000000..49ee14329c --- /dev/null +++ b/testing/web-platform/tests/html/editing/editing-0/autocapitalization/autocapitalize.html @@ -0,0 +1,688 @@ +<!DOCTYPE html> +<html> +<link rel="help" href="https://html.spec.whatwg.org/multipage/interaction.html#autocapitalization"> +<body> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<script> + +test(function() { + assert_true('autocapitalize' in document.createElement('input')); +}, "Test that the autocapitalize is available on HTMLInputElement.") + +test(function() { + assert_true('autocapitalize' in document.createElement('textarea')); +}, "Test that the autocapitalize is available on HTMLTextAreaElement.") + +test(function() { + assert_true('autocapitalize' in document.createElement('div')); +}, "Test that the autocapitalize is available on div.") + +test(function() { + var elements = [ document.createElement('input'), + document.createElement('textarea'), + document.createElement('div') ]; + + elements.forEach(function(e) { + e.autocapitalize = 'on'; + assert_equals(e.autocapitalize, 'sentences'); + + e.autocapitalize = 'off'; + assert_equals(e.autocapitalize, 'none'); + }); +}, "Test deprecated values of autocapitalize."); + +test(function() { + var elements = [ document.createElement('input'), + document.createElement('textarea'), + document.createElement('div') ]; + var knownValues = [ 'none', 'characters', 'words', 'sentences' ]; + + elements.forEach(function(e) { + // Default value. + assert_equals(e.autocapitalize, ''); + + // Empty value. + e.autocapitalize = ''; + assert_equals(e.autocapitalize, ''); + assert_equals(e.getAttribute('autocapitalize'), ''); + e.setAttribute('autocapitalize', ''); + assert_equals(e.autocapitalize, ''); + assert_equals(e.getAttribute('autocapitalize'), ''); + assert_equals(e.autocapitalize, ''); + + // Invalid value. + e.autocapitalize = 'foo'; + assert_equals(e.autocapitalize, 'sentences'); + assert_equals(e.getAttribute('autocapitalize'), 'foo'); + e.setAttribute('autocapitalize', 'bar'); + assert_equals(e.autocapitalize, 'sentences'); + assert_equals(e.getAttribute('autocapitalize'), 'bar'); + + // Default value. + e.removeAttribute('autocapitalize'); + assert_equals(e.autocapitalize, ''); + assert_equals(e.getAttribute('autocapitalize'), null); + + // Case insensitive. + e.setAttribute('autocapitalize', 'NoNe'); + assert_equals(e.autocapitalize, 'none'); + assert_equals(e.getAttribute('autocapitalize'), 'NoNe'); + e.autocapitalize = 'WORDS'; + assert_equals(e.autocapitalize, 'words'); + assert_equals(e.getAttribute('autocapitalize'), 'WORDS'); + + knownValues.forEach(function(value) { + e.setAttribute('autocapitalize', value); + assert_equals(e.autocapitalize, value); + assert_equals(e.getAttribute('autocapitalize'), value); + + e.removeAttribute('autocapitalize'); + + e.autocapitalize = value; + assert_equals(e.autocapitalize, value); + assert_equals(e.getAttribute('autocapitalize'), value); + + e.removeAttribute('autocapitalize'); + }); + }); +}, "Test reflection of autocapitalize."); + +test(function() { +var testData = [ 'text', + 'search', + 'email', + 'url', + 'tel', + 'number', + 'date', + 'color', + 'password' ]; + + testData.forEach(function(data) { + const input = document.createElement('input'); + input.type = data; + assert_equals(input.autocapitalize, ''); + + // Verify that wrapping the input element in a form doesn't change the + // defaults. + const form = document.createElement('form'); + form.appendChild(input); + assert_equals(input.autocapitalize, ''); + }); +}, "Test that the IDL attribute returns the empty string if the content " ++ "attribute is not set.") + +test(function() { + const testData = [ + { + formValue: null, + formElementValue: null, + inheritedResult: '', + uninheritedResult: '', + }, + { + formValue: null, + formElementValue: '', + inheritedResult: '', + uninheritedResult: '', + }, + { + formValue: null, + formElementValue: 'on', + inheritedResult: 'sentences', + uninheritedResult: 'sentences', + }, + { + formValue: null, + formElementValue: 'off', + inheritedResult: 'none', + uninheritedResult: 'none', + }, + { + formValue: null, + formElementValue: 'none', + inheritedResult: 'none', + uninheritedResult: 'none', + }, + { + formValue: null, + formElementValue: 'characters', + inheritedResult: 'characters', + uninheritedResult: 'characters', + }, + { + formValue: null, + formElementValue: 'words', + inheritedResult: 'words', + uninheritedResult: 'words', + }, + { + formValue: null, + formElementValue: 'sentences', + inheritedResult: 'sentences', + uninheritedResult: 'sentences', + }, + { + formValue: null, + formElementValue: 'foo', + inheritedResult: 'sentences', + uninheritedResult: 'sentences', + }, + { + formValue: '', + formElementValue: null, + inheritedResult: '', + uninheritedResult: '', + }, + { + formValue: '', + formElementValue: '', + inheritedResult: '', + uninheritedResult: '', + }, + { + formValue: '', + formElementValue: 'on', + inheritedResult: 'sentences', + uninheritedResult: 'sentences', + }, + { + formValue: '', + formElementValue: 'off', + inheritedResult: 'none', + uninheritedResult: 'none', + }, + { + formValue: '', + formElementValue: 'none', + inheritedResult: 'none', + uninheritedResult: 'none', + }, + { + formValue: '', + formElementValue: 'characters', + inheritedResult: 'characters', + uninheritedResult: 'characters', + }, + { + formValue: '', + formElementValue: 'words', + inheritedResult: 'words', + uninheritedResult: 'words', + }, + { + formValue: '', + formElementValue: 'sentences', + inheritedResult: 'sentences', + uninheritedResult: 'sentences', + }, + { + formValue: '', + formElementValue: 'foo', + inheritedResult: 'sentences', + uninheritedResult: 'sentences', + }, + { + formValue: 'on', + formElementValue: null, + inheritedResult: 'sentences', + uninheritedResult: '', + }, + { + formValue: 'on', + formElementValue: '', + inheritedResult: 'sentences', + uninheritedResult: '', + }, + { + formValue: 'on', + formElementValue: 'on', + inheritedResult: 'sentences', + uninheritedResult: 'sentences', + }, + { + formValue: 'on', + formElementValue: 'off', + inheritedResult: 'none', + uninheritedResult: 'none', + }, + { + formValue: 'on', + formElementValue: 'none', + inheritedResult: 'none', + uninheritedResult: 'none', + }, + { + formValue: 'on', + formElementValue: 'characters', + inheritedResult: 'characters', + uninheritedResult: 'characters', + }, + { + formValue: 'on', + formElementValue: 'words', + inheritedResult: 'words', + uninheritedResult: 'words', + }, + { + formValue: 'on', + formElementValue: 'sentences', + inheritedResult: 'sentences', + uninheritedResult: 'sentences', + }, + { + formValue: 'on', + formElementValue: 'foo', + inheritedResult: 'sentences', + uninheritedResult: 'sentences', + }, + { + formValue: 'off', + formElementValue: null, + inheritedResult: 'none', + uninheritedResult: '', + }, + { + formValue: 'off', + formElementValue: '', + inheritedResult: 'none', + uninheritedResult: '', + }, + { + formValue: 'off', + formElementValue: 'on', + inheritedResult: 'sentences', + uninheritedResult: 'sentences', + }, + { + formValue: 'off', + formElementValue: 'off', + inheritedResult: 'none', + uninheritedResult: 'none', + }, + { + formValue: 'off', + formElementValue: 'none', + inheritedResult: 'none', + uninheritedResult: 'none', + }, + { + formValue: 'off', + formElementValue: 'characters', + inheritedResult: 'characters', + uninheritedResult: 'characters', + }, + { + formValue: 'off', + formElementValue: 'words', + inheritedResult: 'words', + uninheritedResult: 'words', + }, + { + formValue: 'off', + formElementValue: 'sentences', + inheritedResult: 'sentences', + uninheritedResult: 'sentences', + }, + { + formValue: 'off', + formElementValue: 'foo', + inheritedResult: 'sentences', + uninheritedResult: 'sentences', + }, + { + formValue: 'none', + formElementValue: null, + inheritedResult: 'none', + uninheritedResult: '', + }, + { + formValue: 'none', + formElementValue: '', + inheritedResult: 'none', + uninheritedResult: '', + }, + { + formValue: 'none', + formElementValue: 'on', + inheritedResult: 'sentences', + uninheritedResult: 'sentences', + }, + { + formValue: 'none', + formElementValue: 'off', + inheritedResult: 'none', + uninheritedResult: 'none', + }, + { + formValue: 'none', + formElementValue: 'none', + inheritedResult: 'none', + uninheritedResult: 'none', + }, + { + formValue: 'none', + formElementValue: 'characters', + inheritedResult: 'characters', + uninheritedResult: 'characters', + }, + { + formValue: 'none', + formElementValue: 'words', + inheritedResult: 'words', + uninheritedResult: 'words', + }, + { + formValue: 'none', + formElementValue: 'sentences', + inheritedResult: 'sentences', + uninheritedResult: 'sentences', + }, + { + formValue: 'none', + formElementValue: 'foo', + inheritedResult: 'sentences', + uninheritedResult: 'sentences', + }, + { + formValue: 'characters', + formElementValue: null, + inheritedResult: 'characters', + uninheritedResult: '', + }, + { + formValue: 'characters', + formElementValue: '', + inheritedResult: 'characters', + uninheritedResult: '', + }, + { + formValue: 'characters', + formElementValue: 'on', + inheritedResult: 'sentences', + uninheritedResult: 'sentences', + }, + { + formValue: 'characters', + formElementValue: 'off', + inheritedResult: 'none', + uninheritedResult: 'none', + }, + { + formValue: 'characters', + formElementValue: 'none', + inheritedResult: 'none', + uninheritedResult: 'none', + }, + { + formValue: 'characters', + formElementValue: 'characters', + inheritedResult: 'characters', + uninheritedResult: 'characters', + }, + { + formValue: 'characters', + formElementValue: 'words', + inheritedResult: 'words', + uninheritedResult: 'words', + }, + { + formValue: 'characters', + formElementValue: 'sentences', + inheritedResult: 'sentences', + uninheritedResult: 'sentences', + }, + { + formValue: 'characters', + formElementValue: 'foo', + inheritedResult: 'sentences', + uninheritedResult: 'sentences', + }, + { + formValue: 'words', + formElementValue: null, + inheritedResult: 'words', + uninheritedResult: '', + }, + { + formValue: 'words', + formElementValue: '', + inheritedResult: 'words', + uninheritedResult: '', + }, + { + formValue: 'words', + formElementValue: 'on', + inheritedResult: 'sentences', + uninheritedResult: 'sentences', + }, + { + formValue: 'words', + formElementValue: 'off', + inheritedResult: 'none', + uninheritedResult: 'none', + }, + { + formValue: 'words', + formElementValue: 'none', + inheritedResult: 'none', + uninheritedResult: 'none', + }, + { + formValue: 'words', + formElementValue: 'characters', + inheritedResult: 'characters', + uninheritedResult: 'characters', + }, + { + formValue: 'words', + formElementValue: 'words', + inheritedResult: 'words', + uninheritedResult: 'words', + }, + { + formValue: 'words', + formElementValue: 'sentences', + inheritedResult: 'sentences', + uninheritedResult: 'sentences', + }, + { + formValue: 'words', + formElementValue: 'foo', + inheritedResult: 'sentences', + uninheritedResult: 'sentences', + }, + { + formValue: 'sentences', + formElementValue: null, + inheritedResult: 'sentences', + uninheritedResult: '', + }, + { + formValue: 'sentences', + formElementValue: '', + inheritedResult: 'sentences', + uninheritedResult: '', + }, + { + formValue: 'sentences', + formElementValue: 'on', + inheritedResult: 'sentences', + uninheritedResult: 'sentences', + }, + { + formValue: 'sentences', + formElementValue: 'off', + inheritedResult: 'none', + uninheritedResult: 'none', + }, + { + formValue: 'sentences', + formElementValue: 'none', + inheritedResult: 'none', + uninheritedResult: 'none', + }, + { + formValue: 'sentences', + formElementValue: 'characters', + inheritedResult: 'characters', + uninheritedResult: 'characters', + }, + { + formValue: 'sentences', + formElementValue: 'words', + inheritedResult: 'words', + uninheritedResult: 'words', + }, + { + formValue: 'sentences', + formElementValue: 'sentences', + inheritedResult: 'sentences', + uninheritedResult: 'sentences', + }, + { + formValue: 'sentences', + formElementValue: 'foo', + inheritedResult: 'sentences', + uninheritedResult: 'sentences', + }, + { + formValue: 'foo', + formElementValue: null, + inheritedResult: 'sentences', + uninheritedResult: '', + }, + { + formValue: 'foo', + formElementValue: '', + inheritedResult: 'sentences', + uninheritedResult: '', + }, + { + formValue: 'foo', + formElementValue: 'on', + inheritedResult: 'sentences', + uninheritedResult: 'sentences', + }, + { + formValue: 'foo', + formElementValue: 'off', + inheritedResult: 'none', + uninheritedResult: 'none', + }, + { + formValue: 'foo', + formElementValue: 'none', + inheritedResult: 'none', + uninheritedResult: 'none', + }, + { + formValue: 'foo', + formElementValue: 'characters', + inheritedResult: 'characters', + uninheritedResult: 'characters', + }, + { + formValue: 'foo', + formElementValue: 'words', + inheritedResult: 'words', + uninheritedResult: 'words', + }, + { + formValue: 'foo', + formElementValue: 'sentences', + inheritedResult: 'sentences', + uninheritedResult: 'sentences', + }, + { + formValue: 'foo', + formElementValue: 'foo', + inheritedResult: 'sentences', + uninheritedResult: 'sentences', + }, + ]; + + const formElements = [ + {element: 'button', inherits: true}, + {element: 'fieldset', inherits: true}, + {element: 'img', inherits: false}, + {element: 'input', inherits: true}, + {element: 'object', inherits: false}, + {element: 'output', inherits: true}, + {element: 'select', inherits: true}, + {element: 'textarea', inherits: true}, + ]; + + const form = document.createElement('form'); + form.id = 'form'; + document.body.appendChild(form); + + testData.forEach(data => { + form.removeAttribute('autocapitalize'); + + if (data.formValue !== null) { + form.setAttribute('autocapitalize', data.formValue); + } + + formElements.forEach(elementData => { + const element = document.createElement(elementData.element); + form.appendChild(element); + + const element2 = document.createElement(elementData.element); + element2.setAttribute('form', 'form'); + document.body.appendChild(element2); + + if (data.formElementValue !== null) { + element.setAttribute('autocapitalize', data.formElementValue); + element2.setAttribute('autocapitalize', data.formElementValue); + } + + const descriptionSuffix = 'with "' + data.formValue + + '" and form element with "'+ data.formElementValue + '"'; + + if (elementData.inherits) { + assert_equals(element.autocapitalize, data.inheritedResult, + `${elementData.element} element with form parent ` + + `${descriptionSuffix}`); + assert_equals(element2.autocapitalize, data.inheritedResult, + `${elementData.element} element with form owner attribute` + + ` set ${descriptionSuffix}`); + } else { + assert_equals(element.autocapitalize, data.uninheritedResult, + `${elementData.element} element with form parent ` + + `${descriptionSuffix}`); + assert_equals(element2.autocapitalize, data.uninheritedResult, + `${elementData.element} element with form owner attribute` + + `set ${descriptionSuffix}`); + } + }); + }); +}, "Test inheriting values from a form.") + +test(function() { + const testData = [ 'text', + 'search', + 'email', + 'url', + 'tel', + 'number', + 'date', + 'color', + 'password' ]; + + testData.forEach(function(data) { + const form = document.createElement('form'); + form.setAttribute('autocapitalize', 'sentences'); + const input = document.createElement('input'); + input.setAttribute('type', data); + form.appendChild(input); + + assert_equals(input.autocapitalize, 'sentences'); + }); +}, "Verify that even input types that are never autocapitalized support the " ++ "IDL interface.") + +</script> +</body> +</html> diff --git a/testing/web-platform/tests/html/editing/editing-0/contenteditable/contentEditable-invalidvalue.html b/testing/web-platform/tests/html/editing/editing-0/contenteditable/contentEditable-invalidvalue.html new file mode 100644 index 0000000000..b8c17c3a41 --- /dev/null +++ b/testing/web-platform/tests/html/editing/editing-0/contenteditable/contentEditable-invalidvalue.html @@ -0,0 +1,16 @@ +<!DOCTYPE html> +<meta charset=utf-8> +<title>contentEditable setter: invalid value</title> +<link rel="author" title="Denis Ah-Kang" href="mailto:denis@w3.org"> +<link rel=help href="https://html.spec.whatwg.org/multipage/#contenteditable"> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<div id="log"></div> +<script> + var el = document.createElement("div"); + test(function(){ + assert_throws_dom("SyntaxError", function() { + el.contentEditable = "foobar"; + }); + }, "setting contentEditable to an invalid value throws a SyntaxError Exception"); +</script> diff --git a/testing/web-platform/tests/html/editing/editing-0/contenteditable/contentEditable-slotted-inherit.html b/testing/web-platform/tests/html/editing/editing-0/contenteditable/contentEditable-slotted-inherit.html new file mode 100644 index 0000000000..42da515920 --- /dev/null +++ b/testing/web-platform/tests/html/editing/editing-0/contenteditable/contentEditable-slotted-inherit.html @@ -0,0 +1,37 @@ +<!DOCTYPE html> +<meta charset=utf-8> +<title>contentEditable inherit from light tree parent</title> +<link rel="author" title="Rune Lillesveen" href="mailto:futhark@chromium.org"> +<link rel=help href="https://html.spec.whatwg.org/multipage/#contenteditable"> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<p>You should see the word PASS two times below and no FAIL.</p> +<div id="host1" contenteditable><div>FAILPASS</div></div> +<div id="host2" contenteditable><div>FAILPASS</div></div> +<script> + test(() => { + const root = host1.attachShadow({mode:"open"}); + root.innerHTML = "<slot></slot>"; + const text = host1.firstChild.firstChild; + const selection = window.getSelection(); + selection.collapse(text, 0); + selection.extend(text, 4); + host1.focus(); + document.execCommand("delete"); + host1.blur(); + assert_equals(text.data, "PASS", "Text should be PASS after FAIL is deleted"); + }, "Slotted child of contenteditable host should be editable - slot direct child of shadow root"); + + test(() => { + const root = host2.attachShadow({mode:"open"}); + root.innerHTML = "<div><slot></slot></div>"; + const text = host2.firstChild.firstChild; + const selection = window.getSelection(); + selection.collapse(text, 0); + selection.extend(text, 4); + host2.focus(); + document.execCommand("delete"); + host2.blur(); + assert_equals(text.data, "PASS", "Text should be PASS after FAIL is deleted"); + }, "Slotted child of contenteditable host should be editable - slot wrapped in shadow tree ancestor"); +</script> diff --git a/testing/web-platform/tests/html/editing/editing-0/contenteditable/contenteditable-enumerated-ascii-case-insensitive.html b/testing/web-platform/tests/html/editing/editing-0/contenteditable/contenteditable-enumerated-ascii-case-insensitive.html new file mode 100644 index 0000000000..209686680e --- /dev/null +++ b/testing/web-platform/tests/html/editing/editing-0/contenteditable/contenteditable-enumerated-ascii-case-insensitive.html @@ -0,0 +1,24 @@ +<!DOCTYPE html> +<meta charset="utf-8"> +<link rel="help" href="https://html.spec.whatwg.org/#attr-contenteditable"> +<link rel="help" href="https://html.spec.whatwg.org/#enumerated-attribute"> +<meta name="assert" content="@contenteditable values are ASCII case-insensitive"> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<div contenteditable="false"></div> +<div contenteditable="FaLsE"></div> +<div contenteditable="falſe"></div> +<div></div> +<script> +const div = document.querySelectorAll("div"); + +test(() => { + assert_equals(div[0].contentEditable, "false", "lowercase valid"); + assert_equals(div[1].contentEditable, "false", "mixed case valid"); + assert_equals(div[2].contentEditable, "inherit", "non-ASCII invalid"); + + assert_throws_dom("SyntaxError", () => { + div[3].contentEditable = "falſe"; + }, "non-ASCII rejected by IDL"); +}, "keyword false"); +</script> diff --git a/testing/web-platform/tests/html/editing/editing-0/contenteditable/contenteditable-overflow-height-ref.html b/testing/web-platform/tests/html/editing/editing-0/contenteditable/contenteditable-overflow-height-ref.html new file mode 100644 index 0000000000..e88e904f96 --- /dev/null +++ b/testing/web-platform/tests/html/editing/editing-0/contenteditable/contenteditable-overflow-height-ref.html @@ -0,0 +1,9 @@ +<!doctype html> +<title>CSS test reference</title> +<style> + [contenteditable] { + outline: 1px solid black; + outline-offset: -1px; + } +</style> +<div contenteditable></div> diff --git a/testing/web-platform/tests/html/editing/editing-0/contenteditable/contenteditable-overflow-height.html b/testing/web-platform/tests/html/editing/editing-0/contenteditable/contenteditable-overflow-height.html new file mode 100644 index 0000000000..8470b02c2b --- /dev/null +++ b/testing/web-platform/tests/html/editing/editing-0/contenteditable/contenteditable-overflow-height.html @@ -0,0 +1,14 @@ +<!doctype html> +<title>Overflow still allows contenteditable elements to have height</title> +<link rel="author" title="Emilio Cobos Álvarez" href="mailto:emilio@crisal.io"> +<link rel="author" title="Mozilla" href="https://mozilla.org"> +<link rel="help" href="https://bugzilla.mozilla.org/show_bug.cgi?id=1681375"> +<link rel="match" href="contenteditable-overflow-height-ref.html"> +<style> + [contenteditable] { + outline: 1px solid black; + outline-offset: -1px; + overflow: hidden; + } +</style> +<div contenteditable></div> diff --git a/testing/web-platform/tests/html/editing/editing-0/contenteditable/contenteditable-with-empty-block-ref.html b/testing/web-platform/tests/html/editing/editing-0/contenteditable/contenteditable-with-empty-block-ref.html new file mode 100644 index 0000000000..fe68571013 --- /dev/null +++ b/testing/web-platform/tests/html/editing/editing-0/contenteditable/contenteditable-with-empty-block-ref.html @@ -0,0 +1,7 @@ +<!doctype html> +<title>Test reference</title> +<div> + Foo + <div></div> + Bar +</div> diff --git a/testing/web-platform/tests/html/editing/editing-0/contenteditable/contenteditable-with-empty-block.html b/testing/web-platform/tests/html/editing/editing-0/contenteditable/contenteditable-with-empty-block.html new file mode 100644 index 0000000000..7bcc611072 --- /dev/null +++ b/testing/web-platform/tests/html/editing/editing-0/contenteditable/contenteditable-with-empty-block.html @@ -0,0 +1,11 @@ +<!doctype html> +<title>contenteditable doesn't cause inner empty blocks to grow.</title> +<link rel="author" title="Emilio Cobos Álvarez" href="mailto:emilio@crisal.io"> +<link rel="author" title="Mozilla" href="https://mozilla.org"> +<link rel="help" href="https://bugzilla.mozilla.org/show_bug.cgi?id=1628770"> +<link rel="match" href="contenteditable-with-empty-block-ref.html"> +<div contenteditable> + Foo + <div></div> + Bar +</div> diff --git a/testing/web-platform/tests/html/editing/editing-0/contenteditable/selection-in-contentEditable-at-turning-designMode-on-off.tentative.html b/testing/web-platform/tests/html/editing/editing-0/contenteditable/selection-in-contentEditable-at-turning-designMode-on-off.tentative.html new file mode 100644 index 0000000000..4ef9d9003d --- /dev/null +++ b/testing/web-platform/tests/html/editing/editing-0/contenteditable/selection-in-contentEditable-at-turning-designMode-on-off.tentative.html @@ -0,0 +1,31 @@ +<!DOCTYPE html> +<meta charset=utf-8> +<title>selection in contenteditable should not be changed when designMode is turned on/off</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<div id="log"></div> +<iframe srcdoc="<body contenteditable>abc</body>"></iframe> +<script> + const test_load = async_test("Selection in contenteditable shouldn't be reinitialized when changing designMode"); + window.addEventListener("load", test_load.step_func_done(() => { + let iframe = document.querySelector("iframe"); + let iframeSelection = iframe.contentDocument.getSelection(); + iframe.focus(); + iframeSelection.collapse(iframe.contentDocument.body, 1); + function summariseRange(range) { + if (!range) { + return "null"; + } + return `(${range.startContainer.nodeName}, ${range.startOffset}) - (${range.endContainer.nodeName}, ${range.endOffset})`; + } + let maybeNormalizedRangeSummary = summariseRange(iframeSelection.getRangeAt(0)); + assert_in_array(maybeNormalizedRangeSummary, ["(BODY, 1) - (BODY, 1)", "(#text, 3) - (#text, 3)"], + "Selection collapsed at end of <body> can be either as-is or normalized to the end of the text node"); + iframe.contentDocument.designMode = "on"; + assert_equals(summariseRange(iframeSelection.getRangeAt(0)), maybeNormalizedRangeSummary, + "Turning designMode on at load event shouldn't change selection in contenteditable"); + iframe.contentDocument.designMode = "off"; + assert_equals(summariseRange(iframeSelection.getRangeAt(0)), maybeNormalizedRangeSummary, + "Turning designMode off at load event shouldn't change selection in contenteditable"); + })); +</script> diff --git a/testing/web-platform/tests/html/editing/editing-0/contenteditable/user-interaction-editing-contenteditable.html b/testing/web-platform/tests/html/editing/editing-0/contenteditable/user-interaction-editing-contenteditable.html new file mode 100644 index 0000000000..2e51109fa7 --- /dev/null +++ b/testing/web-platform/tests/html/editing/editing-0/contenteditable/user-interaction-editing-contenteditable.html @@ -0,0 +1,58 @@ +<!DOCTYPE html> +<html> + <head> + <title>Editing: contentEditable attribute test</title> + <link rel="author" title="Baidu" href="mailto: guopengcheng@baidu.com" /> + <link + rel="help" + href="https://html.spec.whatwg.org/multipage/#contenteditable" + /> + <script src="/resources/testharness.js"></script> + <script src="/resources/testharnessreport.js"></script> + <div id="log"></div> + </head> + <body> + <script> + function testContentEditable(variationFunc, title, expectIsContentEditable, expectContentEditable) { + test(() => { + const div = document.createElement("div"); + variationFunc(div); + assert_equals(div.isContentEditable, expectIsContentEditable, 'isContentEditable'); + assert_equals(div.contentEditable, expectContentEditable, 'contentEditable'); + }, title); + } + + testContentEditable(el => { + }, "no contenteditable attribute", false, "inherit"); + + testContentEditable(el => { + el.setAttribute("contenteditable", ""); + }, "empty contentEditable attribute", true, "true"); + + testContentEditable(el => { + el.contentEditable = "true"; + }, 'set contentEditable = "true"', true, "true"); + + testContentEditable(el => { + el.contentEditable = "false"; + }, 'set contentEditable = "false"', false, "false"); + + testContentEditable(el => { + const parent = document.createElement("div"); + parent.appendChild(el); + parent.contentEditable = "true"; + }, 'set parent element contentEditable = "true"', true, "inherit"); + + testContentEditable(el => { + const parent = document.createElement("div"); + parent.appendChild(el); + parent.contentEditable = "false"; + }, 'set parent element contentEditable = "false"', false, "inherit"); + + testContentEditable(el => { + el.contentEditable = "true"; + el.removeAttribute("contenteditable"); + }, 'set contentEditable = "true" and then remove contenteditable attribute', false, "inherit"); + </script> + </body> +</html> diff --git a/testing/web-platform/tests/html/editing/editing-0/making-entire-documents-editable-the-designmode-idl-attribute/original-id.json b/testing/web-platform/tests/html/editing/editing-0/making-entire-documents-editable-the-designmode-idl-attribute/original-id.json new file mode 100644 index 0000000000..8b7c4b838c --- /dev/null +++ b/testing/web-platform/tests/html/editing/editing-0/making-entire-documents-editable-the-designmode-idl-attribute/original-id.json @@ -0,0 +1 @@ +{"original_id":"making-entire-documents-editable:-the-designmode-idl-attribute"}
\ No newline at end of file diff --git a/testing/web-platform/tests/html/editing/editing-0/making-entire-documents-editable-the-designmode-idl-attribute/user-interaction-editing-designMode-svg.svg b/testing/web-platform/tests/html/editing/editing-0/making-entire-documents-editable-the-designmode-idl-attribute/user-interaction-editing-designMode-svg.svg new file mode 100644 index 0000000000..fd2fde0fbe --- /dev/null +++ b/testing/web-platform/tests/html/editing/editing-0/making-entire-documents-editable-the-designmode-idl-attribute/user-interaction-editing-designMode-svg.svg @@ -0,0 +1,34 @@ +<?xml version="1.0" encoding="utf-8"?> +<svg:svg xmlns:svg="http://www.w3.org/2000/svg" + xmlns="http://www.w3.org/1999/xhtml" + width="100%" height="100%" viewBox="0 0 800 600"> + <svg:title>Editing: designMode attribute test</svg:title> + <head> + <link rel="author" title="Baidu" href="mailto: guopengcheng@baidu.com"/> + <link rel="help" href="https://html.spec.whatwg.org/multipage/#making-entire-documents-editable:-the-designmode-idl-attribute"/> + <script src="/resources/testharness.js"></script> + <script src="/resources/testharnessreport.js"></script> + <div id="log"></div> + </head> + <body> + <script type="text/javascript"><![CDATA[ + test(function() { + assert_equals(document.designMode, "off", "check for designMode value"); + assert_throws_dom("InvalidStateError", function() { document.queryCommandSupported("delete") }); + assert_throws_dom("InvalidStateError", function() { document.queryCommandEnabled("delete") }); + }, "initial designMode attribute"); + document.designMode="on"; + test(function() { + assert_equals(document.designMode, "on", "check for designMode value"); + assert_throws_dom("InvalidStateError", function() { document.queryCommandSupported("delete") }); + assert_throws_dom("InvalidStateError", function() { document.queryCommandEnabled("delete") }); + }, "set designMode = \"on\""); + document.designMode="off"; + test(function() { + assert_equals(document.designMode,"off", "check for designMode value"); + assert_throws_dom("InvalidStateError", function() { document.queryCommandSupported("delete") }); + assert_throws_dom("InvalidStateError", function() { document.queryCommandEnabled("delete") }); + }, "set designMode = \"off\""); + ]]></script> + </body> +</svg:svg> diff --git a/testing/web-platform/tests/html/editing/editing-0/making-entire-documents-editable-the-designmode-idl-attribute/user-interaction-editing-designMode-xml.xml b/testing/web-platform/tests/html/editing/editing-0/making-entire-documents-editable-the-designmode-idl-attribute/user-interaction-editing-designMode-xml.xml new file mode 100644 index 0000000000..f26cd56453 --- /dev/null +++ b/testing/web-platform/tests/html/editing/editing-0/making-entire-documents-editable-the-designmode-idl-attribute/user-interaction-editing-designMode-xml.xml @@ -0,0 +1,32 @@ +<?xml version="1.0" encoding="utf-8"?> +<html xmlns="http://www.w3.org/1999/xhtml"> + <head> + <title>Editing: designMode attribute test</title> + <link rel="author" title="Baidu" href="mailto: guopengcheng@baidu.com"/> + <link rel="help" href="https://html.spec.whatwg.org/multipage/#making-entire-documents-editable:-the-designmode-idl-attribute"/> + <script src="/resources/testharness.js"></script> + <script src="/resources/testharnessreport.js"></script> + <div id="log"></div> + </head> + <body> + <script type="text/javascript"><![CDATA[ + test(function() { + assert_equals(document.designMode, "off", "check for designMode value"); + assert_throws_dom("InvalidStateError", function() { document.queryCommandSupported("delete") }); + assert_throws_dom("InvalidStateError", function() { document.queryCommandEnabled("delete") }); + }, "initial designMode attribute"); + document.designMode="on"; + test(function() { + assert_equals(document.designMode, "on", "check for designMode value"); + assert_throws_dom("InvalidStateError", function() { document.queryCommandSupported("delete") }); + assert_throws_dom("InvalidStateError", function() { document.queryCommandEnabled("delete") }); + }, "set designMode = \"on\""); + document.designMode="off"; + test(function() { + assert_equals(document.designMode,"off", "check for designMode value"); + assert_throws_dom("InvalidStateError", function() { document.queryCommandSupported("delete") }); + assert_throws_dom("InvalidStateError", function() { document.queryCommandEnabled("delete") }); + }, "set designMode = \"off\""); + ]]></script> + </body> +</html> diff --git a/testing/web-platform/tests/html/editing/editing-0/making-entire-documents-editable-the-designmode-idl-attribute/user-interaction-editing-designMode.html b/testing/web-platform/tests/html/editing/editing-0/making-entire-documents-editable-the-designmode-idl-attribute/user-interaction-editing-designMode.html new file mode 100644 index 0000000000..79d2dc8ba0 --- /dev/null +++ b/testing/web-platform/tests/html/editing/editing-0/making-entire-documents-editable-the-designmode-idl-attribute/user-interaction-editing-designMode.html @@ -0,0 +1,32 @@ +<!DOCTYPE html> +<html> + <head> + <title>Editing: designMode attribute test</title> + <link rel="author" title="Baidu" href="mailto: guopengcheng@baidu.com"/> + <link rel="help" href="https://html.spec.whatwg.org/multipage/#making-entire-documents-editable:-the-designmode-idl-attribute"/> + <script src="/resources/testharness.js"></script> + <script src="/resources/testharnessreport.js"></script> + <div id="log"></div> + </head> + <body> + <script type="text/javascript"> + test(function() { + assert_equals(document.designMode, "off", "check for designMode value"); + assert_true(document.queryCommandSupported("delete")); + assert_false(document.queryCommandEnabled("delete")); + }, "initial designMode attribute"); + document.designMode="on"; + test(function() { + assert_equals(document.designMode, "on", "check for designMode value"); + assert_true(document.queryCommandSupported("delete")); + assert_true(document.queryCommandEnabled("delete")); + }, "set designMode = \"on\""); + document.designMode="off"; + test(function() { + assert_equals(document.designMode,"off", "check for designMode value"); + assert_true(document.queryCommandSupported("delete")); + assert_false(document.queryCommandEnabled("delete")); + }, "set designMode = \"off\""); + </script> + </body> +</html> 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> |