diff options
Diffstat (limited to 'testing/web-platform/tests/html/editing/editing-0/contenteditable/selection-in-contentEditable-at-turning-designMode-on-off.tentative.html')
-rw-r--r-- | testing/web-platform/tests/html/editing/editing-0/contenteditable/selection-in-contentEditable-at-turning-designMode-on-off.tentative.html | 31 |
1 files changed, 31 insertions, 0 deletions
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> |