2 var _moveTableIndex
= 0;
4 var _snavEnabledOld
= null;
5 var _snavXULContentEnabledOld
= null;
6 var _snavModOld
= null ;
7 var _snavRightKeyOld
= null;
8 var _snavLeftKeyOld
= null;
9 var _snavDownKeyOld
= null;
10 var _snavUpKeyOld
= null;
12 function prepareTest(prefs
) {
14 var prefService
= Components
.classes
["@mozilla.org/preferences-service;1"]
15 .getService(Components
.interfaces
.nsIPrefService
);
16 var snavBranch
= prefService
.getBranch("snav.");
19 for (i
= 0; i
< prefs
.length
; i
++)
25 _snavEnabledOld
= snavBranch
.getBoolPref("enabled");
27 _snavEnabledOld
= false;
30 case "xulContentEnabled":
32 _snavXULContentEnabledOld
= snavBranch
.getBoolPref("xulContentEnabled");
34 _snavXULContentEnabledOld
= false;
37 case "keyCode.modifier":
39 _snavModOld
= snavBranch
.getCharPref("keyCode.modifier");
41 _snavModOld
= "alt+shift";
44 case "keyCode.right" :
46 _snavRightKeyOld
= snavBranch
.getIntPref("keyCode.right");
48 _snavRightKeyOld
= Components
.interfaces
.nsIDOMKeyEvent
.DOM_VK_RIGHT
;
53 _snavLeftKeyOld
= snavBranch
.getIntPref("keyCode.left");
55 _snavLeftKeyOld
= Components
.interfaces
.nsIDOMKeyEvent
.DOM_VK_LEFT
;
60 _snavDownKeyOld
= snavBranch
.getIntPref("keyCode.down");
62 _snavDownKeyOld
= Components
.interfaces
.nsIDOMKeyEvent
.DOM_VK_DOWN
;
67 _snavUpKeyOld
= snavBranch
.getIntPref("keyCode.up");
69 _snavUpKeyOld
= Components
.interfaces
.nsIDOMKeyEvent
.DOM_VK_UP
;
74 if (prefs
[i
][1] == "bool")
75 snavBranch
.setBoolPref(prefs
[i
][0], prefs
[i
][2]);
76 else if (prefs
[i
][1] == "int")
77 snavBranch
.setIntPref(prefs
[i
][0], prefs
[i
][2]);
78 else if (prefs
[i
][1] == "char")
79 snavBranch
.setCharPref(prefs
[i
][0], prefs
[i
][2]);
83 // setting pref values back.
84 function completeTest() {
86 var prefService
= Components
.classes
["@mozilla.org/preferences-service;1"]
87 .getService(Components
.interfaces
.nsIPrefService
);
88 var snavBranch
= prefService
.getBranch("snav.");
90 if (_snavEnabledOld
!= null)
91 snavBranch
.setBoolPref("enabled", _snavEnabledOld
);
92 if (_snavXULContentEnabledOld
!= null)
93 snavBranch
.setBoolPref("xulContentEnabled", _snavXULContentEnabledOld
);
94 if (_snavModOld
!= null)
95 snavBranch
.setCharPref("keyCode.modifier", _snavModOld
);
96 if (_snavRightKeyOld
!= null)
97 snavBranch
.setIntPref("keyCode.right", _snavRightKeyOld
);
98 if (_snavUpKeyOld
!= null)
99 snavBranch
.setIntPref("keyCode.up", _snavUpKeyOld
);
100 if (_snavDownKeyOld
!= null)
101 snavBranch
.setIntPref("keyCode.down", _snavDownKeyOld
);
102 if (_snavLeftKeyOld
!= null)
103 snavBranch
.setIntPref("keyCode.left", _snavLeftKeyOld
);
106 function testMoves(table
) {
107 // document.addEventListener("focus", _verifyAndAdvance, true);
118 // When a table ends with "DONE", call finish.
119 if (_moveTable
[_moveTableIndex
][0] == "DONE") {
125 // when a table has an empty elment, end the moves.
126 if (_moveTable
[_moveTableIndex
][0] == "") {
135 sendKey( _moveTable
[_moveTableIndex
][0], document
.activeElement
);
136 setTimeout( _verifyAndAdvance
, 100);
139 function _verifyAndAdvance()
141 var direction
= _moveTable
[_moveTableIndex
][0];
142 var expectedID
= _moveTable
[_moveTableIndex
][1];
144 ok(document
.activeElement
.getAttribute("id") == expectedID
,
145 "Move " + direction
+ " to " + expectedID
+ ". Found " + document
.activeElement
.getAttribute("id"));