Bug 591163 - mochitest for bug 413777, r=marcoz, a=blocking

This commit is contained in:
Alexander Surkov 2010-08-30 14:08:00 +09:00
parent c46068002a
commit c32122e6c7
3 changed files with 166 additions and 12 deletions

View File

@ -315,37 +315,48 @@ function eventQueue(aEventType)
invoker.debugCheck(aEvent);
// Search through unexpected events to ensure no one of them was handled.
for (var idx = 0; idx < this.mEventSeq.length; idx++) {
var idx = 0;
for (; idx < this.mEventSeq.length; idx++) {
if (this.mEventSeq[idx].unexpected && this.compareEvents(idx, aEvent))
invoker.wasCaught[idx] = true;
}
// Wait for next expected event in an order specified by event sequence.
// We've handled all expected events, next invoker processing is pending.
if (this.mEventSeqIdx == this.mEventSeq.length)
return;
// Compute next expected event index.
for (var idx = this.mEventSeqIdx + 1;
idx < this.mEventSeq.length && this.mEventSeq[idx].unexpected; idx++);
for (idx = this.mEventSeqIdx + 1;
idx < this.mEventSeq.length && this.mEventSeq[idx].unexpected;
idx++);
// No expected events were registered, proceed to next invoker to ensure
// unexpected events for current invoker won't be handled.
if (idx == this.mEventSeq.length) {
// There is no expected events in the sequence.
this.mEventSeqIdx = idx;
this.processNextInvokerInTimeout();
return;
}
// Check if handled event matches expected event.
var matched = this.compareEvents(idx, aEvent);
this.dumpEventToDOM(aEvent, idx, matched);
if (matched) {
this.checkEvent(idx, aEvent);
invoker.wasCaught[idx] = true;
// The last event is expected and was handled, proceed next invoker.
if (idx == this.mEventSeq.length - 1) {
this.processNextInvokerInTimeout();
return;
}
this.mEventSeqIdx = idx;
// Get next expected event index.
while (++idx < this.mEventSeq.length && this.mEventSeq[idx].unexpected);
// If the last expected event was processed, proceed next invoker in
// timeout to ensure unexpected events for current invoker won't be
// handled.
if (idx == this.mEventSeq.length) {
this.mEventSeqIdx = idx;
this.processNextInvokerInTimeout();
}
}
}

View File

@ -52,6 +52,7 @@ _TEST_FILES =\
test_button.xul \
test_colorpicker.xul \
test_combobox.xul \
test_cssoverflow.html \
test_filectrl.html \
test_formctrl.html \
test_formctrl.xul \

View File

@ -0,0 +1,142 @@
<html>
<head>
<title>CSS overflow testing</title>
<link rel="stylesheet" type="text/css"
href="chrome://mochikit/content/tests/SimpleTest/test.css" />
<style>
a.link:focus {
overflow: scroll;
}
</style>
<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>
<script type="application/javascript"
src="chrome://mochikit/content/tests/SimpleTest/EventUtils.js"></script>
<script type="application/javascript"
src="chrome://mochikit/content/a11y/accessible/common.js"></script>
<script type="application/javascript"
src="chrome://mochikit/content/a11y/accessible/events.js"></script>
<script type="application/javascript">
////////////////////////////////////////////////////////////////////////////
// Invokers
function focusAnchor(aID)
{
this.DOMNode = getNode(aID);
this.link = getAccessible(this.DOMNode);
this.linkChild = this.link.firstChild;
this.linkChildNode = getAccessible(this.linkChild, [nsIAccessNode]).DOMNode;
this.eventSeq = [
// new invokerChecker(EVENT_HIDE, this.linkChild),
// new invokerChecker(EVENT_SHOW, getAccessible, this.linkChildNode),
new invokerChecker(EVENT_FOCUS, this.link)
];
this.unexpectedEventSeq = [
new invokerChecker(EVENT_HIDE, this.link),
new invokerChecker(EVENT_SHOW, getAccessible, this.DOMNode)
];
this.invoke = function focusAnchor_invoke()
{
todo(false, "enable event hide/show events");
getNode(aID).focus();
}
this.getID = function focusAnchor_getID()
{
return "focus a:focus{overflow:scroll} #1";
}
}
function tabAnchor(aID, aPrevID)
{
this.DOMNode = getNode(aID);
this.link = getAccessible(this.DOMNode);
this.linkChild = this.link.firstChild;
this.linkChildNode = getAccessible(this.linkChild, [nsIAccessNode]).DOMNode;
this.prevLink = getAccessible(aPrevID);
this.prevLinkNode = getAccessible(this.prevLink, [nsIAccessNode]).DOMNode;
this.eventSeq = [
new invokerChecker(EVENT_HIDE, this.prevLink),
new invokerChecker(EVENT_SHOW, getAccessible, this.prevLinkNode),
new invokerChecker(EVENT_HIDE, this.linkChild),
new invokerChecker(EVENT_SHOW, getAccessible, this.linkChildNode),
new invokerChecker(EVENT_FOCUS, this.link)
];
this.unexpectedEventSeq = [
new invokerChecker(EVENT_HIDE, this.link),
new invokerChecker(EVENT_SHOW, getAccessible, this.DOMNode)
];
this.invoke = function focusAnchor_invoke()
{
synthesizeKey("VK_TAB", { shiftKey: false });
}
this.getID = function focusAnchor_getID()
{
return "focus a:focus{overflow:scroll} #2";
}
}
////////////////////////////////////////////////////////////////////////////
// Do tests
var gQueue = null;
// gA11yEventDumpID = "eventdump"; // debug stuff
function doTests()
{
gQueue = new eventQueue();
// CSS 'overflow: scroll' property setting and unsetting causes accessible
// recreation (and fire show/hide events) if the accessible is not
// focused. If it's focused its children are recreated. For example,
// focusing the HTML:a with ':focus {overflow: scroll; }' CSS style
// shouldn't cause of HTML:a accessible recreation. The same time blur
// makes its accessible to be recreated.
gQueue.push(new focusAnchor("a"))
gQueue.push(new tabAnchor("a2", "a"));
gQueue.invoke(); // Will call SimpleTest.finish();
}
SimpleTest.waitForExplicitFinish();
addA11yLoadEvent(doTests);
</script>
</head>
<body>
<a target="_blank"
href="https://bugzilla.mozilla.org/show_bug.cgi?id=591163"
title="mochitest for bug 413777: focus the a:focus {overflow: scroll;} shouldn't recreate HTML a accessible">
Mozilla Bug 591163
</a><br>
<p id="display"></p>
<div id="content" style="display: none"></div>
<pre id="test">
</pre>
<div id="eventdump"></div>
<div>
<a id="a" class="link" href="www">link</a>
</div>
<div>
<a id="a2" class="link" href="www">link2</a>
</div>
</body>
</html>