зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1426886 - Timer.jsm should validate callback argument is a function. r=mconley
--HG-- extra : rebase_source : 9a8c31677a79e11c6798e6399b7c03cfcea33fd5
This commit is contained in:
Родитель
f634ea8511
Коммит
065a649090
|
@ -25,6 +25,9 @@ var gTimerTable = new Map(); // int -> nsITimer
|
|||
|
||||
function _setTimeoutOrIsInterval(aCallback, aMilliseconds, aIsInterval,
|
||||
aTarget, aArgs) {
|
||||
if (typeof aCallback !== "function") {
|
||||
throw new Error(`callback is not a function in ${aIsInterval ? "setInterval" : "setTimeout"}`);
|
||||
}
|
||||
let id = gNextId++;
|
||||
let timer = Cc["@mozilla.org/timer;1"].createInstance(Ci.nsITimer);
|
||||
|
||||
|
|
|
@ -99,3 +99,23 @@ add_task(async function test_setIntervalWithTarget() {
|
|||
}, 100, target, 15, "hola");
|
||||
});
|
||||
});
|
||||
|
||||
add_task(async function test_setTimeoutNonFunction() {
|
||||
Assert.throws(() => { imported.setTimeout({}, 0); },
|
||||
"callback is not a function in setTimeout");
|
||||
});
|
||||
|
||||
add_task(async function test_setIntervalNonFunction() {
|
||||
Assert.throws(() => { imported.setInterval({}, 0); },
|
||||
"callback is not a function in setInterval");
|
||||
});
|
||||
|
||||
add_task(async function test_setTimeoutWithTargetNonFunction() {
|
||||
Assert.throws(() => { imported.setTimeoutWithTarget({}, 0); },
|
||||
"callback is not a function in setTimeout");
|
||||
});
|
||||
|
||||
add_task(async function test_setIntervalWithTargetNonFunction() {
|
||||
Assert.throws(() => { imported.setIntervalWithTarget({}, 0); },
|
||||
"callback is not a function in setInterval");
|
||||
});
|
||||
|
|
Загрузка…
Ссылка в новой задаче