зеркало из https://github.com/mozilla/gecko-dev.git
bug 1316154 - allow testing that an async event comes before or after other events r=yzen
There are cases where we want to test for several events, and while several may have a correct ordering some of the events can be fired in different orders WRT some but not all other events. The only purpose of the orderChecker is to force that all preceeding checkers succeed before allowing any following checkers to match.
This commit is contained in:
Родитель
85af4870f3
Коммит
4dad35bd60
|
@ -536,7 +536,16 @@ function eventQueue(aEventType)
|
|||
}
|
||||
|
||||
// Check if handled event matches any expected async events.
|
||||
var haveUnmatchedAsync = false;
|
||||
for (idx = 0; idx < eventSeq.length; idx++) {
|
||||
if (eventSeq[idx] instanceof orderChecker && haveUnmatchedAsync) {
|
||||
break;
|
||||
}
|
||||
|
||||
if (!eventSeq[idx].wasCaught) {
|
||||
haveUnmatchedAsync = true;
|
||||
}
|
||||
|
||||
if (!eventSeq[idx].unexpected && eventSeq[idx].async) {
|
||||
if (eventQueue.compareEvents(eventSeq[idx], aEvent)) {
|
||||
this.processMatchedChecker(aEvent, eventSeq[idx], scnIdx, idx);
|
||||
|
@ -553,6 +562,16 @@ function eventQueue(aEventType)
|
|||
invoker.check(aEvent);
|
||||
}
|
||||
|
||||
for (idx = 0; idx < eventSeq.length; idx++) {
|
||||
if (!eventSeq[idx].wasCaught) {
|
||||
if (eventSeq[idx] instanceof orderChecker) {
|
||||
eventSeq[idx].wasCaught++;
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// If we don't have more events to wait then schedule next invoker.
|
||||
if (this.hasMatchedScenario()) {
|
||||
if (this.mNextInvokerStatus == kInvokerNotScheduled) {
|
||||
|
@ -596,6 +615,7 @@ function eventQueue(aEventType)
|
|||
(aEventSeq[aEventSeq.idx].unexpected ||
|
||||
aEventSeq[aEventSeq.idx].todo ||
|
||||
aEventSeq[aEventSeq.idx].async ||
|
||||
aEventSeq[aEventSeq.idx] instanceof orderChecker ||
|
||||
aEventSeq[aEventSeq.idx].wasCaught > 0)) {
|
||||
aEventSeq.idx++;
|
||||
}
|
||||
|
@ -612,7 +632,7 @@ function eventQueue(aEventType)
|
|||
// sync expcected events yet.
|
||||
for (var idx = 0; idx < aEventSeq.length; idx++) {
|
||||
if (!aEventSeq[idx].unexpected && !aEventSeq[idx].todo &&
|
||||
!aEventSeq[idx].wasCaught)
|
||||
!aEventSeq[idx].wasCaught && !(aEventSeq[idx] instanceof orderChecker))
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -1679,6 +1699,15 @@ function invokerChecker(aEventType, aTargetOrFunc, aTargetFuncArg, aIsAsync)
|
|||
this.mTargetFuncArg = aTargetFuncArg;
|
||||
}
|
||||
|
||||
/**
|
||||
* event checker that forces preceeding async events to happen before this
|
||||
* checker.
|
||||
*/
|
||||
function orderChecker()
|
||||
{
|
||||
this.__proto__ = new invokerChecker(null, null, null, false);
|
||||
}
|
||||
|
||||
/**
|
||||
* Generic invoker checker for todo events.
|
||||
*/
|
||||
|
|
Загрузка…
Ссылка в новой задаче