summaryrefslogtreecommitdiffstats
path: root/editor/libeditor/tests/test_native_key_bindings_in_shadow.html
diff options
context:
space:
mode:
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.html50
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>