summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/css/css-pseudo/text-selection.html
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-19 00:47:55 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-19 00:47:55 +0000
commit26a029d407be480d791972afb5975cf62c9360a6 (patch)
treef435a8308119effd964b339f76abb83a57c29483 /testing/web-platform/tests/css/css-pseudo/text-selection.html
parentInitial commit. (diff)
downloadfirefox-26a029d407be480d791972afb5975cf62c9360a6.tar.xz
firefox-26a029d407be480d791972afb5975cf62c9360a6.zip
Adding upstream version 124.0.1.upstream/124.0.1
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'testing/web-platform/tests/css/css-pseudo/text-selection.html')
-rw-r--r--testing/web-platform/tests/css/css-pseudo/text-selection.html87
1 files changed, 87 insertions, 0 deletions
diff --git a/testing/web-platform/tests/css/css-pseudo/text-selection.html b/testing/web-platform/tests/css/css-pseudo/text-selection.html
new file mode 100644
index 0000000000..42acd0aa52
--- /dev/null
+++ b/testing/web-platform/tests/css/css-pseudo/text-selection.html
@@ -0,0 +1,87 @@
+<!DOCTYPE html>
+<meta charset="utf-8">
+<title>CSS Pseudo-Elements Test: Text selection</title>
+<link rel="help" href="https://drafts.csswg.org/css-pseudo-4/#treelike">
+<link rel="help" href="https://drafts.csswg.org/css-ui/#user-interaction">
+<link rel="author" title="Oriol Brufau" href="mailto:obrufau@igalia.com">
+<meta name="assert" content="This test checks that text in a ::before or ::marker pseudo-element can't be selected." />
+<link rel="stylesheet" type="text/css" href="/fonts/ahem.css" />
+<style>
+.test {
+ font: 10px/1 Ahem;
+ margin-left: 200px;
+}
+#before::before {
+ content: "::before";
+ display: inline-block;
+ margin-left: -80px;
+}
+#marker {
+ display: list-item;
+ list-style-type: "::marker";
+}
+#before-marker::before {
+ content: "";
+ display: list-item;
+ list-style-type: "::marker";
+ height: 0;
+}
+</style>
+<div class="test" id="before"><span>helloworld</span></div>
+<div class="test" id="marker"><span>helloworld</span></div>
+<div class="test" id="before-marker"><span>helloworld</span></div>
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<script src="/resources/testdriver.js"></script>
+<script src="/resources/testdriver-actions.js"></script>
+<script src="/resources/testdriver-vendor.js"></script>
+<script>
+function createSelection(element, start, end, step) {
+ getSelection().empty();
+ step = Math.abs(step);
+ const actions = new test_driver.Actions();
+ actions.pointerMove(start, 0, {origin: element});
+ actions.pointerDown();
+ if (start < end) {
+ for (let x = start + step; x < end; x += step)
+ actions.pointerMove(x, 0, {origin: element});
+ } else {
+ for (let x = start - step; x > end; x -= step)
+ actions.pointerMove(x, 0, {origin: element});
+ }
+ actions.pointerMove(end, 0, {origin: element});
+ actions.pointerUp();
+ return actions.send();
+}
+(async function() {
+ setup({ explicit_done: true });
+ for (let target of document.querySelectorAll(".test")) {
+ const contents = target.querySelector("span");
+ const text = contents.firstChild;
+ const s = getSelection();
+
+ // Create a selection that starts in the middle of the element contents
+ // and ends in the middle of the pseudo-element
+ await createSelection(contents, 0, -90, 10);
+ test(function(t) {
+ assert_equals(s.toString(), "hello", "toString");
+ assert_equals(s.anchorNode, text, "anchorNode");
+ assert_equals(s.anchorOffset, 5, "anchorOffset");
+ assert_equals(s.focusNode, text, "focusNode");
+ assert_equals(s.focusOffset, 0, "focusOffset");
+ }, "Selection ending in ::" + target.id);
+
+ // Create a selection that starts and ends inside the pseudo-element.
+ await createSelection(contents, -80, -110, 10);
+ test(function(t) {
+ assert_equals(s.toString(), "", "toString");
+ assert_in_array(s.anchorNode, [text, null], "anchorNode");
+ assert_equals(s.anchorOffset, 0, "anchorOffset");
+ assert_in_array(s.focusNode, [text, null], "focusNode");
+ assert_equals(s.focusOffset, 0, "focusOffset");
+ }, "Selection contained in ::" + target.id);
+ }
+ done();
+})();
+</script>
+