Source code
Revision control
Copy as Markdown
Other Tools
Test Info: Warnings
- This test has a WPT meta file that expects 1 subtest issues.
- This WPT test may be referenced by the following Test IDs:
- /compute-pressure/compute_pressure_update_toJSON.https.any.html - WPT Dashboard Interop Dashboard
- /compute-pressure/compute_pressure_update_toJSON.https.any.sharedworker.html - WPT Dashboard Interop Dashboard
- /compute-pressure/compute_pressure_update_toJSON.https.any.worker.html - WPT Dashboard Interop Dashboard
// 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');