Bug 811307 - [AccessFu] Add mochitest for enabling. r=eeejay

This commit is contained in:
David Bolter 2012-11-13 14:07:21 -05:00
parent cf4064cd81
commit 7781bfe064
5 changed files with 109 additions and 0 deletions

View File

@ -98,6 +98,9 @@ this.AccessFu = {
Services.obs.addObserver(this, 'Accessibility:Focus', false);
this.chromeWin.addEventListener('TabOpen', this);
this.chromeWin.addEventListener('TabSelect', this);
if (this.readyCallback)
this.readyCallback();
},
/**

View File

@ -20,6 +20,7 @@ DIRS = \
hittest \
hyperlink \
hypertext \
jsat \
name \
pivot \
relations \

View File

@ -647,6 +647,23 @@ function shortenString(aString, aMaxLength)
aString.substring(aString.length - trimOffset, aString.length);
}
////////////////////////////////////////////////////////////////////////////////
// General Utils
////////////////////////////////////////////////////////////////////////////////
/**
* Return main chrome window (crosses chrome boundary)
*/
function getTopChromeWindow(aWindow)
{
return aWindow.QueryInterface(Components.interfaces.nsIInterfaceRequestor)
.getInterface(Components.interfaces.nsIWebNavigation)
.QueryInterface(Components.interfaces.nsIDocShellTreeItem)
.rootTreeItem
.QueryInterface(Components.interfaces.nsIInterfaceRequestor)
.getInterface(Components.interfaces.nsIDOMWindow);
}
////////////////////////////////////////////////////////////////////////////////
// Private
////////////////////////////////////////////////////////////////////////////////

View File

@ -0,0 +1,18 @@
#
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
DEPTH = @DEPTH@
topsrcdir = @top_srcdir@
srcdir = @srcdir@
VPATH = @srcdir@
relativesrcdir = accessible/jsat
include $(DEPTH)/config/autoconf.mk
MOCHITEST_A11Y_FILES =\
test_alive.html \
$(NULL)
include $(topsrcdir)/config/rules.mk

View File

@ -0,0 +1,70 @@
<html>
<head>
<title>AccessFu test for enabling</title>
<link rel="stylesheet" type="text/css"
href="chrome://mochikit/content/tests/SimpleTest/test.css" />
<style type="text/css">
.offscreen {
position: absolute;
left: -5000px;
top: -5000px;
height: 100px;
width: 100px;
}
</style>
<script type="application/javascript"
src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
<script type="application/javascript"
src="../common.js"></script>
<script type="application/javascript">
Components.utils.import("resource://gre/modules/accessibility/AccessFu.jsm");
var gAccessFuStarted = false;
function startAccessFu()
{
SpecialPowers.setIntPref("accessibility.accessfu.activate", 1);
AccessFu.readyCallback = function readyCallback() {
gAccessFuStarted = true;
}
AccessFu.attach(getTopChromeWindow(window));
}
function doTest()
{
startAccessFu();
ok(gAccessFuStarted,"AccessFu initialization");
SimpleTest.finish();
}
SimpleTest.waitForExplicitFinish();
addA11yLoadEvent(doTest);
</script>
</head>
<body>
<a target="_blank"
href="https://bugzilla.mozilla.org/show_bug.cgi?id=811307"
title="[AccessFu] Add mochitest for enabling">
Mozilla Bug 811307
</a>
<p id="display"></p>
<div id="content" style="display: none"></div>
<pre id="test">
</pre>
<div>Alive!?</div>
</body>
</html>