Bug 670880 - Remove Spatial Navigation. r=blassey

This commit is contained in:
Doug Turner 2011-07-20 15:19:59 -07:00
parent fec7ca5028
commit 6c5c93af7d
14 changed files with 0 additions and 1469 deletions

View File

@ -992,7 +992,6 @@ xpicleanup@BIN_SUFFIX@
modules/services-sync/type_records/prefs.js
modules/services-sync/type_records/tabs.js
modules/services-sync/util.js
modules/SpatialNavigation.js
modules/stylePanel.jsm
modules/tabview/AllTabs.jsm
modules/tabview/groups.jsm

View File

@ -59,7 +59,6 @@ PARALLEL_DIRS = \
mozapps/xpinstall \
obsolete \
profile \
spatial-navigation \
themes \
$(NULL)

View File

@ -1,50 +0,0 @@
# ***** BEGIN LICENSE BLOCK *****
# Version: MPL 1.1/GPL 2.0/LGPL 2.1
#
# The contents of this file are subject to the Mozilla Public License Version
# 1.1 (the "License"); you may not use this file except in compliance with
# the License. You may obtain a copy of the License at
# http://www.mozilla.org/MPL/
#
# Software distributed under the License is distributed on an "AS IS" basis,
# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
# for the specific language governing rights and limitations under the
# License.
#
# The Original Code is mozilla.org build system.
#
# The Initial Developer of the Original Code is Mozilla Foundation
# Portions created by the Initial Developer are Copyright (C) 2008
# the Initial Developer. All Rights Reserved.
#
# Contributor(s):
# Doug Turner <dougt@meer.net>
#
# Alternatively, the contents of this file may be used under the terms of
# either the GNU General Public License Version 2 or later (the "GPL"), or
# the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
# in which case the provisions of the GPL or the LGPL are applicable instead
# of those above. If you wish to allow use of your version of this file only
# under the terms of either the GPL or the LGPL, and not to allow others to
# use your version of this file under the terms of the MPL, indicate your
# decision by deleting the provisions above and replace them with the notice
# and other provisions required by the GPL or the LGPL. If you do not delete
# the provisions above, a recipient may use your version of this file under
# the terms of any one of the MPL, the GPL or the LGPL.
#
# ***** END LICENSE BLOCK *****
DEPTH = ../..
topsrcdir = @top_srcdir@
srcdir = @srcdir@
VPATH = @srcdir@
include $(DEPTH)/config/autoconf.mk
EXTRA_JS_MODULES = SpatialNavigation.js
ifdef ENABLE_TESTS
DIRS += tests
endif
include $(topsrcdir)/config/rules.mk

View File

