blob: d29fb5f13fd94a7f425e76ad733c89913b004133 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
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>
|