summaryrefslogtreecommitdiffstats
path: root/layout/generic/test/test_bug1642588.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 /layout/generic/test/test_bug1642588.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 'layout/generic/test/test_bug1642588.html')
-rw-r--r--layout/generic/test/test_bug1642588.html70
1 files changed, 70 insertions, 0 deletions
diff --git a/layout/generic/test/test_bug1642588.html b/layout/generic/test/test_bug1642588.html
new file mode 100644
index 0000000000..56ebc6fc1e
--- /dev/null
+++ b/layout/generic/test/test_bug1642588.html
@@ -0,0 +1,70 @@
+<!DOCTYPE html>
+<title>Test for Bug 1642588</title>
+<script src="/tests/SimpleTest/SimpleTest.js"></script>
+<script src="/tests/SimpleTest/EventUtils.js"></script>
+<link rel="stylesheet" href="/tests/SimpleTest/test.css">
+<style>
+ [contenteditable] {
+ padding: .5em 40%;
+ }
+</style>
+
+<div>
+ <p>
+ Intentionally not in WPT as triple click is not guaranteed to have same
+ behavior on every browser.
+ </p>
+ <span contenteditable></span><hr>
+ <div contenteditable style="display: inline;"></div><hr>
+ <div contenteditable style="display: inline-block;"></div><hr>
+ <!--
+ FIXME: https://bugzilla.mozilla.org/show_bug.cgi?id=1654364
+ <table contenteditable style="display: inline-table;"><tr><td></table><hr>
+ -->
+ <div contenteditable style="display: inline-flex;"></div><hr>
+ <div contenteditable style="display: inline-grid;"></div>
+</div>
+
+<script>
+function selectHostByClicks(host, number) {
+ for (let i = 1; i <= number; i++) {
+ synthesizeMouseAtCenter(host, { clickCount: i });
+ }
+}
+
+function nonCollapsedDeletionTest(host, clickCount) {
+ host.textContent = "contenteditable";
+ selectHostByClicks(host, clickCount);
+ const selection = getSelection();
+
+ is(selection.isCollapsed, false, "Noncollapsed selection should occur");
+
+ synthesizeKey("KEY_Backspace");
+ is(
+ host.textContent,
+ "",
+ `Backspace should delete the content of the editing host (<div contenteditable style="${
+ host.getAttribute("style")
+ }">)`);
+}
+
+function collapsedSelectionTest(host, clickCount) {
+ host.textContent = "";
+ selectHostByClicks(host, clickCount);
+ const selection = getSelection();
+
+ is(selection.isCollapsed, true, "Collapsed selection should occur");
+ is(selection.anchorNode, host, "Caret should be in host");
+}
+
+SimpleTest.waitForExplicitFinish();
+SimpleTest.waitForFocus(() => {
+ const hosts = document.querySelectorAll("[contenteditable]");
+ for (const host of hosts) {
+ nonCollapsedDeletionTest(host, 2);
+ nonCollapsedDeletionTest(host, 3);
+ collapsedSelectionTest(host, 3);
+ }
+ SimpleTest.finish();
+});
+</script>