_("Make sure notify sends out the right notifications");
add_task(async function run_test() {
let ret, rightThis, didCall;
let obj = {
notify: Utils.notify("foo:"),
_log: {
trace() {},
},
func() { returnthis.notify("bar", "baz", async function () {
rightThis = this == obj;
didCall = true; return 5;
})();
},
let state = 0;
let makeObs = function (topic) {
let obj2 = {
observe(subject, obsTopic, data) { this.state = ++state; this.subject = subject; this.topic = obsTopic; this.data = data;
},
};
Svc.Obs.add(topic, obj2); return obj2;
};
_("Make sure a normal call will call and return with notifications");
rightThis = didCall = false;
let fs = makeObs("foo:bar:start");
let ff = makeObs("foo:bar:finish");
let fe = makeObs("foo:bar:error");
ret = await obj.func(); Assert.equal(ret, 5); Assert.ok(rightThis); Assert.ok(didCall);
_("Make sure a throwy call will call and throw with notifications");
ret = null;
rightThis = didCall = false;
let ts = makeObs("foo:bad:start");
let tf = makeObs("foo:bad:finish");
let te = makeObs("foo:bad:error"); try {
ret = await obj.throwy();
do_throw("throwy should have thrown!");
} catch (ex) { Assert.equal(ex.message, "covfefe");
} Assert.equal(ret, null); Assert.ok(rightThis); Assert.ok(didCall);
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.