summaryrefslogtreecommitdiffstats
path: root/dom/html/test/test_bug406596.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 /dom/html/test/test_bug406596.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 'dom/html/test/test_bug406596.html')
-rw-r--r--dom/html/test/test_bug406596.html83
1 files changed, 83 insertions, 0 deletions
diff --git a/dom/html/test/test_bug406596.html b/dom/html/test/test_bug406596.html
new file mode 100644
index 0000000000..6886d078be
--- /dev/null
+++ b/dom/html/test/test_bug406596.html
@@ -0,0 +1,83 @@
+<!DOCTYPE HTML>
+<html>
+<!--
+https://bugzilla.mozilla.org/show_bug.cgi?id=406596
+-->
+<head>
+ <title>Test for Bug 406596</title>
+ <script src="/tests/SimpleTest/SimpleTest.js"></script>
+ <script src="/tests/SimpleTest/EventUtils.js"></script>
+ <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
+</head>
+<body>
+<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=406596">Mozilla Bug 406596</a>
+<div id="content">
+ <div id="edit" contenteditable="true">This text is editable, you can change its content <a href="#" id="a" tabindex="0">ABCDEFGHIJKLMNOPQRSTUV</a> <input type="submit" value="abcd" id="b"></input> <img src="foo.png" id="c"></div>
+ <div tabindex="0">This text is not editable but is focusable</div>
+ <div tabindex="0">This text is not editable but is focusable</div>
+ <a href="#" id="d" contenteditable="true">ABCDEFGHIJKLMNOPQRSTUV</a>
+ <div tabindex="0">This text is not editable but is focusable</div>
+ <div tabindex="0">This text is not editable but is focusable</div>
+</div>
+<pre id="test">
+<script class="testbody" type="text/javascript">
+
+/** Test for Bug 406596 **/
+
+function testTabbing(click, focus, selectionOffset) {
+ var wu = SpecialPowers.getDOMWindowUtils(window);
+
+ var elem = document.getElementById(click);
+ var rect = elem.getBoundingClientRect();
+ var selection = window.getSelection();
+
+ var x = (rect.left + rect.right) / 4;
+ var y = (rect.top + rect.bottom) / 2;
+ wu.sendMouseEvent("mousedown", x, y, 0, 1, 0);
+ wu.sendMouseEvent("mousemove", x + selectionOffset, y, 0, 1, 0);
+ wu.sendMouseEvent("mouseup", x + selectionOffset, y, 0, 1, 0);
+ if (selectionOffset) {
+ is(selection.rangeCount, 1, "there should be one range in the selection");
+ var range = selection.getRangeAt(0);
+ }
+ var focusedElement = document.activeElement;
+ is(focusedElement, document.getElementById(focus),
+ "clicking should move focus to the contentEditable node");
+ synthesizeKey("KEY_Tab");
+ synthesizeKey("KEY_Tab");
+ synthesizeKey("KEY_Tab", {shiftKey: true});
+ synthesizeKey("KEY_Tab", {shiftKey: true});
+ is(document.activeElement, focusedElement,
+ "tab/shift-tab should move focus back to the contentEditable node");
+ if (selectionOffset) {
+ is(selection.rangeCount, 1,
+ "there should still be one range in the selection");
+ var newRange = selection.getRangeAt(0);
+ is(newRange.compareBoundaryPoints(Range.START_TO_START, range), 0,
+ "the selection should be the same as before the tabbing");
+ is(newRange.compareBoundaryPoints(Range.END_TO_END, range), 0,
+ "the selection should be the same as before the tabbing");
+ }
+}
+
+function test() {
+ window.getSelection().removeAllRanges();
+ testTabbing("edit", "edit", 0);
+ testTabbing("a", "edit", 0);
+ testTabbing("d", "d", 0);
+ testTabbing("edit", "edit", 10);
+ testTabbing("a", "edit", 10);
+ testTabbing("d", "d", 10);
+
+ SimpleTest.finish();
+}
+
+window.onload = function() {
+ SimpleTest.waitForExplicitFinish();
+ setTimeout(test, 0);
+};
+
+</script>
+</pre>
+</body>
+</html>