зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1672347 - remove defer from devtools/shared/discovery/tests/xpcshell. r=Honza
Differential Revision: https://phabricator.services.mozilla.com/D94283
This commit is contained in:
Родитель
79854d2dec
Коммит
2dd4dbb9c9
|
@ -57,21 +57,20 @@ var RootActor = protocol.ActorClassWithSpec(rootSpec, {
|
||||||
|
|
||||||
promiseReturn: function(toWait) {
|
promiseReturn: function(toWait) {
|
||||||
// Guarantee that this resolves after simpleReturn returns.
|
// Guarantee that this resolves after simpleReturn returns.
|
||||||
const deferred = defer();
|
return new Promise(resolve => {
|
||||||
const sequence = this.sequence++;
|
const sequence = this.sequence++;
|
||||||
|
|
||||||
// Wait until the number of requests specified by toWait have
|
// Wait until the number of requests specified by toWait have
|
||||||
// happened, to test queuing.
|
// happened, to test queuing.
|
||||||
const check = () => {
|
const check = () => {
|
||||||
if (this.sequence - sequence < toWait) {
|
if (this.sequence - sequence < toWait) {
|
||||||
executeSoon(check);
|
executeSoon(check);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
deferred.resolve(sequence);
|
resolve(sequence);
|
||||||
};
|
};
|
||||||
executeSoon(check);
|
executeSoon(check);
|
||||||
|
});
|
||||||
return deferred.promise;
|
|
||||||
},
|
},
|
||||||
|
|
||||||
simpleThrow: function() {
|
simpleThrow: function() {
|
||||||
|
@ -80,13 +79,13 @@ var RootActor = protocol.ActorClassWithSpec(rootSpec, {
|
||||||
|
|
||||||
promiseThrow: function() {
|
promiseThrow: function() {
|
||||||
// Guarantee that this resolves after simpleReturn returns.
|
// Guarantee that this resolves after simpleReturn returns.
|
||||||
const deferred = defer();
|
return new Promise((resolve, reject) => {
|
||||||
let sequence = this.sequence++;
|
let sequence = this.sequence++;
|
||||||
// This should be enough to force a failure if the code is broken.
|
// This should be enough to force a failure if the code is broken.
|
||||||
do_timeout(150, () => {
|
do_timeout(150, () => {
|
||||||
deferred.reject(sequence++);
|
reject(sequence++);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
return deferred.promise;
|
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -206,26 +206,26 @@ function run_test() {
|
||||||
expectRootChildren(0);
|
expectRootChildren(0);
|
||||||
})
|
})
|
||||||
.then(() => {
|
.then(() => {
|
||||||
const deferred = defer();
|
return new Promise(resolve => {
|
||||||
rootFront.once("string-event", str => {
|
rootFront.once("string-event", str => {
|
||||||
trace.expectSend({ type: "emitShortString", to: "<actorid>" });
|
trace.expectSend({ type: "emitShortString", to: "<actorid>" });
|
||||||
trace.expectReceive({
|
trace.expectReceive({
|
||||||
type: "string-event",
|
type: "string-event",
|
||||||
str: "abc",
|
str: "abc",
|
||||||
from: "<actorid>",
|
from: "<actorid>",
|
||||||
});
|
});
|
||||||
|
|
||||||
Assert.ok(!!str);
|
Assert.ok(!!str);
|
||||||
strfront = str;
|
strfront = str;
|
||||||
// Shouldn't generate any new references
|
// Shouldn't generate any new references
|
||||||
expectRootChildren(0);
|
expectRootChildren(0);
|
||||||
// will generate no packets.
|
// will generate no packets.
|
||||||
strfront.string().then(value => {
|
strfront.string().then(value => {
|
||||||
deferred.resolve(value);
|
resolve(value);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
rootFront.emitShortString();
|
||||||
});
|
});
|
||||||
rootFront.emitShortString();
|
|
||||||
return deferred.promise;
|
|
||||||
})
|
})
|
||||||
.then(value => {
|
.then(value => {
|
||||||
Assert.equal(value, SHORT_STR);
|
Assert.equal(value, SHORT_STR);
|
||||||
|
@ -235,52 +235,52 @@ function run_test() {
|
||||||
return strfront.release();
|
return strfront.release();
|
||||||
})
|
})
|
||||||
.then(() => {
|
.then(() => {
|
||||||
const deferred = defer();
|
return new Promise(resolve => {
|
||||||
rootFront.once("string-event", str => {
|
rootFront.once("string-event", str => {
|
||||||
trace.expectSend({ type: "emitLongString", to: "<actorid>" });
|
trace.expectSend({ type: "emitLongString", to: "<actorid>" });
|
||||||
trace.expectReceive({
|
trace.expectReceive({
|
||||||
type: "string-event",
|
type: "string-event",
|
||||||
str: {
|
str: {
|
||||||
type: "longString",
|
type: "longString",
|
||||||
actor: "<actorid>",
|
actor: "<actorid>",
|
||||||
length: 16,
|
length: 16,
|
||||||
initial: "abcde",
|
initial: "abcde",
|
||||||
},
|
},
|
||||||
from: "<actorid>",
|
from: "<actorid>",
|
||||||
});
|
});
|
||||||
|
|
||||||
Assert.ok(!!str);
|
Assert.ok(!!str);
|
||||||
// Should generate one new reference
|
// Should generate one new reference
|
||||||
expectRootChildren(1);
|
expectRootChildren(1);
|
||||||
strfront = str;
|
strfront = str;
|
||||||
strfront.string().then(value => {
|
strfront.string().then(value => {
|
||||||
trace.expectSend({
|
trace.expectSend({
|
||||||
type: "substring",
|
type: "substring",
|
||||||
start: 5,
|
start: 5,
|
||||||
end: 10,
|
end: 10,
|
||||||
to: "<actorid>",
|
to: "<actorid>",
|
||||||
});
|
});
|
||||||
trace.expectReceive({ substring: "fghij", from: "<actorid>" });
|
trace.expectReceive({ substring: "fghij", from: "<actorid>" });
|
||||||
trace.expectSend({
|
trace.expectSend({
|
||||||
type: "substring",
|
type: "substring",
|
||||||
start: 10,
|
start: 10,
|
||||||
end: 15,
|
end: 15,
|
||||||
to: "<actorid>",
|
to: "<actorid>",
|
||||||
});
|
});
|
||||||
trace.expectReceive({ substring: "klmno", from: "<actorid>" });
|
trace.expectReceive({ substring: "klmno", from: "<actorid>" });
|
||||||
trace.expectSend({
|
trace.expectSend({
|
||||||
type: "substring",
|
type: "substring",
|
||||||
start: 15,
|
start: 15,
|
||||||
end: 20,
|
end: 20,
|
||||||
to: "<actorid>",
|
to: "<actorid>",
|
||||||
});
|
});
|
||||||
trace.expectReceive({ substring: "p", from: "<actorid>" });
|
trace.expectReceive({ substring: "p", from: "<actorid>" });
|
||||||
|
|
||||||
deferred.resolve(value);
|
resolve(value);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
rootFront.emitLongString();
|
||||||
});
|
});
|
||||||
rootFront.emitLongString();
|
|
||||||
return deferred.promise;
|
|
||||||
})
|
})
|
||||||
.then(value => {
|
.then(value => {
|
||||||
Assert.equal(value, LONG_STR);
|
Assert.equal(value, LONG_STR);
|
||||||
|
|
Загрузка…
Ссылка в новой задаче