diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-19 00:47:55 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-19 00:47:55 +0000 |
commit | 26a029d407be480d791972afb5975cf62c9360a6 (patch) | |
tree | f435a8308119effd964b339f76abb83a57c29483 /editor/libeditor/tests/test_native_key_bindings_in_shadow.html | |
parent | Initial commit. (diff) | |
download | firefox-26a029d407be480d791972afb5975cf62c9360a6.tar.xz firefox-26a029d407be480d791972afb5975cf62c9360a6.zip |
Adding upstream version 124.0.1.upstream/124.0.1
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'editor/libeditor/tests/test_native_key_bindings_in_shadow.html')
-rw-r--r-- | editor/libeditor/tests/test_native_key_bindings_in_shadow.html | 50 |
1 files changed, 50 insertions, 0 deletions
diff --git a/editor/libeditor/tests/test_native_key_bindings_in_shadow.html b/editor/libeditor/tests/test_native_key_bindings_in_shadow.html new file mode 100644 index 0000000000..d29fb5f13f --- /dev/null +++ b/editor/libeditor/tests/test_native_key_bindings_in_shadow.html @@ -0,0 +1,50 @@ +<!doctype html> +<html> +<head> +<meta charset="utf-8"> +<title>Check whether native key bindings work in shadow DOM in editor</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" /> +<script> +"use strict"; + +const kIsMac = navigator.platform.includes("Mac"); + +SimpleTest.waitForExplicitFinish(); +SimpleTest.waitForFocus(() => { + const shadowHost = document.querySelector("div"); + const shadowRoot = shadowHost.attachShadow({mode: "open"}); + shadowRoot.innerHTML = "<div contenteditable>abc def</div>"; + const editingHost = shadowRoot.querySelector("div[contenteditable]"); + editingHost.focus(); + getSelection().collapse(editingHost.firstChild, "abc ".length); + if (kIsMac) { + synthesizeKey("KEY_ArrowLeft", {metaKey: true}); + } else { + synthesizeKey("KEY_Home"); + } + synthesizeKey("X", {shiftKey: true}); + is( + editingHost.textContent, + "Xabc def", + "X should've insert start of the editing host after typing \"Home\"" + ); + if (kIsMac) { + synthesizeKey("KEY_ArrowRight", {metaKey: true}); + } else { + synthesizeKey("KEY_End"); + } + synthesizeKey("Y", {shiftKey: true}); + is( + editingHost.textContent, + "Xabc defY", + "Y should've been inserted end of the editing host after typing \"End\"" + ); + + SimpleTest.finish(); +}); +</script> +</head> +<body><div></div></body> +</html> |