summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/compute-pressure/compute_pressure_update_toJSON.https.any.js
diff options
context:
space:
mode:
Diffstat (limited to 'testing/web-platform/tests/compute-pressure/compute_pressure_update_toJSON.https.any.js')
-rw-r--r--testing/web-platform/tests/compute-pressure/compute_pressure_update_toJSON.https.any.js17
1 files changed, 17 insertions, 0 deletions
diff --git a/testing/web-platform/tests/compute-pressure/compute_pressure_update_toJSON.https.any.js b/testing/web-platform/tests/compute-pressure/compute_pressure_update_toJSON.https.any.js
new file mode 100644
index 0000000000..7f726698d6
--- /dev/null
+++ b/testing/web-platform/tests/compute-pressure/compute_pressure_update_toJSON.https.any.js
@@ -0,0 +1,17 @@
+// META: script=/resources/test-only-api.js
+// META: script=resources/pressure-helpers.js
+// META: global=window,dedicatedworker,sharedworker
+
+pressure_test(async (t, mockPressureService) => {
+ const changes = await new Promise(resolve => {
+ const observer = new PressureObserver(resolve);
+ observer.observe('cpu');
+ mockPressureService.setPressureUpdate('cpu', 'critical');
+ mockPressureService.startPlatformCollector(/*sampleInterval=*/ 200);
+ });
+ assert_true(changes.length === 1);
+ const json = changes[0].toJSON();
+ assert_equals(json.state, 'critical');
+ assert_equals(json.source, 'cpu');
+ assert_equals(typeof json.time, 'number');
+}, 'Basic functionality test');