Add a setting to suppress keyboard input during provisional navigation
[WebKit-https.git] / LayoutTests / http / tests / navigation / resources / keyboard-events-test.js
1 function runTest()
2 {
3     function eventHandler(event)
4     {
5         console.log(event.type + "event dispatched (isTrusted: " + event.isTrusted + ").");
6     }
7
8     window.addEventListener("keydown", eventHandler, true);
9     window.addEventListener("keypress", eventHandler, true);
10     window.addEventListener("keyup", eventHandler, true);
11     window.addEventListener("compositionstart", eventHandler, true);
12     window.addEventListener("compositionupdate", eventHandler, true);
13     window.addEventListener("compositionend", eventHandler, true);
14     window.addEventListener("textInput", eventHandler, true);
15     window.addEventListener("beforeinput", eventHandler, true);
16     window.addEventListener("input", eventHandler, true);
17
18     console.log("Dispatching untrusted keypress event.");
19     var keyPressEvent = new KeyboardEvent("keypress");
20     document.body.dispatchEvent(keyPressEvent);
21
22     var textInput = document.createElement("input");
23     textInput.type = "text";
24     document.body.appendChild(textInput);
25
26     console.log("Pressing tab.");
27     eventSender.keyDown("\t");
28     console.log("Active element after pressing tab: " + document.activeElement + ".");
29
30     console.log("Pressing \"a\".");
31     eventSender.keyDown("a");
32
33     console.log("Setting marked text to \"b\".");
34     textInputController.setMarkedText("b", 0, 1);
35
36     console.log("Inserting text \"c\".");
37     textInputController.insertText("c");
38
39     console.log("Input element value after text input events: \"" + textInput.value + "\".");
40 }