summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/compute-pressure/compute_pressure_factors.tentative.https.window.js
blob: 6d8d2208887007e429269b26cfd2891dfc497a29 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
// META: script=/resources/test-only-api.js
// META: script=resources/pressure-helpers.js

'use strict';

pressure_test(async (t, mockPressureService) => {
  const changes = await new Promise(resolve => {
    const observer = new PressureObserver(resolve, {sampleRate: 1.0});
    observer.observe('cpu');
    mockPressureService.setPressureUpdate('critical', ['thermal']);
    mockPressureService.startPlatformCollector(/*sampleRate=*/ 1.0);
  });
  assert_true(changes.length === 1);
  assert_equals(changes[0].state, 'critical');
  assert_equals(changes[0].source, 'cpu');
  assert_equals(typeof changes[0].time, 'number');
  assert_equals(changes[0].factors[0], 'thermal');
}, 'Basic factors functionality test');