@ -1,567 +0,0 @@
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is Spatial Navigation.
*
* The Initial Developer of the Original Code is Mozilla Foundation
* Portions created by the Initial Developer are Copyright (C) 2008
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Doug Turner <dougt@meer.net> (Original Author)
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
/**
*
* Import this module through
*
* Components.utils.import("resource://gre/modules/SpatialNavigation.js");
*
* Usage: (Literal class)
*
* SpatialNavigation(browser_element, optional_callback);
*
* optional_callback will be called when a new element is focused.
*
* function optional_callback(element) {}
*
*/
var EXPORTED_SYMBOLS = ["SpatialNavigation"];
var SpatialNavigation = {
init: function(browser, callback) {
browser.addEventListener("keypress", function (event) { _onInputKeyPress(event, callback) }, true);
},
uninit: function() {
}
};
// Private stuff
const Cc = Components.classes;
const Ci = Components.interfaces;
function dump(msg)
{
var console = Cc["@mozilla.org/consoleservice;1"].getService(Ci.nsIConsoleService);
console.logStringMessage("*** SNAV: " + msg);
}
var gDirectionalBias = 10;
var gRectFudge = 1;
// modifier values
const kAlt = "alt";
const kShift = "shift";
const kCtrl = "ctrl";
const kNone = "none";
function _onInputKeyPress (event, callback) {
// If it isn't enabled, bail.
if (!PrefObserver['enabled'])
return;
// Use whatever key value is available (either keyCode or charCode).
// It might be useful for addons or whoever wants to set different
// key to be used here (e.g. "a", "F1", "arrowUp", ...).
var key = event.which || event.keyCode;
if (key != PrefObserver['keyCodeDown'] &&
key != PrefObserver['keyCodeRight'] &&
key != PrefObserver['keyCodeUp'] &&
key != PrefObserver['keyCodeLeft'])
return;
// If it is not using the modifiers it should, bail.
if (!event.altKey && PrefObserver['modifierAlt'])
return;
if (!event.shiftKey && PrefObserver['modifierShift'])
return;
if (!event.crtlKey && PrefObserver['modifierCtrl'])
return;
// In some special cases where charCode is equal to one of the default arrow keyCodes we
// should bail.
if (!event.keyCode &&
(key == Ci.nsIDOMKeyEvent.DOM_VK_LEFT || key == Ci.nsIDOMKeyEvent.DOM_VK_DOWN ||
key == Ci.nsIDOMKeyEvent.DOM_VK_RIGHT || key == Ci.nsIDOMKeyEvent.DOM_VK_UP))
return;
var target = event.target;
var doc = target.ownerDocument;
// If it is XUL content (e.g. about:config), bail.
if (!PrefObserver['xulContentEnabled'] && doc instanceof Ci.nsIDOMXULDocument)
return ;
// check to see if we are in a textarea or text input element, and if so,
// ensure that we let the arrow keys work properly.
if (target instanceof Ci.nsIDOMHTMLHtmlElement) {
_focusNextUsingCmdDispatcher(key, callback);
return;
}
if ((target instanceof Ci.nsIDOMHTMLInputElement &&
target.mozIsTextField(false)) ||
target instanceof Ci.nsIDOMHTMLTextAreaElement) {
// if there is any selection at all, just ignore
if (target.selectionEnd - target.selectionStart > 0)
return;
// if there is no text, there is nothing special to do.
if (target.textLength > 0) {
if (key == PrefObserver['keyCodeRight'] ||
key == PrefObserver['keyCodeDown'] ) {
// we are moving forward into the document
if (target.textLength != target.selectionEnd)
return;
}
else
{
// we are at the start of the text, okay to move
if (target.selectionStart != 0)
return;
}
}
}
// Check to see if we are in a select
if (target instanceof Ci.nsIDOMHTMLSelectElement)
{
if (key == PrefObserver['keyCodeDown']) {
if (target.selectedIndex + 1 < target.length)
return;
}
if (key == PrefObserver['keyCodeUp']) {
if (target.selectedIndex > 0)
return;
}
}
function snavfilter(node) {
if (node instanceof Ci.nsIDOMHTMLLinkElement ||
node instanceof Ci.nsIDOMHTMLAnchorElement) {
// if a anchor doesn't have a href, don't target it.
if (node.href == "")
return Ci.nsIDOMNodeFilter.FILTER_SKIP;
return Ci.nsIDOMNodeFilter.FILTER_ACCEPT;
}
if ((node instanceof Ci.nsIDOMHTMLButtonElement ||
node instanceof Ci.nsIDOMHTMLInputElement ||
node instanceof Ci.nsIDOMHTMLLinkElement ||
node instanceof Ci.nsIDOMHTMLOptGroupElement ||
node instanceof Ci.nsIDOMHTMLSelectElement ||
node instanceof Ci.nsIDOMHTMLTextAreaElement) &&
node.disabled == false)
return Ci.nsIDOMNodeFilter.FILTER_ACCEPT;
return Ci.nsIDOMNodeFilter.FILTER_SKIP;
}
var bestElementToFocus = null;
var distanceToBestElement = Infinity;
var focusedRect = _inflateRect(target.getBoundingClientRect(),
- gRectFudge);
var treeWalker = doc.createTreeWalker(doc, Ci.nsIDOMNodeFilter.SHOW_ELEMENT, snavfilter, false);
var nextNode;
while ((nextNode = treeWalker.nextNode())) {
if (nextNode == target)
continue;
var nextRect = _inflateRect(nextNode.getBoundingClientRect(),
- gRectFudge);
if (! _isRectInDirection(key, focusedRect, nextRect))
continue;
var distance = _spatialDistance(key, focusedRect, nextRect);
//dump("looking at: " + nextNode + " " + distance);
if (distance <= distanceToBestElement && distance > 0) {
distanceToBestElement = distance;
bestElementToFocus = nextNode;
}
}
if (bestElementToFocus != null) {
//dump("focusing element " + bestElementToFocus.nodeName + " " + bestElementToFocus) + "id=" + bestElementToFocus.getAttribute("id");
// Wishing we could do element.focus()
doc.defaultView.QueryInterface(Ci.nsIInterfaceRequestor).getInterface(Ci.nsIDOMWindowUtils).focus(bestElementToFocus);
// if it is a text element, select all.
if ((bestElementToFocus instanceof Ci.nsIDOMHTMLInputElement &&
bestElementToFocus.mozIsTextField(false)) ||
bestElementToFocus instanceof Ci.nsIDOMHTMLTextAreaElement) {
bestElementToFocus.selectionStart = 0;
bestElementToFocus.selectionEnd = bestElementToFocus.textLength;
}
if (callback != undefined)
callback(bestElementToFocus);
} else {
// couldn't find anything. just advance and hope.
_focusNextUsingCmdDispatcher(key, callback);
}
event.preventDefault();
event.stopPropagation();
}
function _focusNextUsingCmdDispatcher(key, callback) {
var windowMediator = Cc['@mozilla.org/appshell/window-mediator;1'].getService(Ci.nsIWindowMediator);
var window = windowMediator.getMostRecentWindow("navigator:browser");
if (key == PrefObserver['keyCodeRight'] || key == PrefObserver['keyCodeDown']) {
window.document.commandDispatcher.advanceFocus();
} else {
window.document.commandDispatcher.rewindFocus();
}
if (callback != undefined)
callback(null);
}
function _isRectInDirection(key, focusedRect, anotherRect)
{
if (key == PrefObserver['keyCodeLeft']) {
return (anotherRect.left < focusedRect.left);
}
if (key == PrefObserver['keyCodeRight']) {
return (anotherRect.right > focusedRect.right);
}
if (key == PrefObserver['keyCodeUp']) {
return (anotherRect.top < focusedRect.top);
}
if (key == PrefObserver['keyCodeDown']) {
return (anotherRect.bottom > focusedRect.bottom);
}
return false;
}
function _inflateRect(rect, value)
{
var newRect = new Object();
newRect.left = rect.left - value;
newRect.top = rect.top - value;
newRect.right = rect.right + value;
newRect.bottom = rect.bottom + value;
return newRect;
}
function _containsRect(a, b)
{
return ( (b.left <= a.right) &&
(b.right >= a.left) &&
(b.top <= a.bottom) &&
(b.bottom >= a.top) );
}
function _spatialDistance(key, a, b)
{
var inlineNavigation = false;
var mx, my, nx, ny;
if (key == PrefObserver['keyCodeLeft']) {
// |---|
// |---|
//
// |---| |---|
// |---| |---|
//
// |---|
// |---|
//
if (a.top > b.bottom) {
// the b rect is above a.
mx = a.left;
my = a.top;
nx = b.right;
ny = b.bottom;
}
else if (a.bottom < b.top) {
// the b rect is below a.
mx = a.left;
my = a.bottom;
nx = b.right;
ny = b.top;
}
else {
mx = a.left;
my = 0;
nx = b.right;
ny = 0;
}
} else if (key == PrefObserver['keyCodeRight']) {
// |---|
// |---|
//
// |---| |---|
// |---| |---|
//
// |---|
// |---|
//
if (a.top > b.bottom) {
// the b rect is above a.
mx = a.right;
my = a.top;
nx = b.left;
ny = b.bottom;
}
else if (a.bottom < b.top) {
// the b rect is below a.
mx = a.right;
my = a.bottom;
nx = b.left;
ny = b.top;
} else {
mx = a.right;
my = 0;
nx = b.left;
ny = 0;
}
} else if (key == PrefObserver['keyCodeUp']) {
// |---| |---| |---|
// |---| |---| |---|
//
// |---|
// |---|
//
if (a.left > b.right) {
// the b rect is to the left of a.
mx = a.left;
my = a.top;
nx = b.right;
ny = b.bottom;
} else if (a.right < b.left) {
// the b rect is to the right of a
mx = a.right;
my = a.top;
nx = b.left;
ny = b.bottom;
} else {
// both b and a share some common x's.
mx = 0;
my = a.top;
nx = 0;
ny = b.bottom;
}
} else if (key == PrefObserver['keyCodeDown']) {
// |---|
// |---|
//
// |---| |---| |---|
// |---| |---| |---|
//
if (a.left > b.right) {
// the b rect is to the left of a.
mx = a.left;
my = a.bottom;
nx = b.right;
ny = b.top;
} else if (a.right < b.left) {
// the b rect is to the right of a
mx = a.right;
my = a.bottom;
nx = b.left;
ny = b.top;
} else {
// both b and a share some common x's.
mx = 0;
my = a.bottom;
nx = 0;
ny = b.top;
}
}
var scopedRect = _inflateRect(a, gRectFudge);
if (key == PrefObserver['keyCodeLeft'] ||
key == PrefObserver['keyCodeRight']) {
scopedRect.left = 0;
scopedRect.right = Infinity;
inlineNavigation = _containsRect(scopedRect, b);
}
else if (key == PrefObserver['keyCodeUp'] ||
key == PrefObserver['keyCodeDown']) {
scopedRect.top = 0;
scopedRect.bottom = Infinity;
inlineNavigation = _containsRect(scopedRect, b);
}
var d = Math.pow((mx-nx), 2) + Math.pow((my-ny), 2);
// prefer elements directly aligned with the focused element
if (inlineNavigation)
d /= gDirectionalBias;
return d;
}
// Snav preference observer
PrefObserver = {
register: function()
{
this.prefService = Cc["@mozilla.org/preferences-service;1"]
.getService(Ci.nsIPrefService);
this._branch = this.prefService.getBranch("snav.");
this._branch.QueryInterface(Ci.nsIPrefBranch2);
this._branch.addObserver("", this, false);
// set current or default pref values
this.observe(null, "nsPref:changed", "enabled");
this.observe(null, "nsPref:changed", "xulContentEnabled");
this.observe(null, "nsPref:changed", "keyCode.modifier");
this.observe(null, "nsPref:changed", "keyCode.right");
this.observe(null, "nsPref:changed", "keyCode.up");
this.observe(null, "nsPref:changed", "keyCode.down");
this.observe(null, "nsPref:changed", "keyCode.left");
},
observe: function(aSubject, aTopic, aData)
{
if(aTopic != "nsPref:changed")
return;
// aSubject is the nsIPrefBranch we're observing (after appropriate QI)
// aData is the name of the pref that's been changed (relative to aSubject)
switch (aData) {
case "enabled":
try {
this.enabled = this._branch.getBoolPref("enabled");
} catch(e) {
this.enabled = false;
}
break;
case "xulContentEnabled":
try {
this.xulContentEnabled = this._branch.getBoolPref("xulContentEnabled");
} catch(e) {
this.xulContentEnabled = false;
}
break;
case "keyCode.modifier":
try {
this.keyCodeModifier = this._branch.getCharPref("keyCode.modifier");
// resetting modifiers
this.modifierAlt = false;
this.modifierShift = false;
this.modifierCtrl = false;
if (this.keyCodeModifier != this.kNone)
{
// use are using '+' as a separator in about:config.
var mods = this.keyCodeModifier.split(/\++/);
for (var i = 0; i < mods.length; i++) {
var mod = mods[i].toLowerCase();
if (mod == "")
continue;
else if (mod == kAlt)
this.modifierAlt = true;
else if (mod == kShift)
this.modifierShift = true;
else if (mod == kCtrl)
this.modifierCtrl = true;
else {
this.keyCodeModifier = kNone;
break;
}
}
}
} catch(e) {
this.keyCodeModifier = kNone;
}
break;
case "keyCode.up":
try {
this.keyCodeUp = this._branch.getIntPref("keyCode.up");
} catch(e) {
this.keyCodeUp = Ci.nsIDOMKeyEvent.DOM_VK_UP;
}
break;
case "keyCode.down":
try {
this.keyCodeDown = this._branch.getIntPref("keyCode.down");
} catch(e) {
this.keyCodeDown = Ci.nsIDOMKeyEvent.DOM_VK_DOWN;
}
break;
case "keyCode.left":
try {
this.keyCodeLeft = this._branch.getIntPref("keyCode.left");
} catch(e) {
this.keyCodeLeft = Ci.nsIDOMKeyEvent.DOM_VK_LEFT;
}
break;
case "keyCode.right":
try {
this.keyCodeRight = this._branch.getIntPref("keyCode.right");
} catch(e) {
this.keyCodeRight = Ci.nsIDOMKeyEvent.DOM_VK_RIGHT;
}
break;
}
},
}
PrefObserver.register();

