Bug 1008772 part.3 Fix new orages caused by tabbrowser consuming some key events at keydown r=smaug
authorMasayuki Nakano <masayuki@d-toybox.com>
Thu, 05 Jun 2014 11:57:54 +0900
changeset 207046 6d883625709965e5b5441986d2a9948b3170404f
parent 207045 721046203db098453b3d7dd09cf5bcb585ca90c7
child 207047 ccc885c8f4ac40d3f1de740d4f8d98af9fa167c2
push id494
push userraliiev@mozilla.com
push dateMon, 25 Aug 2014 18:42:16 +0000
treeherdermozilla-release@a3cc3e46b571 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssmaug
bugs1008772
milestone32.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1008772 part.3 Fix new orages caused by tabbrowser consuming some key events at keydown r=smaug
editor/libeditor/html/tests/test_htmleditor_keyevent_handling.html
editor/libeditor/text/tests/test_texteditor_keyevent_handling.html
widget/tests/test_key_event_counts.xul
--- a/editor/libeditor/html/tests/test_htmleditor_keyevent_handling.html
+++ b/editor/libeditor/html/tests/test_htmleditor_keyevent_handling.html
@@ -266,20 +266,21 @@ function runTests()
 
     reset("a");
     synthesizeKey("VK_TAB", { shiftKey: true });
     check(aDescription + "Shift+Tab", true, true, false);
     is(aElement.innerHTML, "a", aDescription + "Shift+Tab");
     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)");
 
     reset("a");
     synthesizeKey("VK_TAB", { altKey: true });
     check(aDescription + "Alt+Tab", true, true, false);
     is(aElement.innerHTML, "a", aDescription + "Alt+Tab");
@@ -331,20 +332,21 @@ function runTests()
           true, true, !aIsTabbable && !aIsReadonly && !aIsPlaintext);
     is(aElement.innerHTML,
        aIsReadonly || aIsTabbable || aIsPlaintext ?
          "<ul><li id=\"target\">ul list item</li></ul>" : "ul list item",
        aDescription + "Shift+Tab on UL");
     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,
        aDescription + "focus moved unexpectedly (Ctrl+Tab on UL)");
 
     resetForIndent("<ul><li id=\"target\">ul list item</li></ul>");
     synthesizeKey("VK_TAB", { altKey: true });
     check(aDescription + "Alt+Tab on UL", true, true, false);
@@ -399,20 +401,21 @@ function runTests()
           true, true, !aIsTabbable && !aIsReadonly && !aIsPlaintext);
     is(aElement.innerHTML,
        aIsReadonly || aIsTabbable || aIsPlaintext ?
          "<ol><li id=\"target\">ol list item</li></ol>" : "ol list item",
        aDescription + "Shfit+Tab on OL");
     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,
        aDescription + "focus moved unexpectedly (Ctrl+Tab on OL)");
 
     resetForIndent("<ol><li id=\"target\">ol list item</li></ol>");
     synthesizeKey("VK_TAB", { altKey: true });
     check(aDescription + "Alt+Tab on OL", true, true, false);
@@ -466,20 +469,21 @@ function runTests()
     synthesizeKey("VK_TAB", { shiftKey: true });
     check(aDescription + "Shift+Tab on TD", true, true, false);
     is(aElement.innerHTML,
        "<table><tbody><tr><td id=\"target\">td</td></tr></tbody></table>",
        aDescription + "Shift+Tab on TD");
     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");
     is(SpecialPowers.unwrap(fm.focusedElement), aElement,
        aDescription + "focus moved unexpectedly (Ctrl+Tab on TD)");
 
     resetForIndent("<table><tr><td id=\"target\">td</td></tr></table>");
     synthesizeKey("VK_TAB", { altKey: true });
@@ -537,20 +541,21 @@ function runTests()
     synthesizeKey("VK_TAB", { shiftKey: true });
     check(aDescription + "Shift+Tab on TH", true, true, false);
     is(aElement.innerHTML,
        "<table><tbody><tr><th id=\"target\">th</th></tr></tbody></table>",
        aDescription + "Shift+Tab on TH");
     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");
     is(SpecialPowers.unwrap(fm.focusedElement), aElement,
        aDescription + "focus moved unexpectedly (Ctrl+Tab on TH)");
 
     resetForIndent("<table><tr><th id=\"target\">th</th></tr></table>");
     synthesizeKey("VK_TAB", { altKey: true });
--- a/editor/libeditor/text/tests/test_texteditor_keyevent_handling.html
+++ b/editor/libeditor/text/tests/test_texteditor_keyevent_handling.html
@@ -287,20 +287,21 @@ function runTests()
 
     reset("a");
     synthesizeKey("VK_TAB", { shiftKey: true });
     check(aDescription + "Shift+Tab", true, true, false);
     is(aElement.value, "a", aDescription + "Shift+Tab");
     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)");
 
     reset("a");
     synthesizeKey("VK_TAB", { altKey: true });
     check(aDescription + "Alt+Tab", true, true, false);
     is(aElement.value, "a", aDescription + "Alt+Tab");
--- a/widget/tests/test_key_event_counts.xul
+++ b/widget/tests/test_key_event_counts.xul
@@ -17,39 +17,53 @@
   <body xmlns="http://www.w3.org/1999/xhtml">
     <p id="display"></p>
     <div id="content" style="display: none"></div>
     <pre id="test"></pre>
   </body>
 
   <script type="application/javascript"><![CDATA[
     var gKeyPressEventCount = 0;
+    var gKeyDownEventCound = 0;
+
+    function onKeyDown(e)
+    {
+      gKeyDownEventCount++;
+    }
 
     function onKeyPress(e)
     {
       gKeyPressEventCount++;
       e.preventDefault();
     }
 
     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>
 
 </window>