blob: 5dc3804b2f7ea21f5e189351ea0194f30d6f536d (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
|
// META: script=/resources/test-only-api.js
// META: script=resources/pressure-helpers.js
// META: global=window,dedicatedworker,sharedworker
'use strict';
pressure_test(async (t, mockPressureService) => {
const update = await new Promise((resolve, reject) => {
const observer = new PressureObserver(resolve);
t.add_cleanup(() => observer.disconnect());
observer.observe('cpu').catch(reject);
observer.observe('cpu').catch(reject);
observer.observe('cpu').catch(reject);
mockPressureService.setPressureUpdate('cpu', 'critical');
mockPressureService.startPlatformCollector(/*sampleRate=*/ 5.0);
});
assert_equals(update[0].state, 'critical');
}, 'PressureObserver.observe() is idempotent');
|