View File

@ -1,61 +0,0 @@
# ***** BEGIN LICENSE BLOCK *****
# Version: MPL 1.1/GPL 2.0/LGPL 2.1
#
# The contents of this file are subject to the Mozilla Public License Version
# 1.1 (the "License"); you may not use this file except in compliance with
# the License. You may obtain a copy of the License at
# http://www.mozilla.org/MPL/
#
# Software distributed under the License is distributed on an "AS IS" basis,
# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
# for the specific language governing rights and limitations under the
# License.
#
# The Original Code is mozilla.org build system.
#
# The Initial Developer of the Original Code is Mozilla Foundation
# Portions created by the Initial Developer are Copyright (C) 2008
# the Initial Developer. All Rights Reserved.
#
# Contributor(s):
# Doug Turner <dougt@meer.net>
#
# Alternatively, the contents of this file may be used under the terms of
# either the GNU General Public License Version 2 or later (the "GPL"), or
# the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
# in which case the provisions of the GPL or the LGPL are applicable instead
# of those above. If you wish to allow use of your version of this file only
# under the terms of either the GPL or the LGPL, and not to allow others to
# use your version of this file under the terms of the MPL, indicate your
# decision by deleting the provisions above and replace them with the notice
# and other provisions required by the GPL or the LGPL. If you do not delete
# the provisions above, a recipient may use your version of this file under
# the terms of any one of the MPL, the GPL or the LGPL.
#
# ***** END LICENSE BLOCK *****
DEPTH = ../../..
topsrcdir = @top_srcdir@
srcdir = @srcdir@
VPATH = @srcdir@
relativesrcdir = toolkit/spatial-navigation/tests
include $(DEPTH)/config/autoconf.mk
MODULE = test_snav
MOCHI_TESTS = chrome/test_snav.xul \
chrome/test_snav_tightlinks.xul \
chrome/test_snav_disabledElement.xul \
chrome/test_snav_selects.xul \
chrome/test_snav_prefDisabled.xul \
chrome/test_snav_prefKeyCode.xul \
chrome/SpatialNavUtils.js \
$(NULL)
# bug 447671 chrome/test_snav_textFields.xul \
include $(topsrcdir)/config/rules.mk
libs:: $(MOCHI_TESTS) $(MOCHI_CONTENT)
$(INSTALL) $(foreach f,$^,"$f") $(DEPTH)/_tests/testing/mochitest/chrome/$(relativesrcdir)

