summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/selection/contenteditable/cefalse-on-boundaries.html
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 09:22:09 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 09:22:09 +0000
commit43a97878ce14b72f0981164f87f2e35e14151312 (patch)
tree620249daf56c0258faa40cbdcf9cfba06de2a846 /testing/web-platform/tests/selection/contenteditable/cefalse-on-boundaries.html
parentInitial commit. (diff)
downloadfirefox-43a97878ce14b72f0981164f87f2e35e14151312.tar.xz
firefox-43a97878ce14b72f0981164f87f2e35e14151312.zip
Adding upstream version 110.0.1.upstream/110.0.1upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'testing/web-platform/tests/selection/contenteditable/cefalse-on-boundaries.html')
-rw-r--r--testing/web-platform/tests/selection/contenteditable/cefalse-on-boundaries.html72
1 files changed, 72 insertions, 0 deletions
diff --git a/testing/web-platform/tests/selection/contenteditable/cefalse-on-boundaries.html b/testing/web-platform/tests/selection/contenteditable/cefalse-on-boundaries.html
new file mode 100644
index 0000000000..945058dfc3
--- /dev/null
+++ b/testing/web-platform/tests/selection/contenteditable/cefalse-on-boundaries.html
@@ -0,0 +1,72 @@
+<!DOCTYPE HTML>
+<meta charset=utf-8>
+<title>Selection of contenteditable=false at the beginning and end of contenteditable element</title>
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<div contenteditable id="host">
+ <div contenteditable="false" id="beginning">&nbsp;</div>
+ <p id="paragraph">Lorem ipsum dolor sit amet.</p>
+ <div contenteditable="false" id="end">&nbsp;</div>
+</div>
+<script>
+test( () => {
+ const range = document.createRange();
+
+ range.setStartBefore( beginning );
+ range.setEndAfter( paragraph );
+ getSelection().removeAllRanges();
+ getSelection().addRange( range );
+
+ const selectedRange = getSelection().getRangeAt( 0 );
+
+ assert_equals( selectedRange.startContainer, host );
+ assert_equals( selectedRange.startOffset, 1 );
+ assert_equals( selectedRange.endContainer, host );
+ assert_equals( selectedRange.endOffset, 4 );
+}, 'Selection can start on cE=false element at the beginning of the cE=true element' );
+
+test( () => {
+ const range = document.createRange();
+
+ range.setStartBefore( paragraph );
+ range.setEndAfter( end );
+ getSelection().removeAllRanges();
+ getSelection().addRange( range );
+
+ const selectedRange = getSelection().getRangeAt( 0 );
+
+ assert_equals( selectedRange.startContainer, host );
+ assert_equals( selectedRange.startOffset, 3 );
+ assert_equals( selectedRange.endContainer, host );
+ assert_equals( selectedRange.endOffset, 6 );
+}, 'Selection can end on cE=false element at the end of the cE=true element' );
+
+test( () => {
+ const range = document.createRange();
+
+ range.setStartBefore( beginning );
+ range.setEndAfter( end );
+ getSelection().removeAllRanges();
+ getSelection().addRange( range );
+
+ const selectedRange = getSelection().getRangeAt( 0 );
+
+ assert_equals( selectedRange.startContainer, host );
+ assert_equals( selectedRange.startOffset, 1 );
+ assert_equals( selectedRange.endContainer, host );
+ assert_equals( selectedRange.endOffset, 6 );
+}, 'Selection can start and end on cE=false elements at the boundaries of cE=true element' );
+
+test( () => {
+ const range = document.createRange();
+
+ range.selectNodeContents( host );
+
+ const selectedRange = getSelection().getRangeAt( 0 );
+
+ assert_equals( selectedRange.startContainer, host );
+ assert_equals( selectedRange.startOffset, 1 );
+ assert_equals( selectedRange.endContainer, host );
+ assert_equals( selectedRange.endOffset, 6 );
+}, 'Range#selectNodeContents() correctly select contents of cE=true element with cE=false elements on boundaries' );
+</script>