summaryrefslogtreecommitdiffstats
path: root/layout/generic/test/test_selection_tripleclick.html
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 17:32:43 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 17:32:43 +0000
commit6bf0a5cb5034a7e684dcc3500e841785237ce2dd (patch)
treea68f146d7fa01f0134297619fbe7e33db084e0aa /layout/generic/test/test_selection_tripleclick.html
parentInitial commit. (diff)
downloadthunderbird-6bf0a5cb5034a7e684dcc3500e841785237ce2dd.tar.xz
thunderbird-6bf0a5cb5034a7e684dcc3500e841785237ce2dd.zip
Adding upstream version 1:115.7.0.upstream/1%115.7.0upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'layout/generic/test/test_selection_tripleclick.html')
-rw-r--r--layout/generic/test/test_selection_tripleclick.html63
1 files changed, 63 insertions, 0 deletions
diff --git a/layout/generic/test/test_selection_tripleclick.html b/layout/generic/test/test_selection_tripleclick.html
new file mode 100644
index 0000000000..a912eb4686
--- /dev/null
+++ b/layout/generic/test/test_selection_tripleclick.html
@@ -0,0 +1,63 @@
+<!DOCTYPE>
+<title>Selection test</title>
+<script src="/tests/SimpleTest/SimpleTest.js"></script>
+<script src="/tests/SimpleTest/EventUtils.js"></script>
+<style>
+ body { margin: 0; font: 16px/1 sans-serif; }
+ code { display: inline-block }
+</style>
+<p id="a">Some <code>code</code> with <span>text</span> with <code>code</code> in it</p>
+
+<p id="b">Here's <span>some</span> <code><span>code</span><br><span>broken</span></code> with <span>text</span> with <code><span>code</span><br><span>broken</span></code> in <span>it and such</span> and so on</p>
+
+<pre id="c">Here's some text and
+some <span>more</span> code <span>with</span> pre-formatted
+whitespace <span>that</span> should be selected
+line <span>by</span> line</pre>
+
+<script>
+ SimpleTest.waitForExplicitFinish();
+
+ function testTripleClick(elem, expectation) {
+ window.getSelection().removeAllRanges();
+ synthesizeMouse(elem, 5, 5, { clickCount: 3 });
+ is(window.getSelection().toString(), expectation);
+ }
+
+ SimpleTest.waitForFocus(function () {
+ for (let child of document.querySelectorAll("#a span, #a code"))
+ testTripleClick(child, "Some code with text with code in it");
+
+ {
+ let spans = document.querySelectorAll("#b span");
+ let expectations = [
+ "Here's some code", // First span, at the beginning of the text.
+ "Here's some code", // Top span in the inline-block, before break.
+ "broken with text with code", // Bottom span in inline-block, after break
+ "broken with text with code", // Center of the text.
+ "broken with text with code", // Top span in the second inline-block, before break.
+ "broken in it and such and so on", // Bottom span in the second inline-block, after break.
+ "broken in it and such and so on", // Last span, at the end of the text.
+ ];
+ is(spans.length, expectations.length);
+ for (let i = 0; i < expectations.length; ++i)
+ testTripleClick(spans[i], expectations[i]);
+ }
+
+ {
+ testTripleClick(document.getElementById("c"), "Here's some text and");
+ let spans = document.querySelectorAll("#c span");
+ let expectations = [
+ "some more code with pre-formatted",
+ "some more code with pre-formatted",
+ "whitespace that should be selected",
+ "line by line",
+ ];
+ is(spans.length, expectations.length);
+ for (let i = 0; i < expectations.length; ++i)
+ testTripleClick(spans[i], expectations[i]);
+ }
+
+ SimpleTest.finish();
+ });
+</script>