var gKeyDown1 = 0, gKeyPress1 = 0, gKeyUp1 = 0; var gKeyDown2 = 0, gKeyPress2 = 0, gKeyUp2 = 0; var gKeyDown3 = 0, gKeyPress3 = 0, gKeyUp3 = 0;
function runTest()
{
$("i1").focus();
// key events should not be retargeted when the focus changes to an
// element in the same document.
synthesizeKey("a", {type: "keydown"});
is(document.activeElement, $("i2"), "input 2 in focused");
synthesizeKey("a", {type: "keyup"});
is(gKeyDown1, 1, "keydown on input 1");
is(gKeyPress1, 0, "keypress on input 1");
is(gKeyUp1, 0, "keyup on input 1");
is(gKeyDown2, 0, "keydown on input 2");
is(gKeyPress2, 1, "keypress on input 2");
is(gKeyUp2, 1, "keyup on input 2");
// key events should also be retargeted when the focus changes to an
// element in a chrome document from a content document.
i4.addEventListener("keydown", () => $("i3").focus());
sendString("c");
is(gKeyDown3, 1, "keydown on input 3");
is(gKeyPress3, 1, "keypress on input 3");
is(gKeyUp3, 1, "keyup on input 3");
is(childWinObj.gKeyDownChild, 1, "keydown on input 4");
is(childWinObj.gKeyPressChild, 1, "keypress on input 4");
is(childWinObj.gKeyUpChild, 1, "keyup on input 4");
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.