From a4c51500ad9ca9478a6452b0296bd1581dad6827 Mon Sep 17 00:00:00 2001 From: Mina Almasry Date: Sat, 12 Oct 2013 13:59:50 -0400 Subject: [PATCH] Bug 698437 - Allow spatial navigation with directional controller. r=kats --- .../forms/test_input_range_key_events.html | 4 + .../test/forms/test_input_range_rounding.html | 4 + content/html/content/test/test_bug633058.html | 3 + content/html/content/test/test_bug674558.html | 5 + dom/tests/mochitest/bugs/test_bug265203.html | 4 + .../libeditor/base/tests/test_bug795785.html | 6 + layout/forms/test/test_bug345267.html | 4 + layout/forms/test/test_bug365410.html | 3 + layout/forms/test/test_bug563642.html | 3 + .../test/test_select_prevent_default.html | 5 + mobile/android/app/mobile.js | 2 + mobile/android/chrome/content/browser.js | 4 + modules/libpref/src/init/all.js | 3 + toolkit/modules/SpatialNavigation.jsm | 505 ++++++++++++++++++ toolkit/modules/moz.build | 1 + toolkit/modules/tests/mochitest/mochitest.ini | 1 + .../mochitest/test_spatial_navigation.html | 78 +++ toolkit/modules/tests/moz.build | 2 + widget/android/nsWindow.cpp | 3 + 19 files changed, 640 insertions(+) create mode 100644 toolkit/modules/SpatialNavigation.jsm create mode 100644 toolkit/modules/tests/mochitest/mochitest.ini create mode 100644 toolkit/modules/tests/mochitest/test_spatial_navigation.html diff --git a/content/html/content/test/forms/test_input_range_key_events.html b/content/html/content/test/forms/test_input_range_key_events.html index c8f8d182d4f0..b936c8e49246 100644 --- a/content/html/content/test/forms/test_input_range_key_events.html +++ b/content/html/content/test/forms/test_input_range_key_events.html @@ -24,6 +24,10 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=843725 * various key events while it is in various states. **/ SimpleTest.waitForExplicitFinish(); + +// Turn off Spatial Navigation because it hijacks arrow keydown events: +SpecialPowers.setBoolPref("snav.enabled", false); + SimpleTest.waitForFocus(function() { test(); SimpleTest.finish(); diff --git a/content/html/content/test/forms/test_input_range_rounding.html b/content/html/content/test/forms/test_input_range_rounding.html index 535c1e931af7..abc0fa85c8c8 100644 --- a/content/html/content/test/forms/test_input_range_rounding.html +++ b/content/html/content/test/forms/test_input_range_rounding.html @@ -26,6 +26,10 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=853525 * ugly rounding errors. **/ SimpleTest.waitForExplicitFinish(); + +// Turn off spatial navigation because it hijacks arrow keydown events: +SpecialPowers.setBoolPref("snav.enabled", false); + SimpleTest.waitForFocus(function() { test(); SimpleTest.finish(); diff --git a/content/html/content/test/test_bug633058.html b/content/html/content/test/test_bug633058.html index 0a6cf0faf1c0..a291eafd5d64 100644 --- a/content/html/content/test/test_bug633058.html +++ b/content/html/content/test/test_bug633058.html @@ -22,6 +22,9 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=633058 SimpleTest.waitForExplicitFinish(); +// Turn off Spatial Navigation so that the 'keypress' event fires. +SpecialPowers.setBoolPref('snav.enabled', false); + SimpleTest.waitForFocus(function() { var nbExpectedKeyPress = 8; var inputGotKeyPress = 0; diff --git a/content/html/content/test/test_bug674558.html b/content/html/content/test/test_bug674558.html index cbf2f5149484..21d3ad60b515 100644 --- a/content/html/content/test/test_bug674558.html +++ b/content/html/content/test/test_bug674558.html @@ -19,6 +19,11 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=674558 /** Test for Bug 674558 **/ SimpleTest.waitForExplicitFinish(); + +// Turn off spatial navigation because it hijacks VK_RIGHT and VK_LEFT keydown +// events. +SpecialPowers.setBoolPref("snav.enabled", false); + SimpleTest.waitForFocus(function() { function textAreaCtor() { return document.createElement("textarea"); diff --git a/dom/tests/mochitest/bugs/test_bug265203.html b/dom/tests/mochitest/bugs/test_bug265203.html index 0ac70f90b8f4..435ba683199f 100644 --- a/dom/tests/mochitest/bugs/test_bug265203.html +++ b/dom/tests/mochitest/bugs/test_bug265203.html @@ -41,6 +41,10 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=265203 /** Test for Bug 265203 **/ +// Turn off spatial navigation because it hijacks VK_RIGHT and VK_LEFT keydown +// events +SpecialPowers.setBoolPref("snav.enabled", false); + var gTestStarted = false; var expectedResult = [ null, 0, null ]; var nextTest; diff --git a/editor/libeditor/base/tests/test_bug795785.html b/editor/libeditor/base/tests/test_bug795785.html index 4ee48f29796d..aedffa762781 100644 --- a/editor/libeditor/base/tests/test_bug795785.html +++ b/editor/libeditor/base/tests/test_bug795785.html @@ -23,7 +23,13 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=795785 + + + + + +Mozilla Bug 698437 +

+
+

This is a really long sentence

+

This is a + really long + sentence

+

This is a really long sentence

+
+
+
+ + diff --git a/toolkit/modules/tests/moz.build b/toolkit/modules/tests/moz.build index 798b6ff93346..f0262b20701f 100644 --- a/toolkit/modules/tests/moz.build +++ b/toolkit/modules/tests/moz.build @@ -9,3 +9,5 @@ DIRS += ['browser'] MODULE = 'test_toolkit_general' XPCSHELL_TESTS_MANIFESTS += ['xpcshell/xpcshell.ini'] + +MOCHITEST_MANIFESTS += ['mochitest/mochitest.ini'] diff --git a/widget/android/nsWindow.cpp b/widget/android/nsWindow.cpp index a2143dfdc213..e8f8c5027c7c 100644 --- a/widget/android/nsWindow.cpp +++ b/widget/android/nsWindow.cpp @@ -1438,6 +1438,9 @@ static unsigned int ConvertAndroidKeyCodeToDOMKeyCode(int androidKeyCode) case AKEYCODE_KANA: return NS_VK_KANA; case AKEYCODE_ASSIST: return NS_VK_HELP; + // the A key is the action key for gamepad devices. + case AKEYCODE_BUTTON_A: return NS_VK_RETURN; + default: ALOG("ConvertAndroidKeyCodeToDOMKeyCode: " "No DOM keycode for Android keycode %d", androidKeyCode);