Commit 0dbb3b1a authored by Arnaud Mandy's avatar Arnaud Mandy Committed by aborovova@mozilla.com
Browse files

Bug 1966633 [wpt PR 52565] - compute pressure: Add OwnContributionEstimate to API.,

Automatic update from web-platform-tests
compute pressure: Add OwnContributionEstimate to API.

This patch is the second part of the two patches patchset to
implement OnwContributionEstimate feature described in [1].

The first patch for crbug.com/402033762 addressed the
implementation-specific part, modifying //services and //content.

This patch exposes OwnContributionEstimate to Compute Pressure API.
The CDP has been also modified to also include a virtual estimate value.
Testdriver code was also modified to support estimate as a virtual
source input parameter.

[1] https://w3c.github.io/compute-pressure/?experimental=1#the-owncontributionestimate-attribute

Bug: 402033762
Change-Id: Ie4ff1294aea757700fb1cf6b5f22f18906867428
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6373001


Reviewed-by: default avatarAlex Rudenko <alexrudenko@chromium.org>
Reviewed-by: default avatarReilly Grant <reillyg@chromium.org>
Reviewed-by: default avatarKoji Ishii <kojii@chromium.org>
Reviewed-by: default avatarDanil Somsikov <dsv@chromium.org>
Commit-Queue: Arnaud Mandy <arnaud.mandy@intel.com>
Cr-Commit-Position: refs/heads/main@{#1460595}

--

wpt-commits: 9c26aadd95c82cc819cb766ea69946467cf6d5ea
wpt-pr: 52565

Differential Revision: https://phabricator.services.mozilla.com/D250621
parent e76fafb2
Loading
Loading
Loading
Loading
+22 −1
Original line number Diff line number Diff line
@@ -31,14 +31,35 @@ pressure_test(async (t) => {
    const observer = new PressureObserver(resolve);
    t.add_cleanup(() => observer.disconnect());
    observer.observe('cpu').catch(reject);
    update_virtual_pressure_source('cpu', 'critical').catch(reject);
    update_virtual_pressure_source('cpu', 'critical', 0.5).catch(reject);
  });
  assert_equals(1, changes.length);
  assert_equals(changes[0].state, 'critical');
  assert_equals(changes[0].source, 'cpu');
  assert_equals(typeof changes[0].time, 'number');
  assert_equals(typeof changes[0].ownContributionEstimate, 'number');
  assert_equals(changes[0].ownContributionEstimate, 0.5);
}, 'Basic functionality test');

pressure_test(async (t) => {
  await create_virtual_pressure_source('cpu');
  t.add_cleanup(async () => {
    await remove_virtual_pressure_source('cpu');
  });

  const changes = await new Promise((resolve, reject) => {
    const observer = new PressureObserver(resolve);
    t.add_cleanup(() => observer.disconnect());
    observer.observe('cpu').catch(reject);
    update_virtual_pressure_source('cpu', 'critical').catch(reject);
  });
  assert_equals(1, changes.length);
  assert_equals(changes[0].state, 'critical');
  assert_equals(changes[0].source, 'cpu');
  assert_equals(typeof changes[0].time, 'number');
  assert_equals(changes[0].ownContributionEstimate, null);
}, 'Basic functionality test with no ownContributionEstimate');

pressure_test(async (t) => {
  await create_virtual_pressure_source('cpu');
  t.add_cleanup(async () => {
+3 −3
Original line number Diff line number Diff line
@@ -19,15 +19,15 @@ pressure_test(async (t) => {
  const syncObserver = new SyncPressureObserver(t);
  await syncObserver.observer().observe('cpu');

  await update_virtual_pressure_source('cpu', 'critical');
  await update_virtual_pressure_source('cpu', 'critical', 0.2);
  await syncObserver.waitForUpdate();
  assert_equals(syncObserver.changes()[0][0].state, 'critical');

  await update_virtual_pressure_source('cpu', 'critical');
  await update_virtual_pressure_source('cpu', 'critical', 0.2);
  await new Promise(resolve => {t.step_timeout(resolve, 3000)});
  assert_equals(syncObserver.changes().length, 1);

  await update_virtual_pressure_source('cpu', 'nominal');
  await update_virtual_pressure_source('cpu', 'nominal'), 0.2;
  await syncObserver.waitForUpdate();
  assert_equals(syncObserver.changes()[1][0].state, 'nominal');

+2 −2
Original line number Diff line number Diff line
@@ -43,8 +43,8 @@ function remove_virtual_pressure_source(source) {
  return send_message({command: 'remove', params: [source]});
}

function update_virtual_pressure_source(source, state) {
  return send_message({command: 'update', params: [source, state]});
function update_virtual_pressure_source(source, state, estimate) {
  return send_message({command: 'update', params: [source, state, estimate]});
}

const uuid = new URLSearchParams(location.search).get('uuid');