View File

@ -1,149 +0,0 @@
var _moveTable;
var _moveTableIndex = 0;
var _snavEnabledOld = null;
var _snavXULContentEnabledOld = null;
var _snavModOld = null ;
var _snavRightKeyOld = null;
var _snavLeftKeyOld = null;
var _snavDownKeyOld = null;
var _snavUpKeyOld = null;
function prepareTest(prefs) {
var prefService = Components.classes["@mozilla.org/preferences-service;1"]
.getService(Components.interfaces.nsIPrefService);
var snavBranch = prefService.getBranch("snav.");
var i;
for (i = 0; i < prefs.length; i++)
{
switch (prefs[i][0])
{
case "enabled":
try {
_snavEnabledOld = snavBranch.getBoolPref("enabled");
} catch(e) {
_snavEnabledOld = false;
}
break;
case "xulContentEnabled":
try {
_snavXULContentEnabledOld = snavBranch.getBoolPref("xulContentEnabled");
} catch(e) {
_snavXULContentEnabledOld = false;
}
break;
case "keyCode.modifier":
try {
_snavModOld = snavBranch.getCharPref("keyCode.modifier");
} catch(e) {
_snavModOld = "alt+shift";
}
break;
case "keyCode.right" :
try {
_snavRightKeyOld = snavBranch.getIntPref("keyCode.right");
} catch(e) {
_snavRightKeyOld = Components.interfaces.nsIDOMKeyEvent.DOM_VK_RIGHT;
}
break;
case "keyCode.left" :
try {
_snavLeftKeyOld = snavBranch.getIntPref("keyCode.left");
} catch(e) {
_snavLeftKeyOld = Components.interfaces.nsIDOMKeyEvent.DOM_VK_LEFT;
}
break;
case "keyCode.down" :
try {
_snavDownKeyOld = snavBranch.getIntPref("keyCode.down");
} catch(e) {
_snavDownKeyOld = Components.interfaces.nsIDOMKeyEvent.DOM_VK_DOWN;
}
break;
case "keyCode.up" :
try {
_snavUpKeyOld = snavBranch.getIntPref("keyCode.up");
} catch(e) {
_snavUpKeyOld = Components.interfaces.nsIDOMKeyEvent.DOM_VK_UP;
}
break;
} // switch
if (prefs[i][1] == "bool")
snavBranch.setBoolPref(prefs[i][0], prefs[i][2]);
else if (prefs[i][1] == "int")
snavBranch.setIntPref(prefs[i][0], prefs[i][2]);
else if (prefs[i][1] == "char")
snavBranch.setCharPref(prefs[i][0], prefs[i][2]);
} // for
}
// setting pref values back.
function completeTest() {
var prefService = Components.classes["@mozilla.org/preferences-service;1"]
.getService(Components.interfaces.nsIPrefService);
var snavBranch = prefService.getBranch("snav.");
if (_snavEnabledOld != null)
snavBranch.setBoolPref("enabled", _snavEnabledOld);
if (_snavXULContentEnabledOld != null)
snavBranch.setBoolPref("xulContentEnabled", _snavXULContentEnabledOld);
if (_snavModOld != null)
snavBranch.setCharPref("keyCode.modifier", _snavModOld);
if (_snavRightKeyOld != null)
snavBranch.setIntPref("keyCode.right", _snavRightKeyOld);
if (_snavUpKeyOld != null)
snavBranch.setIntPref("keyCode.up", _snavUpKeyOld);
if (_snavDownKeyOld != null)
snavBranch.setIntPref("keyCode.down", _snavDownKeyOld);
if (_snavLeftKeyOld != null)
snavBranch.setIntPref("keyCode.left", _snavLeftKeyOld);
}
function testMoves(table) {
// document.addEventListener("focus", _verifyAndAdvance, true);
_moveTable = table;
_moveTableIndex = 0;
_move();
}
function _nextMove()
{
_moveTableIndex++;
// When a table ends with "DONE", call finish.
if (_moveTable[_moveTableIndex][0] == "DONE") {
completeTest ();
SimpleTest.finish();
return;
}
// when a table has an empty elment, end the moves.
if (_moveTable[_moveTableIndex][0] == "") {
return;
}
_move();
}
function _move()
{
sendKey( _moveTable[_moveTableIndex][0], document.activeElement);
setTimeout( _verifyAndAdvance , 100);
}
function _verifyAndAdvance()
{
var direction = _moveTable[_moveTableIndex][0];
var expectedID = _moveTable[_moveTableIndex][1];
ok(document.activeElement.getAttribute("id") == expectedID,
"Move " + direction + " to " + expectedID + ". Found " + document.activeElement.getAttribute("id"));
_nextMove();
}

