mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 846988 - Handle additional arguments to setTimeout in Timer.jsm [r=neil]
This commit is contained in:
parent
ddac28cf16
commit
247810ac19
@ -23,10 +23,11 @@ let gTimeoutTable = new Map(); // int -> nsITimer
|
||||
|
||||
this.setTimeout = function setTimeout(aCallback, aMilliseconds) {
|
||||
let id = gNextTimeoutId++;
|
||||
let args = Array.slice(arguments, 2);
|
||||
let timer = Cc["@mozilla.org/timer;1"].createInstance(Ci.nsITimer);
|
||||
timer.initWithCallback(function setTimeout_timer() {
|
||||
gTimeoutTable.delete(id);
|
||||
aCallback();
|
||||
aCallback.apply(null, args);
|
||||
}, aMilliseconds, timer.TYPE_ONE_SHOT);
|
||||
|
||||
gTimeoutTable.set(id, timer);
|
||||
|
@ -15,10 +15,12 @@ function run_test(browser, tab, document) {
|
||||
do_check_eq(typeof timeout1, "number", "setTimeout returns a number");
|
||||
do_check_true(timeout1 > 0, "setTimeout returns a positive number");
|
||||
|
||||
let timeout2 = imported.setTimeout(function() {
|
||||
let timeout2 = imported.setTimeout(function(param1, param2) {
|
||||
do_check_true(true, "Should be called");
|
||||
do_check_eq(param1, 5, "first parameter is correct");
|
||||
do_check_eq(param2, "test", "second parameter is correct");
|
||||
do_test_finished();
|
||||
}, 100);
|
||||
}, 100, 5, "test");
|
||||
|
||||
do_check_eq(typeof timeout2, "number", "setTimeout returns a number");
|
||||
do_check_true(timeout2 > 0, "setTimeout returns a positive number");
|
||||
|
Loading…
Reference in New Issue
Block a user