diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 17:32:43 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 17:32:43 +0000 |
commit | 6bf0a5cb5034a7e684dcc3500e841785237ce2dd (patch) | |
tree | a68f146d7fa01f0134297619fbe7e33db084e0aa /editor/libeditor/tests/test_abs_positioner_hidden_during_dragging.html | |
parent | Initial commit. (diff) | |
download | thunderbird-upstream.tar.xz thunderbird-upstream.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 'editor/libeditor/tests/test_abs_positioner_hidden_during_dragging.html')
-rw-r--r-- | editor/libeditor/tests/test_abs_positioner_hidden_during_dragging.html | 102 |
1 files changed, 102 insertions, 0 deletions
diff --git a/editor/libeditor/tests/test_abs_positioner_hidden_during_dragging.html b/editor/libeditor/tests/test_abs_positioner_hidden_during_dragging.html new file mode 100644 index 0000000000..3badd4c3b3 --- /dev/null +++ b/editor/libeditor/tests/test_abs_positioner_hidden_during_dragging.html @@ -0,0 +1,102 @@ +<!DOCTYPE html> +<meta charset="utf-8" /> +<title>Drag absolutely positioned element to crash</title> +<script src="/tests/SimpleTest/SimpleTest.js"></script> +<script src="/tests/SimpleTest/EventUtils.js"></script> +<link rel="stylesheet" href="/tests/SimpleTest/test.css"/> +<div + contenteditable + style=" + border: blue 1px solid; + margin: 20px; + " +> + <div + style=" + border: red 1px dashed; + background-color: rgba(255, 0, 0, 0.3); + position: absolute; + width: 100px; + height: 100px; + overflow: auto; + " + > + This is absolutely positioned element. + </div> + <p>This is static positioned paragraph #1</p> + <p>This is static positioned paragraph #2</p> + <p>This is static positioned paragraph #3</p> + <p>This is static positioned paragraph #4</p> + <p>This is static positioned paragraph #5</p> + <p>This is static positioned paragraph #6</p> + <p>This is static positioned paragraph #7</p> +</div> +<script> +"use strict"; + +document.execCommand("enableAbsolutePositionEditing", false, true); + +SimpleTest.waitForExplicitFinish(); +SimpleTest.waitForFocus(async () => { + disableNonTestMouseEvents(true); + try { + document.querySelector("div[contenteditable").focus(); + + function promiseSelectionChange() { + return new Promise(resolve => { + document.addEventListener("selectionchange", () => { + resolve(); + }, {once: true}); + }); + } + + let absContainer = document.querySelector("div > div"); + let rect = absContainer.getBoundingClientRect(); + // We still don't have a way to retrieve the grabber. Therefore, we need + // to compute a point in the grabber from the absolutely positioned + // element's top-left coordinates. + const kOffsetX = 18; + const kOffsetY = -7; + let waitForSelectionChange = promiseSelectionChange(); + synthesizeMouseAtCenter(absContainer, {}); + await waitForSelectionChange; + synthesizeMouse(absContainer, kOffsetX, kOffsetY, {type: "mousedown"}); + ok(absContainer.hasAttribute("_moz_abspos"), "Mousedown on the grabber should make it in drag mode"); + synthesizeMouseAtPoint(100, 100, {type: "mousemove"}); + synthesizeMouseAtPoint(100, 100, {type: "mouseup"}); + isnot(absContainer.getBoundingClientRect().x, rect.x, + "The absolutely positioned container should be moved along x-axis"); + isnot(absContainer.getBoundingClientRect().y, rect.y, + "The absolutely positioned container should be moved along y-axis"); + + rect = absContainer.getBoundingClientRect(); + synthesizeMouse(absContainer, kOffsetX, kOffsetY, {type: "mousedown"}); + ok(absContainer.hasAttribute("_moz_abspos"), "Mousedown on the grabber should make it in drag mode again"); + document.execCommand("enableAbsolutePositionEditing", false, false); + ok(!absContainer.hasAttribute("_moz_abspos"), "Disabling the grabber makes it not in drag mode (before mouse move)"); + synthesizeMouseAtPoint(50, 50, {type: "mousemove"}); + synthesizeMouseAtPoint(50, 50, {type: "mouseup"}); + is(absContainer.getBoundingClientRect().x, rect.x, + "The absolutely positioned container shouldn't be moved along x-axis due to the UI is killed by the web app (before mouse move)"); + is(absContainer.getBoundingClientRect().y, rect.y, + "The absolutely positioned container shouldn't be moved along y-axis due to the UI is killed by the web app (before mouse move)"); + document.execCommand("enableAbsolutePositionEditing", false, true); + + rect = absContainer.getBoundingClientRect(); + synthesizeMouse(absContainer, kOffsetX, kOffsetY, {type: "mousedown"}); + ok(absContainer.hasAttribute("_moz_abspos"), "Mousedown on the grabber should make it in drag mode again"); + document.execCommand("enableAbsolutePositionEditing", false, false); + synthesizeMouseAtPoint(50, 50, {type: "mousemove"}); + ok(!absContainer.hasAttribute("_moz_abspos"), "Disabling the grabber makes it not in drag mode (during mouse move)"); + synthesizeMouseAtPoint(50, 50, {type: "mousemove"}); + synthesizeMouseAtPoint(50, 50, {type: "mouseup"}); + is(absContainer.getBoundingClientRect().x, rect.x, + "The absolutely positioned container shouldn't be moved along x-axis due to the UI is killed by the web app (during mouse move)"); + is(absContainer.getBoundingClientRect().y, rect.y, + "The absolutely positioned container shouldn't be moved along y-axis due to the UI is killed by the web app (during mouse move)"); + } finally { + disableNonTestMouseEvents(false); + SimpleTest.finish(); + } +}); +</script> |