diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-21 11:44:51 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-21 11:44:51 +0000 |
commit | 9e3c08db40b8916968b9f30096c7be3f00ce9647 (patch) | |
tree | a68f146d7fa01f0134297619fbe7e33db084e0aa /editor/libeditor/tests/test_bug629172.html | |
parent | Initial commit. (diff) | |
download | thunderbird-9e3c08db40b8916968b9f30096c7be3f00ce9647.tar.xz thunderbird-9e3c08db40b8916968b9f30096c7be3f00ce9647.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_bug629172.html')
-rw-r--r-- | editor/libeditor/tests/test_bug629172.html | 105 |
1 files changed, 105 insertions, 0 deletions
diff --git a/editor/libeditor/tests/test_bug629172.html b/editor/libeditor/tests/test_bug629172.html new file mode 100644 index 0000000000..55d1ed89b6 --- /dev/null +++ b/editor/libeditor/tests/test_bug629172.html @@ -0,0 +1,105 @@ +<!DOCTYPE HTML> +<html> +<!-- +https://bugzilla.mozilla.org/show_bug.cgi?id=629172 +--> +<head> + <title>Test for Bug 629172</title> + <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script> + <script type="text/javascript" src="/tests/SimpleTest/EventUtils.js"></script> + <script type="text/javascript" src="/tests/SimpleTest/WindowSnapshot.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=629172">Mozilla Bug 629172</a> +<p id="display"></p> +<div id="content"> +<textarea id="ltr-ref">test.</textarea> +<textarea id="rtl-ref" style="display: none; direction: rtl">test.</textarea> +</div> +<pre id="test"> +<script> + +/** Test for Bug 629172 **/ +SimpleTest.waitForExplicitFinish(); +SimpleTest.waitForFocus(async function() { + await SpecialPowers.pushPrefEnv({ + set: [["test.events.async.enabled", true]], + }); + + let LTRRef = document.getElementById("ltr-ref"); + let RTLRef = document.getElementById("rtl-ref"); + let ReferenceScreenshots = {}; + + // generate the reference screenshots + document.body.clientWidth; + ReferenceScreenshots.ltr = snapshotWindow(window); + LTRRef.remove(); + RTLRef.style.display = ""; + document.body.clientWidth; + ReferenceScreenshots.rtl = snapshotWindow(window); + RTLRef.remove(); + + async function testDirection(initialDir) { + function revertDir(aDir) { + return aDir == "rtl" ? "ltr" : "rtl"; + } + + function promiseFormatSetBlockTextDirectionInputEvent(aElement) { + return new Promise(resolve => { + function handler(aEvent) { + if (aEvent.inputType !== "formatSetBlockTextDirection") { + ok(false, `Unexpected input event received: inputType="${aEvent.inputType}"`); + } else { + aElement.removeEventListener("input", handler, true); + SimpleTest.executeSoon(resolve); + } + } + aElement.addEventListener("input", handler, true); + }); + } + + let textarea = document.createElement("textarea"); + textarea.setAttribute("dir", initialDir); + textarea.value = "test."; + document.getElementById("content").appendChild(textarea); + document.body.clientWidth; + assertSnapshots(snapshotWindow(window), ReferenceScreenshots[initialDir], + /* expectEqual = */ true, /* fuzz = */ null, + `<textarea dir="${initialDir}"> before Accel+Shift+X`, + `<textarea dir="${initialDir}">`); + textarea.focus(); + let waitForInputEvent = promiseFormatSetBlockTextDirectionInputEvent(textarea); + synthesizeKey("X", {accelKey: true, shiftKey: true}); + await waitForInputEvent; + is(textarea.getAttribute("dir"), revertDir(initialDir), + "The dir attribute must be correctly updated with first Accel+Shift+X"); + textarea.blur(); + assertSnapshots(snapshotWindow(window), ReferenceScreenshots[revertDir(initialDir)], + /* expectEqual = */ true, /* fuzz = */ null, + `<textarea dir="${initialDir}"> after first Accel+Shift+X`, + `<textarea dir="${revertDir(initialDir)}">`); + textarea.focus(); + waitForInputEvent = promiseFormatSetBlockTextDirectionInputEvent(textarea); + synthesizeKey("X", {accelKey: true, shiftKey: true}); + await waitForInputEvent; + is(textarea.getAttribute("dir"), initialDir, + "The dir attribute must be correctly recovered with second Accel+Shift+X"); + textarea.blur(); + assertSnapshots(snapshotWindow(window), ReferenceScreenshots[initialDir], + /* expectEqual = */ true, /* fuzz = */ null, + `<textarea dir="${initialDir}"> after second Accel+Shift+X`, + `<textarea dir="${initialDir}">`); + textarea.remove(); + } + + await testDirection("ltr"); + await testDirection("rtl"); + + SimpleTest.finish(); +}); + +</script> +</pre> +</body> +</html> |