summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/compute-pressure/compute_pressure_options.https.any.js
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-06-12 05:43:14 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-06-12 05:43:14 +0000
commit8dd16259287f58f9273002717ec4d27e97127719 (patch)
tree3863e62a53829a84037444beab3abd4ed9dfc7d0 /testing/web-platform/tests/compute-pressure/compute_pressure_options.https.any.js
parentReleasing progress-linux version 126.0.1-1~progress7.99u1. (diff)
downloadfirefox-8dd16259287f58f9273002717ec4d27e97127719.tar.xz
firefox-8dd16259287f58f9273002717ec4d27e97127719.zip
Merging upstream version 127.0.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'testing/web-platform/tests/compute-pressure/compute_pressure_options.https.any.js')
-rw-r--r--testing/web-platform/tests/compute-pressure/compute_pressure_options.https.any.js43
1 files changed, 24 insertions, 19 deletions
diff --git a/testing/web-platform/tests/compute-pressure/compute_pressure_options.https.any.js b/testing/web-platform/tests/compute-pressure/compute_pressure_options.https.any.js
index d0760ef622..ecf3c29dbf 100644
--- a/testing/web-platform/tests/compute-pressure/compute_pressure_options.https.any.js
+++ b/testing/web-platform/tests/compute-pressure/compute_pressure_options.https.any.js
@@ -1,26 +1,31 @@
+// META: script=/resources/test-only-api.js
+// META: script=resources/pressure-helpers.js
// META: global=window,dedicatedworker,sharedworker
'use strict';
-test(t => {
- const observer = new PressureObserver(() => {}, {sampleInterval: 0});
- assert_equals(typeof observer, 'object');
-}, 'PressureObserver constructor doesnt throw error for sampleInterval value 0');
-
-
-test(t => {
- assert_throws_js(TypeError, () => {
- new PressureObserver(() => {}, {sampleInterval: -2});
+pressure_test(async (t, mockPressureService) => {
+ await new Promise(resolve => {
+ const observer = new PressureObserver(resolve);
+ t.add_cleanup(() => observer.disconnect());
+ observer.observe('cpu', {sampleInterval: 0});
+ mockPressureService.setPressureUpdate('cpu', 'critical');
+ mockPressureService.startPlatformCollector(/*sampleInterval=*/ 200);
});
-}, 'PressureObserver constructor requires a positive sampleInterval');
+}, 'PressureObserver observe method doesnt throw error for sampleInterval value 0');
-test(t => {
- assert_throws_js(TypeError, () => {
- new PressureObserver(() => {}, {sampleInterval: 2 ** 32});
- });
-}, 'PressureObserver constructor requires a sampleInterval in unsigned long range');
+promise_test(async t => {
+ const observer =
+ new PressureObserver(t.unreached_func('oops should not end up here'));
+ t.add_cleanup(() => observer.disconnect());
+ await promise_rejects_js(
+ t, TypeError, observer.observe('cpu', {sampleInterval: -2}));
+}, 'PressureObserver observe method requires a positive sampleInterval');
-test(t => {
- const observer = new PressureObserver(() => {}, {});
- assert_equals(typeof observer, 'object');
-}, 'PressureObserver constructor succeeds on empty sampleInterval');
+promise_test(async t => {
+ const observer =
+ new PressureObserver(t.unreached_func('oops should not end up here'));
+ t.add_cleanup(() => observer.disconnect());
+ await promise_rejects_js(
+ t, TypeError, observer.observe('cpu', {sampleInterval: 2 ** 32}));
+}, 'PressureObserver observe method requires a sampleInterval in unsigned long range');