tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

basic.any.js (1706B)


      1 test(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 
      8 test(function() {
      9  assert_true(self.performance.now() > 0);
     10 }, "self.performance.now() returns a positive number");
     11 
     12 test(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 
     18 async_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 
     30 test(function() {
     31  var didHandle = false;
     32  self.performance.addEventListener("testEvent", function() {
     33    didHandle = true;
     34  }, { once: true} );
     35  self.performance.dispatchEvent(new Event("testEvent"));
     36  assert_true(didHandle, "Performance extends EventTarget, so event dispatching should work.");
     37 }, "Performance interface extends EventTarget.");