Bug 1008772 part.3 Fix new orages caused by tabbrowser consuming some key events at keydown r=smaug

This commit is contained in:
Masayuki Nakano 2014-06-05 11:57:54 +09:00
parent fe9df046d7
commit d0367270e1
3 changed files with 33 additions and 13 deletions

View File

@ -271,10 +271,11 @@ function runTests()
is(SpecialPowers.unwrap(fm.focusedElement), aElement,
aDescription + "focus moved unexpectedly (Shift+Tab)");
// Ctrl+Tab may be consumed by tabbrowser but editor shouldn't consume this.
// Ctrl+Tab should be consumed by tabbrowser at keydown, so, keypress
// event should never be fired.
reset("a");
synthesizeKey("VK_TAB", { ctrlKey: true });
check(aDescription + "Ctrl+Tab", true, true, false);
check(aDescription + "Ctrl+Tab", false, false, false);
is(aElement.innerHTML, "a", aDescription + "Ctrl+Tab");
is(SpecialPowers.unwrap(fm.focusedElement), aElement,
aDescription + "focus moved unexpectedly (Ctrl+Tab)");
@ -336,10 +337,11 @@ function runTests()
is(SpecialPowers.unwrap(fm.focusedElement), aElement,
aDescription + "focus moved unexpectedly (Shift+Tab on UL)");
// Ctrl+Tab may be consumed by tabbrowser but editor shouldn't consume this.
// Ctrl+Tab should be consumed by tabbrowser at keydown, so, keypress
// event should never be fired.
resetForIndent("<ul><li id=\"target\">ul list item</li></ul>");
synthesizeKey("VK_TAB", { ctrlKey: true });
check(aDescription + "Ctrl+Tab on UL", true, true, false);
check(aDescription + "Ctrl+Tab on UL", false, false, false);
is(aElement.innerHTML, "<ul><li id=\"target\">ul list item</li></ul>",
aDescription + "Ctrl+Tab on UL");
is(SpecialPowers.unwrap(fm.focusedElement), aElement,
@ -404,10 +406,11 @@ function runTests()
is(SpecialPowers.unwrap(fm.focusedElement), aElement,
aDescription + "focus moved unexpectedly (Shift+Tab on OL)");
// Ctrl+Tab may be consumed by tabbrowser but editor shouldn't consume this.
// Ctrl+Tab should be consumed by tabbrowser at keydown, so, keypress
// event should never be fired.
resetForIndent("<ol><li id=\"target\">ol list item</li></ol>");
synthesizeKey("VK_TAB", { ctrlKey: true });
check(aDescription + "Ctrl+Tab on OL", true, true, false);
check(aDescription + "Ctrl+Tab on OL", false, false, false);
is(aElement.innerHTML, "<ol><li id=\"target\">ol list item</li></ol>",
aDescription + "Ctrl+Tab on OL");
is(SpecialPowers.unwrap(fm.focusedElement), aElement,
@ -471,10 +474,11 @@ function runTests()
is(SpecialPowers.unwrap(fm.focusedElement), aElement,
aDescription + "focus moved unexpectedly (Shift+Tab on TD)");
// Ctrl+Tab may be consumed by tabbrowser but editor shouldn't consume this.
// Ctrl+Tab should be consumed by tabbrowser at keydown, so, keypress
// event should never be fired.
resetForIndent("<table><tr><td id=\"target\">td</td></tr></table>");
synthesizeKey("VK_TAB", { ctrlKey: true });
check(aDescription + "Ctrl+Tab on TD", true, true, false);
check(aDescription + "Ctrl+Tab on TD", false, false, false);
is(aElement.innerHTML,
"<table><tbody><tr><td id=\"target\">td</td></tr></tbody></table>",
aDescription + "Ctrl+Tab on TD");
@ -542,10 +546,11 @@ function runTests()
is(SpecialPowers.unwrap(fm.focusedElement), aElement,
aDescription + "focus moved unexpectedly (Shift+Tab on TH)");
// Ctrl+Tab may be consumed by tabbrowser but editor shouldn't consume this.
// Ctrl+Tab should be consumed by tabbrowser at keydown, so, keypress
// event should never be fired.
resetForIndent("<table><tr><th id=\"target\">th</th></tr></table>");
synthesizeKey("VK_TAB", { ctrlKey: true });
check(aDescription + "Ctrl+Tab on TH", true, true, false);
check(aDescription + "Ctrl+Tab on TH", false, false, false);
is(aElement.innerHTML,
"<table><tbody><tr><th id=\"target\">th</th></tr></tbody></table>",
aDescription + "Ctrl+Tab on TH");

View File

@ -292,10 +292,11 @@ function runTests()
is(SpecialPowers.unwrap(fm.focusedElement), aElement,
aDescription + "focus moved unexpectedly (Shift+Tab)");
// Ctrl+Tab may be consumed by tabbrowser but editor shouldn't consume this.
// Ctrl+Tab should be consumed by tabbrowser at keydown, so, keypress
// event should never be fired.
reset("a");
synthesizeKey("VK_TAB", { ctrlKey: true });
check(aDescription + "Ctrl+Tab", true, true, false);
check(aDescription + "Ctrl+Tab", false, false, false);
is(aElement.value, "a", aDescription + "Ctrl+Tab");
is(SpecialPowers.unwrap(fm.focusedElement), aElement,
aDescription + "focus moved unexpectedly (Ctrl+Tab)");

View File

@ -22,6 +22,12 @@
<script type="application/javascript"><![CDATA[
var gKeyPressEventCount = 0;
var gKeyDownEventCound = 0;
function onKeyDown(e)
{
gKeyDownEventCount++;
}
function onKeyPress(e)
{
@ -31,23 +37,31 @@
function runTest()
{
window.addEventListener("keydown", onKeyDown, false);
window.addEventListener("keypress", onKeyPress, false);
// Test ctrl-tab
gKeyDownEventCount = 0;
gKeyPressEventCount = 0;
synthesizeNativeKey(KEYBOARD_LAYOUT_EN_US, MAC_VK_Tab, {ctrlKey:1}, "\t", "\t");
is(gKeyPressEventCount, 1);
is(gKeyDownEventCount, 1);
is(gKeyPressEventCount, 0, "ctrl-tab should be consumed by tabbox of tabbrowser at keydown");
// Test cmd+shift+a
gKeyDownEventCount = 0;
gKeyPressEventCount = 0;
synthesizeNativeKey(KEYBOARD_LAYOUT_EN_US, MAC_VK_ANSI_A, {metaKey:1, shiftKey:1}, "a", "A");
is(gKeyDownEventCount, 1);
is(gKeyPressEventCount, 1);
// Test cmd-;
gKeyDownEventCount = 0;
gKeyPressEventCount = 0;
synthesizeNativeKey(KEYBOARD_LAYOUT_EN_US, MAC_VK_ANSI_Semicolon, {metaKey:1}, ";", ";");
is(gKeyDownEventCount, 1);
is(gKeyPressEventCount, 1);
window.removeEventListener("keydown", onKeyDown, false);
window.removeEventListener("keypress", onKeyPress, false);
}
]]></script>