1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/toolkit/modules/tests/xpcshell/test_timer.js Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,30 @@ 1.4 +/* Any copyright is dedicated to the Public Domain. 1.5 + * http://creativecommons.org/publicdomain/zero/1.0/ */ 1.6 + 1.7 +"use strict"; 1.8 + 1.9 +// Tests exports from Timer.jsm 1.10 + 1.11 +let imported = {}; 1.12 +Components.utils.import("resource://gre/modules/Timer.jsm", imported); 1.13 + 1.14 +function run_test(browser, tab, document) { 1.15 + do_test_pending(); 1.16 + 1.17 + let timeout1 = imported.setTimeout(function() do_throw("Should not be called"), 100); 1.18 + do_check_eq(typeof timeout1, "number", "setTimeout returns a number"); 1.19 + do_check_true(timeout1 > 0, "setTimeout returns a positive number"); 1.20 + 1.21 + let timeout2 = imported.setTimeout(function(param1, param2) { 1.22 + do_check_true(true, "Should be called"); 1.23 + do_check_eq(param1, 5, "first parameter is correct"); 1.24 + do_check_eq(param2, "test", "second parameter is correct"); 1.25 + do_test_finished(); 1.26 + }, 100, 5, "test"); 1.27 + 1.28 + do_check_eq(typeof timeout2, "number", "setTimeout returns a number"); 1.29 + do_check_true(timeout2 > 0, "setTimeout returns a positive number"); 1.30 + do_check_neq(timeout1, timeout2, "Calling setTimeout again returns a different value"); 1.31 + 1.32 + imported.clearTimeout(timeout1); 1.33 +}