Bug 834138 - Intermittent states/test_doc_busy.html | Test timed out, r=tbsaunde

This commit is contained in:
Alexander Surkov 2013-09-12 09:10:42 -04:00
parent bbcd4a0cad
commit b12d399e5b
2 changed files with 66 additions and 43 deletions

View File

@ -293,11 +293,12 @@ function eventQueue(aEventType)
{ {
// Some scenario was matched, we wait on next invoker processing. // Some scenario was matched, we wait on next invoker processing.
if (this.mNextInvokerStatus == kInvokerCanceled) { if (this.mNextInvokerStatus == kInvokerCanceled) {
this.mNextInvokerStatus = kInvokerNotScheduled; this.setInvokerStatus(kInvokerNotScheduled,
"scenario was matched, wait for next invoker activation");
return; return;
} }
this.mNextInvokerStatus = kInvokerNotScheduled; this.setInvokerStatus(kInvokerNotScheduled, "the next invoker is processed now");
// Finish processing of the current invoker if any. // Finish processing of the current invoker if any.
var testFailed = false; var testFailed = false;
@ -433,7 +434,7 @@ function eventQueue(aEventType)
this.processNextInvokerInTimeout = this.processNextInvokerInTimeout =
function eventQueue_processNextInvokerInTimeout(aUncondProcess) function eventQueue_processNextInvokerInTimeout(aUncondProcess)
{ {
this.mNextInvokerStatus = kInvokerPending; this.setInvokerStatus(kInvokerPending, "Process next invoker in timeout");
// No need to wait extra timeout when a) we know we don't need to do that // No need to wait extra timeout when a) we know we don't need to do that
// and b) there's no any single unexpected event. // and b) there's no any single unexpected event.
@ -541,15 +542,22 @@ function eventQueue(aEventType)
} }
// If we don't have more events to wait then schedule next invoker. // If we don't have more events to wait then schedule next invoker.
if (this.hasMatchedScenario() && if (this.hasMatchedScenario()) {
(this.mNextInvokerStatus == kInvokerNotScheduled)) { if (this.mNextInvokerStatus == kInvokerNotScheduled) {
this.processNextInvokerInTimeout(); this.processNextInvokerInTimeout();
} else if (this.mNextInvokerStatus == kInvokerCanceled) {
this.setInvokerStatus(kInvokerPending,
"Full match. Void the cancelation of next invoker processing");
}
return; return;
} }
// If we have scheduled a next invoker then cancel in case of match. // If we have scheduled a next invoker then cancel in case of match.
if ((this.mNextInvokerStatus == kInvokerPending) && hasMatchedCheckers) if ((this.mNextInvokerStatus == kInvokerPending) && hasMatchedCheckers) {
this.mNextInvokerStatus = kInvokerCanceled; this.setInvokerStatus(kInvokerCanceled,
"Cancel the scheduled invoker in case of match");
}
} }
// Helpers // Helpers
@ -622,6 +630,17 @@ function eventQueue(aEventType)
return true; return true;
} }
this.isUnexpectedEventScenario =
function eventQueue_isUnexpectedEventsScenario(aScenario)
{
for (var idx = 0; idx < aScenario.length; idx++) {
if (!aScenario[idx].unexpected)
break;
}
return idx == aScenario.length;
}
this.hasUnexpectedEventsScenario = this.hasUnexpectedEventsScenario =
function eventQueue_hasUnexpectedEventsScenario() function eventQueue_hasUnexpectedEventsScenario()
{ {
@ -629,23 +648,19 @@ function eventQueue(aEventType)
return true; return true;
for (var scnIdx = 0; scnIdx < this.mScenarios.length; scnIdx++) { for (var scnIdx = 0; scnIdx < this.mScenarios.length; scnIdx++) {
var eventSeq = this.mScenarios[scnIdx]; if (this.isUnexpectedEventScenario(this.mScenarios[scnIdx]))
for (var idx = 0; idx < eventSeq.length; idx++) {
if (!eventSeq[idx].unexpected)
break;
}
if (idx == eventSeq.length)
return true; return true;
} }
return false; return false;
} }
this.hasMatchedScenario = this.hasMatchedScenario =
function eventQueue_hasMatchedScenario() function eventQueue_hasMatchedScenario()
{ {
for (var scnIdx = 0; scnIdx < this.mScenarios.length; scnIdx++) { for (var scnIdx = 0; scnIdx < this.mScenarios.length; scnIdx++) {
if (!this.areExpectedEventsLeft(this.mScenarios[scnIdx])) var scn = this.mScenarios[scnIdx];
if (!this.isUnexpectedEventScenario(scn) && !this.areExpectedEventsLeft(scn))
return true; return true;
} }
return false; return false;
@ -775,6 +790,14 @@ function eventQueue(aEventType)
return invoker.getID(); return invoker.getID();
} }
this.setInvokerStatus = function eventQueue_setInvokerStatus(aStatus, aLogMsg)
{
this.mNextInvokerStatus = aStatus;
// Uncomment it to debug invoker processing logic.
//gLogger.log(eventQueue.invokerStatusToMsg(aStatus, aLogMsg));
}
this.mDefEventType = aEventType; this.mDefEventType = aEventType;
this.mInvokers = new Array(); this.mInvokers = new Array();
@ -872,24 +895,10 @@ eventQueue.isSameEvent = function eventQueue_isSameEvent(aChecker, aEvent)
!(aEvent instanceof nsIAccessibleStateChangeEvent); !(aEvent instanceof nsIAccessibleStateChangeEvent);
} }
eventQueue.logEvent = function eventQueue_logEvent(aOrigEvent, aMatchedChecker, eventQueue.invokerStatusToMsg =
aScenarioIdx, aEventIdx, function eventQueue_invokerStatusToMsg(aInvokerStatus, aMsg)
aAreExpectedEventsLeft,
aInvokerStatus)
{ {
if (!gLogger.isEnabled()) // debug stuff var msg = "invoker status: ";
return;
// Dump DOM event information. Skip a11y event since it is dumped by
// gA11yEventObserver.
if (aOrigEvent instanceof nsIDOMEvent) {
var info = "Event type: " + eventQueue.getEventTypeAsString(aOrigEvent);
info += ". Target: " + eventQueue.getEventTargetDescr(aOrigEvent);
gLogger.logToDOM(info);
}
var msg = "unhandled expected events: " + aAreExpectedEventsLeft +
", invoker status: ";
switch (aInvokerStatus) { switch (aInvokerStatus) {
case kInvokerNotScheduled: case kInvokerNotScheduled:
msg += "not scheduled"; msg += "not scheduled";
@ -902,23 +911,37 @@ eventQueue.logEvent = function eventQueue_logEvent(aOrigEvent, aMatchedChecker,
break; break;
} }
gLogger.logToConsole(msg); if (aMsg)
gLogger.logToDOM(msg); msg += " (" + aMsg + ")";
if (!aMatchedChecker) return msg;
return; }
var msg = "EQ: "; eventQueue.logEvent = function eventQueue_logEvent(aOrigEvent, aMatchedChecker,
var emphText = "matched "; aScenarioIdx, aEventIdx,
aAreExpectedEventsLeft,
aInvokerStatus)
{
// Dump DOM event information. Skip a11y event since it is dumped by
// gA11yEventObserver.
if (aOrigEvent instanceof nsIDOMEvent) {
var info = "Event type: " + eventQueue.getEventTypeAsString(aOrigEvent);
info += ". Target: " + eventQueue.getEventTargetDescr(aOrigEvent);
gLogger.logToDOM(info);
}
var infoMsg = "unhandled expected events: " + aAreExpectedEventsLeft +
", " + eventQueue.invokerStatusToMsg(aInvokerStatus);
var currType = eventQueue.getEventTypeAsString(aMatchedChecker); var currType = eventQueue.getEventTypeAsString(aMatchedChecker);
var currTargetDescr = eventQueue.getEventTargetDescr(aMatchedChecker); var currTargetDescr = eventQueue.getEventTargetDescr(aMatchedChecker);
var consoleMsg = "*****\nScenario " + aScenarioIdx + var consoleMsg = "*****\nScenario " + aScenarioIdx +
", event " + aEventIdx + " matched: " + currType + "\n*****"; ", event " + aEventIdx + " matched: " + currType + "\n" + infoMsg + "\n*****";
gLogger.logToConsole(consoleMsg); gLogger.logToConsole(consoleMsg);
msg += " event, type: " + currType + ", target: " + currTargetDescr; var emphText = "matched ";
var msg = "EQ event, type: " + currType + ", target: " + currTargetDescr +
", " + infoMsg;
gLogger.logToDOM(msg, true, emphText); gLogger.logToDOM(msg, true, emphText);
} }

View File

@ -20,7 +20,7 @@
src="../events.js"></script> src="../events.js"></script>
<script type="application/javascript"> <script type="application/javascript">
gA11yEventDumpToConsole = true; // debugging stuff //gA11yEventDumpToConsole = true; // debugging stuff
function loadFile() function loadFile()
{ {