5 <title>Check whether native key bindings work in shadow DOM in editor
</title>
6 <script src=
"/tests/SimpleTest/SimpleTest.js"></script>
7 <script src=
"/tests/SimpleTest/EventUtils.js"></script>
8 <link rel=
"stylesheet" type=
"text/css" href=
"/tests/SimpleTest/test.css" />
12 const kIsMac
= navigator
.platform
.includes("Mac");
14 SimpleTest
.waitForExplicitFinish();
15 SimpleTest
.waitForFocus(() => {
16 const shadowHost
= document
.querySelector("div");
17 const shadowRoot
= shadowHost
.attachShadow({mode
: "open"});
18 shadowRoot
.innerHTML
= "<div contenteditable>abc def</div>";
19 const editingHost
= shadowRoot
.querySelector("div[contenteditable]");
21 getSelection().collapse(editingHost
.firstChild
, "abc ".length
);
23 synthesizeKey("KEY_ArrowLeft", {metaKey
: true});
25 synthesizeKey("KEY_Home");
27 synthesizeKey("X", {shiftKey
: true});
29 editingHost
.textContent
,
31 "X should've insert start of the editing host after typing \"Home\""
34 synthesizeKey("KEY_ArrowRight", {metaKey
: true});
36 synthesizeKey("KEY_End");
38 synthesizeKey("Y", {shiftKey
: true});
40 editingHost
.textContent
,
42 "Y should've been inserted end of the editing host after typing \"End\""
49 <body><div></div></body>