View File

@ -1,88 +0,0 @@
<?xml version="1.0"?>
<?xml-stylesheet href="chrome://global/skin" type="text/css"?>
<?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css type="text/css"?>
<!--
https://bugzilla.mozilla.org/show_bug.cgi?id=436084
-->
<window title="Mozilla Bug 288254"
xmlns:html="http://www.w3.org/1999/xhtml"
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
<script type="application/javascript" src="chrome://mochikit/content/MochiKit/packed.js"></script>
<script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"/>
<script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/EventUtils.js"></script>
<script type="application/javascript" src="SpatialNavUtils.js"></script>
<body id="some-content" xmlns="http://www.w3.org/1999/xhtml">
<a id="start" href="https://bugzilla.mozilla.org/show_bug.cgi?id=436084">Mozilla Bug 436084</a>
<table
style="text-align: left; width: 100%; margin-left: auto; margin-right: auto;" border="1" cellpadding="2" cellspacing="2">
<tbody>
<tr>
<td style="vertical-align: top; text-align: center;"><a id="1" href="a">test</a></td>
<td style="vertical-align: top; text-align: center;"><a id="2" href="a">test</a></td>
<td style="vertical-align: top; text-align: center;"><a id="3" href="a">test</a></td>
</tr>
<tr>
<td style="vertical-align: top; text-align: center;"><a id="4" href="a">test</a></td>
<td style="vertical-align: top; text-align: center;"><a id="5" href="a">test</a></td>
<td style="vertical-align: top; text-align: center;"><a id="6" href="a">test</a></td>
</tr>
<tr>
<td style="vertical-align: top; text-align: center;"><a id="7" href="a">test</a></td>
<td style="vertical-align: top; text-align: center;"><a id="8" href="a">test</a></td>
<td style="vertical-align: top; text-align: center;"><a id="9" href="a">test</a></td>
</tr>
</tbody>
</table>
</body>
<script class="testbody" type="application/javascript">
<![CDATA[
Components.utils.import("resource://gre/modules/SpatialNavigation.js");
var moveTable = [
["DOWN", "1"],
["DOWN", "4"],
["DOWN", "7"],
["RIGHT", "8"],
["RIGHT", "9"],
["UP", "6"],
["UP", "3"],
["LEFT", "2"],
["LEFT", "1"],
["DONE", "DONE"]
];
var prefs = [
["enabled", "bool", true],
["xulContentEnabled", "bool", true],
["keyCode.modifier", "char", "none"],
];
function runtest()
{
prepareTest(prefs);
// starting the test itself.
var x = document.getElementById("some-content");
SpatialNavigation.init(x);
// get to a known place.
document.getElementById("start").focus();
testMoves(moveTable);
SimpleTest.waitForExplicitFinish();
SpatialNavigation.uninit();
}
SimpleTest.waitForFocus(runtest);
]]></script>
</window>

View File

