summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/compute-pressure/compute_pressure_options.https.any.js
diff options
context:
space:
mode:
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');