diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-19 00:47:55 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-19 00:47:55 +0000 |
commit | 26a029d407be480d791972afb5975cf62c9360a6 (patch) | |
tree | f435a8308119effd964b339f76abb83a57c29483 /testing/web-platform/tests/hr-time/basic.any.js | |
parent | Initial commit. (diff) | |
download | firefox-26a029d407be480d791972afb5975cf62c9360a6.tar.xz firefox-26a029d407be480d791972afb5975cf62c9360a6.zip |
Adding upstream version 124.0.1.upstream/124.0.1
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'testing/web-platform/tests/hr-time/basic.any.js')
-rw-r--r-- | testing/web-platform/tests/hr-time/basic.any.js | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/testing/web-platform/tests/hr-time/basic.any.js b/testing/web-platform/tests/hr-time/basic.any.js new file mode 100644 index 0000000000..4cd6e42dfc --- /dev/null +++ b/testing/web-platform/tests/hr-time/basic.any.js @@ -0,0 +1,37 @@ +test(function() { + assert_true((self.performance !== undefined), "self.performance exists"); + assert_equals(typeof self.performance, "object", "self.performance is an object"); + assert_equals((typeof self.performance.now), "function", "self.performance.now() is a function"); + assert_equals(typeof self.performance.now(), "number", "self.performance.now() returns a number"); +}, "self.performance.now() is a function that returns a number"); + +test(function() { + assert_true(self.performance.now() > 0); +}, "self.performance.now() returns a positive number"); + +test(function() { + var now1 = self.performance.now(); + var now2 = self.performance.now(); + assert_true((now2-now1) >= 0); + }, "self.performance.now() difference is not negative"); + +async_test(function() { + // Check whether the performance.now() method is close to Date() within 30ms (due to inaccuracies) + var initial_hrt = self.performance.now(); + var initial_date = Date.now(); + this.step_timeout(function() { + var final_hrt = self.performance.now(); + var final_date = Date.now(); + 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'); + this.done(); + }, 2000); +}, 'High resolution time has approximately the right relative magnitude'); + +test(function() { + var didHandle = false; + self.performance.addEventListener("testEvent", function() { + didHandle = true; + }, { once: true} ); + self.performance.dispatchEvent(new Event("testEvent")); + assert_true(didHandle, "Performance extends EventTarget, so event dispatching should work."); +}, "Performance interface extends EventTarget."); |