@ -1,70 +0,0 @@
<?xml version="1.0"?>
<?xml-stylesheet href="chrome://global/skin" type="text/css"?>
<?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css type="text/css"?>
<!--
https://bugzilla.mozilla.org/show_bug.cgi?id=436084
-->
<window title="Mozilla Bug 288254"
xmlns:html="http://www.w3.org/1999/xhtml"
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
<script type="application/javascript" src="chrome://mochikit/content/MochiKit/packed.js"></script>
<script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"/>
<script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/EventUtils.js"></script>
<script type="text/javascript" src="SpatialNavUtils.js"></script>
<body id="some-content" xmlns="http://www.w3.org/1999/xhtml">
<p>
<a id="start" href="https://bugzilla.mozilla.org/show_bug.cgi?id=436084">Mozilla Bug 436084</a>
</p>
<p>
<input id="hi_mom" value="Some text" disabled="true" type="text"> </input>
</p>
<p>
<a id="end" href="https://bugzilla.mozilla.org/show_bug.cgi?id=436084">Mozilla Bug 436084</a>
</p>
</body>
<script class="testbody" type="application/javascript">
<![CDATA[
Components.utils.import("resource://gre/modules/SpatialNavigation.js");
var moveTable = [
["DOWN", "end"],
["DONE", "DONE"],
];
var prefs = [
["enabled", "bool", true],
["xulContentEnabled", "bool", true],
["keyCode.modifier", "char", "none"],
];
function runtest()
{
prepareTest(prefs);
// starting the test itself.
var x = document.getElementById("some-content");
SpatialNavigation.init(x);
// get to a known place.
document.getElementById("start").focus();
testMoves(moveTable);
SimpleTest.waitForExplicitFinish();
SpatialNavigation.uninit();
}
SimpleTest.waitForFocus(runtest);
]]></script>
</window>

View File

@ -1,65 +0,0 @@
<?xml version="1.0"?>
<?xml-stylesheet type="text/css" href="chrome://global/skin"?>
<?xml-stylesheet type="text/css" href="chrome://mochikit/content/tests/SimpleTest/test.css"?>
<window title="Mozilla Bug 444801"
xmlns:html="http://www.w3.org/1999/xhtml"
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
<script type="application/javascript" src="chrome://mochikit/content/MochiKit/packed.js"></script>
<script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"/>
<script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/EventUtils.js"></script>
<script type="application/javascript" src="SpatialNavUtils.js"></script>
<body id="some-content" xmlns="http://www.w3.org/1999/xhtml">
<a id="start" href="https://bugzilla.mozilla.org/show_bug.cgi?id=444801">Mozilla Bug 444801</a>
<table
style="text-align: left; width: 100%; margin-left: auto; margin-right: auto;" border="1" cellpadding="2" cellspacing="2">
<tbody>
<tr>
<td style="vertical-align: top; text-align: center;"><a id="1" href="a">test</a></td>
<td style="vertical-align: top; text-align: center;"><a id="2" href="a">test</a></td>
</tr>
</tbody>
</table>
</body>
<script class="testbody" type="application/javascript">
<![CDATA[
Components.utils.import("resource://gre/modules/SpatialNavigation.js");
var moveTable = [
["DOWN", "start"],
["DONE", "DONE"],
];
var prefs = [
["enabled", "bool", false],
["xulContentEnabled", "bool", true],
["keyCode.modifier", "char", "none"],
];
function runtest()
{
prepareTest(prefs);
// starting the test itself.
var x = document.getElementById("some-content");
SpatialNavigation.init(x);
// get to a known place.
document.getElementById("start").focus();
testMoves(moveTable);
SimpleTest.waitForExplicitFinish();
SpatialNavigation.uninit();
}
SimpleTest.waitForFocus(runtest);
]]>
</script>
</window>

View File

@ -1,77 +0,0 @@
<?xml version="1.0"?>
<?xml-stylesheet type="text/css" href="chrome://global/skin"?>
<?xml-stylesheet type="text/css" href="chrome://mochikit/content/tests/SimpleTest/test.css"?>
<window title="Mozilla Bug 444801"
xmlns:html="http://www.w3.org/1999/xhtml"
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
<script type="application/javascript" src="chrome://mochikit/content/MochiKit/packed.js"></script>
<script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"/>
<script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/EventUtils.js"></script>
<script type="application/javascript" src="SpatialNavUtils.js"></script>
<body id="some-content" xmlns="http://www.w3.org/1999/xhtml">
<a id="start" href="https://bugzilla.mozilla.org/show_bug.cgi?id=444801">Mozilla Bug 444801</a>
<table
style="text-align: left; width: 100%; margin-left: auto; margin-right: auto;" border="1" cellpadding="2" cellspacing="2">
<tbody>
<tr>
<td style="vertical-align: top; text-align: center;"><a id="1" href="a">test</a></td>
<td style="vertical-align: top; text-align: center;"><a id="2" href="a">test</a></td>
</tr>
<tr>
<td style="vertical-align: top; text-align: center;"><a id="3" href="a">test</a></td>
<td style="vertical-align: top; text-align: center;"><a id="4" href="a">test</a></td>
</tr>
</tbody>
</table>
</body>
<script class="testbody" type="application/javascript">
<![CDATA[
Components.utils.import("resource://gre/modules/SpatialNavigation.js");
var moveTable = [
["D", "1"],
["D", "3"],
["R", "4"],
["U", "2"],
["L", "1"],
["DONE", "DONE"],
];
var prefs = [
["enabled", "bool", true],
["xulContentEnabled", "bool", true],
["keyCode.modifier", "char", "none"],
["keyCode.right", "int", 82], // DOM_VK_R
["keyCode.left", "int", 76], // DOM_VK_L
["keyCode.down", "int", 68], // DOM_VK_D
["keyCode.up", "int", 85], // DOM_VK_U
];
function runtest()
{
prepareTest(prefs);
// starting the test itself.
var x = document.getElementById("some-content");
SpatialNavigation.init(x);
// get to a known place.
document.getElementById("start").focus();
testMoves(moveTable);
SimpleTest.waitForExplicitFinish();
SpatialNavigation.uninit();
}
SimpleTest.waitForFocus(runtest);
]]>
</script>
</window>

