summaryrefslogtreecommitdiffstats
path: root/third_party/WebKit/LayoutTests/inspector-protocol/input/dispatchKeyEvent.html
blob: 77048e0bb3103f9d09e18d949ef7fac917a27dc4 (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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
<html>
<head>
<script type="text/javascript" src="../../http/tests/inspector-protocol/resources/protocol-test.js"></script>
<script>

window.addEventListener("keydown", logEvent);
window.addEventListener("keypress", logEvent);
window.addEventListener("keyup", logEvent);

function logEvent(event)
{
    log("-----Event-----");
    log("type: " + event.type);
    if (event.altKey)
        log("altKey");
    if (event.ctrlKey)
        log("ctrlKey");
    if (event.metaKey)
        log("metaKey");
    if (event.shiftKey)
        log("shiftKey");
    if (event.keyCode)
        log("keyCode: " + event.keyCode);
    if (event.keyIdentifier)
        log("keyIdentifier: " + event.keyIdentifier);
    if (event.charCode)
        log("charCode: " + event.charCode);
    if (event.text)
        log("text: " + event.text);
    log("");
}

function test()
{
    var events = [
        {
            "type": "rawKeyDown",
            "windowsVirtualKeyCode": 65, // VK_A
            "keyIdentifier": "U+0041"
        },
        {
            "type": "char",
            "modifiers": 8, // shift
            "text": "A",
            "unmodifiedText": "a"
        },
        {
            "type": "keyUp",
            "windowsVirtualKeyCode": 65,
            "keyIdentifier": "U+0041"
        },
        {
            "type": "char",
            "text": "\u05E9",  // Hebrew Shin (sh)
            "unmodifiedText": "\u05E9"
        }
    ];

    for (var i = 0; i < events.length; i++)
        InspectorTest.sendCommand("Input.dispatchKeyEvent", events[i], checkResponse.bind(undefined, i == events.length - 1));

    function checkResponse(isLastCommand, msg)
    {
        if (msg.error)
            InspectorTest.log("Error: " + msg.error.message);
        if (isLastCommand)
            InspectorTest.completeTest();
    }
}

</script>
</head>
<body onload="runTest()">
</body>
</html>