1test(function() { 2 assert_true((self.performance !== undefined), "self.performance exists"); 3 assert_equals(typeof self.performance, "object", "self.performance is an object"); 4 assert_equals((typeof self.performance.now), "function", "self.performance.now() is a function"); 5 assert_equals(typeof self.performance.now(), "number", "self.performance.now() returns a number"); 6}, "self.performance.now() is a function that returns a number"); 7 8test(function() { 9 assert_true(self.performance.now() > 0); 10}, "self.performance.now() returns a positive number"); 11 12test(function() { 13 var now1 = self.performance.now(); 14 var now2 = self.performance.now(); 15 assert_true((now2-now1) >= 0); 16 }, "self.performance.now() difference is not negative"); 17 18async_test(function() { 19 // Check whether the performance.now() method is close to Date() within 30ms (due to inaccuracies) 20 var initial_hrt = self.performance.now(); 21 var initial_date = Date.now(); 22 this.step_timeout(function() { 23 var final_hrt = self.performance.now(); 24 var final_date = Date.now(); 25 assert_approx_equals(final_hrt - initial_hrt, final_date - initial_date, 30, 'High resolution time value increased by approximately the same amount as time from date object'); 26 this.done(); 27 }, 2000); 28}, 'High resolution time has approximately the right relative magnitude'); 29