View File

@ -1,81 +0,0 @@
<?xml version="1.0"?>
<?xml-stylesheet href="chrome://global/skin" type="text/css"?>
<?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css type="text/css"?>
<!--
https://bugzilla.mozilla.org/show_bug.cgi?id=436084
-->
<window title="Mozilla Bug 288254"
xmlns:html="http://www.w3.org/1999/xhtml"
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
<script type="application/javascript" src="chrome://mochikit/content/MochiKit/packed.js"></script>
<script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"/>
<script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/EventUtils.js"></script>
<script type="text/javascript" src="SpatialNavUtils.js"></script>
<body id="some-content" xmlns="http://www.w3.org/1999/xhtml">
<p>
<a id="start" href="https://bugzilla.mozilla.org/show_bug.cgi?id=436084">Mozilla Bug 445518</a>
</p>
<form>
<select id="select_element" name="dropdown" size="1">
<option value ="1">option 1</option>
<option value ="2">option 2</option>
<option value ="3">option 3</option>
<option value ="4">option 4</option>
</select>
</form>
<p>
<a id="end" href="https://bugzilla.mozilla.org/show_bug.cgi?id=436084">Mozilla Bug 445518</a>
</p>
</body>
<script class="testbody" type="application/javascript">
<![CDATA[
Components.utils.import("resource://gre/modules/SpatialNavigation.js");
var moveTable = [
["DOWN", "select_element"],
["UP", "start"],
["DOWN", "select_element"],
["DOWN", "select_element"],
["DOWN", "select_element"],
["DOWN", "select_element"],
["DOWN", "end"],
["DONE", "DONE"],
];
var prefs = [
["enabled", "bool", true],
["xulContentEnabled", "bool", true],
["keyCode.modifier", "char", "none"],
];
function runtest()
{
prepareTest(prefs);
// starting the test itself.
var x = document.getElementById("some-content");
SpatialNavigation.init(x);
// get to a known place.
document.getElementById("start").focus();
testMoves(moveTable);
SimpleTest.waitForExplicitFinish();
SpatialNavigation.uninit();
}
SimpleTest.waitForFocus(runtest);
]]></script>
</window>

View File

@ -1,137 +0,0 @@
<?xml version="1.0"?>
<?xml-stylesheet href="chrome://global/skin" type="text/css"?>
<?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css type="text/css"?>
<!--
https://bugzilla.mozilla.org/show_bug.cgi?id=436084
-->
<window title="Mozilla Bug 288254"
xmlns:html="http://www.w3.org/1999/xhtml"
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
<script type="application/javascript" src="chrome://mochikit/content/MochiKit/packed.js"></script>
<script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"/>
<script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/EventUtils.js"></script>
<script type="text/javascript" src="SpatialNavUtils.js"></script>
<body id="some-content" xmlns="http://www.w3.org/1999/xhtml">
<p>
<a id="start" href="https://bugzilla.mozilla.org/show_bug.cgi?id=436084">Mozilla Bug 436084</a>
</p>
<p>
<input id="textinput" value="abcdefghijklmnopqrstuvwxyz" type="text"></input>
</p>
<p>
<textarea id="textarea" name="textarea" cols="30" rows="3" wrap="hard">The Book of Mozilla</textarea>
</p>
<p>
<a id="end" href="https://bugzilla.mozilla.org/show_bug.cgi?id=436084">Mozilla Bug 436084</a>
</p>
</body>
<script class="testbody" type="application/javascript">
<![CDATA[
Components.utils.import("resource://gre/modules/SpatialNavigation.js");
var moveTable = [
["DOWN", "textinput"],
["DOWN", "textinput"],
["DOWN", "textarea"],
["DOWN", "textarea"],
["DOWN", "end"],
["UP", "textarea"],
["UP", "textarea"],
["UP", "textinput"],
["UP", "textinput"],
["UP", "start"],
["DOWN", "textinput"],
["LEFT", "textinput"],
["RIGHT", "textinput"],
["RIGHT", "textinput"],
["RIGHT", "textinput"],
["RIGHT", "textinput"],
["RIGHT", "textinput"],
["RIGHT", "textinput"],
["RIGHT", "textinput"],
["RIGHT", "textinput"],
["RIGHT", "textinput"],
["RIGHT", "textinput"],
["RIGHT", "textinput"],
["RIGHT", "textinput"],
["RIGHT", "textinput"],
["RIGHT", "textinput"],
["RIGHT", "textinput"],
["RIGHT", "textinput"],
["RIGHT", "textinput"],
["RIGHT", "textinput"],
["RIGHT", "textinput"],
["RIGHT", "textinput"],
["RIGHT", "textinput"],
["RIGHT", "textinput"],
["RIGHT", "textinput"],
["RIGHT", "textinput"],
["RIGHT", "textinput"],
["RIGHT", "textinput"],
["RIGHT", "textarea"],
["LEFT", "textarea"],
["RIGHT", "textarea"],
["RIGHT", "textarea"],
["RIGHT", "textarea"],
["RIGHT", "textarea"],
["RIGHT", "textarea"],
["RIGHT", "textarea"],
["RIGHT", "textarea"],
["RIGHT", "textarea"],
["RIGHT", "textarea"],
["RIGHT", "textarea"],
["RIGHT", "textarea"],
["RIGHT", "textarea"],
["RIGHT", "textarea"],
["RIGHT", "textarea"],
["RIGHT", "textarea"],
["RIGHT", "textarea"],
["RIGHT", "textarea"],
["RIGHT", "textarea"],
["RIGHT", "textarea"],
["RIGHT", "end"],
["UP", "textarea"],
["DONE", "DONE"],
];
var prefs = [
["enabled", "bool", true],
["xulContentEnabled", "bool", true],
["keyCode.modifier", "char", "none"],
];
function runtest()
{
prepareTest(prefs);
// starting the test itself.
var x = document.getElementById("some-content");
SpatialNavigation.init(x);
// get to a known place.
document.getElementById("start").focus();
testMoves(moveTable);
SimpleTest.waitForExplicitFinish();
SpatialNavigation.uninit();
}
SimpleTest.waitForFocus(runtest);
]]></script>
</window>

