diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 19:33:14 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 19:33:14 +0000 |
commit | 36d22d82aa202bb199967e9512281e9a53db42c9 (patch) | |
tree | 105e8c98ddea1c1e4784a60a5a6410fa416be2de /dom/html/test/test_bug406596.html | |
parent | Initial commit. (diff) | |
download | firefox-esr-36d22d82aa202bb199967e9512281e9a53db42c9.tar.xz firefox-esr-36d22d82aa202bb199967e9512281e9a53db42c9.zip |
Adding upstream version 115.7.0esr.upstream/115.7.0esrupstream
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.html | 83 |
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> |