mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 501496 part.9 EventUtils and some tests shouldn't synthesize keypress event if precede keydown event is consumed r=smaug
This commit is contained in:
parent
eda073062e
commit
0f31ecd06d
@ -538,8 +538,10 @@ function setupBracketCompletion(sourceEditor)
|
||||
let utils = editorElement.ownerDocument.defaultView.
|
||||
QueryInterface(Ci.nsIInterfaceRequestor).
|
||||
getInterface(Ci.nsIDOMWindowUtils);
|
||||
let handled = utils.sendKeyEvent("keydown", keyCode, 0, modifiers);
|
||||
utils.sendKeyEvent("keypress", 0, charCode, modifiers, !handled);
|
||||
|
||||
if (utils.sendKeyEvent("keydown", keyCode, 0, modifiers)) {
|
||||
utils.sendKeyEvent("keypress", 0, charCode, modifiers);
|
||||
}
|
||||
utils.sendKeyEvent("keyup", keyCode, 0, modifiers);
|
||||
// and rewind caret
|
||||
sourceEditor.setCaretOffset(sourceEditor.getCaretOffset() - 1);
|
||||
|
@ -273,7 +273,10 @@ function testSynthesizedKeyLocation()
|
||||
is(aEvent.location, currentTest.event.location,
|
||||
description + "location of " + aEvent.type + " was invalid");
|
||||
events[aEvent.type] = true;
|
||||
aEvent.preventDefault();
|
||||
if (aEvent.type != "keydown" ||
|
||||
(currentTest.event.isModifier && aEvent.type == "keydown")) {
|
||||
aEvent.preventDefault();
|
||||
}
|
||||
}
|
||||
|
||||
window.addEventListener("keydown", handler, true);
|
||||
|
@ -47,9 +47,9 @@ addLoadEvent(function test() {
|
||||
|
||||
function keypressOnSelect(key, modifiers) {
|
||||
WinUtils.focus(eSelect)
|
||||
WinUtils.sendKeyEvent("keyup", key, 0, modifiers, WinUtils.KEY_FLAG_PREVENT_DEFAULT)
|
||||
WinUtils.sendKeyEvent("keypress", key, 0, modifiers, WinUtils.KEY_FLAG_PREVENT_DEFAULT)
|
||||
WinUtils.sendKeyEvent("keydown", key, 0, modifiers, WinUtils.KEY_FLAG_PREVENT_DEFAULT)
|
||||
WinUtils.sendKeyEvent("keyup", key, 0, modifiers)
|
||||
WinUtils.sendKeyEvent("keypress", key, 0, modifiers)
|
||||
WinUtils.sendKeyEvent("keydown", key, 0, modifiers)
|
||||
}
|
||||
|
||||
function testKey(key, modifiers, keyString, functionToContinue) {
|
||||
|
@ -552,10 +552,7 @@ function synthesizeKey(aKey, aEvent, aWindow)
|
||||
// Send keydown + (optional) keypress + keyup events.
|
||||
var keyDownDefaultHappened =
|
||||
utils.sendKeyEvent("keydown", keyCode, 0, modifiers, flags);
|
||||
if (isKeypressFiredKey(keyCode)) {
|
||||
if (!keyDownDefaultHappened) {
|
||||
flags |= utils.KEY_FLAG_PREVENT_DEFAULT;
|
||||
}
|
||||
if (isKeypressFiredKey(keyCode) && keyDownDefaultHappened) {
|
||||
utils.sendKeyEvent("keypress", keyCode, charCode, modifiers, flags);
|
||||
}
|
||||
utils.sendKeyEvent("keyup", keyCode, 0, modifiers, flags);
|
||||
|
@ -40,7 +40,7 @@ var press2 = false;
|
||||
$("testKeyEvent2").focus();
|
||||
synthesizeKey("x", {});
|
||||
is($("testKeyEvent2").value, "", "synthesizeKey should respect keydown preventDefault");
|
||||
is(press2, true, "synthesizeKey should dispatch keyPress with default prevented");
|
||||
is(press2, false, "synthesizeKey should not dispatch keyPress with default prevented");
|
||||
|
||||
var press3 = false;
|
||||
$("testKeyEvent3").focus();
|
||||
@ -52,7 +52,7 @@ var press4 = false;
|
||||
$("testKeyEvent4").focus();
|
||||
sendChar("x")
|
||||
is($("testKeyEvent4").value, "", "sendChar should respect keydown preventDefault");
|
||||
is(press4, true, "sendChar should dispatch keyPress with default prevented");
|
||||
is(press4, false, "sendChar should not dispatch keyPress with default prevented");
|
||||
|
||||
|
||||
</script>
|
||||
|
@ -123,8 +123,9 @@ function doKey(aKey, modifier) {
|
||||
var wutils = window.QueryInterface(Components.interfaces.nsIInterfaceRequestor).
|
||||
getInterface(Components.interfaces.nsIDOMWindowUtils);
|
||||
|
||||
wutils.sendKeyEvent("keydown", key, 0, modifier);
|
||||
wutils.sendKeyEvent("keypress", key, 0, modifier);
|
||||
if (wutils.sendKeyEvent("keydown", key, 0, modifier)) {
|
||||
wutils.sendKeyEvent("keypress", key, 0, modifier);
|
||||
}
|
||||
wutils.sendKeyEvent("keyup", key, 0, modifier);
|
||||
}
|
||||
|
||||
|
@ -47,8 +47,9 @@ function doKey(aKey, modifier) {
|
||||
// Window utils for sending fake sey events.
|
||||
var wutils = SpecialPowers.getDOMWindowUtils(window);
|
||||
|
||||
wutils.sendKeyEvent("keydown", key, 0, modifier);
|
||||
wutils.sendKeyEvent("keypress", key, 0, modifier);
|
||||
if (wutils.sendKeyEvent("keydown", key, 0, modifier)) {
|
||||
wutils.sendKeyEvent("keypress", key, 0, modifier);
|
||||
}
|
||||
wutils.sendKeyEvent("keyup", key, 0, modifier);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user