View File

@ -1,120 +0,0 @@
<?xml version="1.0"?>
<?xml-stylesheet href="chrome://global/skin" type="text/css"?>
<?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css type="text/css"?>
<!--
https://bugzilla.mozilla.org/show_bug.cgi?id=436084
-->
<window title="Mozilla Bug 288254"
xmlns:html="http://www.w3.org/1999/xhtml"
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
<script type="application/javascript" src="chrome://mochikit/content/MochiKit/packed.js"></script>
<script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"/>
<script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/EventUtils.js"></script>
<script type="application/javascript" src="SpatialNavUtils.js"></script>
<body id="some-content" xmlns="http://www.w3.org/1999/xhtml">
<a id="start" href="https://bugzilla.mozilla.org/show_bug.cgi?id=436084">Mozilla Bug 436084 (roxama test case)</a>
<table>
<tbody>
<tr>
<td style="font-size: small;"><a id="1" href="a">Link</a></td>
<td style="font-size: small;"><a id="2" href="a">Link</a></td>
<td style="font-size: small;"><a id="3" href="a">Link</a></td>
<td style="font-size: small;"><a id="4" href="a">Link</a></td>
</tr>
<tr>
<td style="font-size: small;"><a id="5" href="a">Link</a></td>
<td style="font-size: small;"><a id="6" href="a">Link</a></td>
<td style="font-size: small;"><a id="7" href="a">Link</a></td>
<td style="font-size: small;"><a id="8" href="a">Link</a></td>
</tr>
<tr>
<td style="font-size: small;"><a id="9" href="a">Link</a></td>
<td style="font-size: small;"><a id="10" href="a">Link</a></td>
<td style="font-size: small;"><a id="11" href="a">Link</a></td>
<td style="font-size: small;"><a id="12" href="a">Link</a></td>
</tr>
<tr>
<td style="font-size: small;"><a id="13" href="a">Link</a></td>
<td style="font-size: small;"><a id="14" href="a">Link</a></td>
<td style="font-size: small;"><a id="15" href="a">Link</a></td>
<td style="font-size: small;"><a id="16" href="a">Link</a></td>
</tr>
</tbody>
</table>
</body>
<script class="testbody" type="application/javascript">
<![CDATA[
Components.utils.import("resource://gre/modules/SpatialNavigation.js");
var moveTable = [
["DOWN", "5"],
["DOWN", "9"],
["DOWN", "13"],
["UP", "9"],
["UP", "5"],
["UP", "1"],
["RIGHT", "2"],
["DOWN", "6"],
["DOWN", "10"],
["DOWN", "14"],
["UP", "10"],
["UP", "6"],
["UP", "2"],
["RIGHT", "3"],
["DOWN", "7"],
["DOWN", "11"],
["DOWN", "15"],
["UP", "11"],
["UP", "7"],
["UP", "3"],
["RIGHT", "4"],
["DOWN", "8"],
["DOWN", "12"],
["DOWN", "16"],
["UP", "12"],
["UP", "8"],
["UP", "4"],
["DONE", "DONE"]
];
var prefs = [
["enabled", "bool", true],
["xulContentEnabled", "bool", true],
["keyCode.modifier", "char", "none"],
];
function runtest()
{
prepareTest(prefs);
// starting the test itself.
var x = document.getElementById("some-content");
SpatialNavigation.init(x);
// get to a known place.
document.getElementById("1").focus();
testMoves(moveTable);
SimpleTest.waitForExplicitFinish();
SpatialNavigation.uninit();
}
SimpleTest.waitForFocus(runtest);
]]></script>
</window>

View File

@ -635,7 +635,6 @@ MAKEFILES_xulapp="
toolkit/components/printing/Makefile
toolkit/components/satchel/Makefile
toolkit/components/search/Makefile
toolkit/spatial-navigation/Makefile
toolkit/components/startup/Makefile
toolkit/components/startup/public/Makefile
toolkit/components/statusfilter/Makefile
@ -927,7 +926,6 @@ if [ "$ENABLE_TESTS" ]; then
toolkit/mozapps/extensions/test/Makefile
toolkit/mozapps/plugins/tests/Makefile
toolkit/mozapps/update/test/Makefile
toolkit/spatial-navigation/tests/Makefile
toolkit/xre/test/Makefile
uriloader/exthandler/tests/mochitest/Makefile
widget/tests/Makefile