commit 0e9e3e91a79560f9406400f66722b509e93339db
parent e1140b43b14e9d0da34be7f4207ba9e8440fac15
Author: Nikolaos Papaspyrou <nikolaos@chromium.org>
Date: Wed, 15 Oct 2025 08:23:47 +0000
Bug 1993569 [wpt PR 55309] - cpu_performance: Add prototype implementation, a=testonly
Automatic update from web-platform-tests
cpu_performance: Add prototype implementation
This CL adds a prototype implementation for a new Web API that exposes
some information about how powerful the user device is, targeting
applications that will use this information to provide an improved
user experience. It is currently implemented behind the runtime flag
--enable-features=CpuPerformance.
The API exposes navigator.cpuPerformance, which is a small integer
number corresponding to the user device's "performance tier" (similarly
to navigator.deviceMemory). The prototype implementation simply
classifies user devices in five tiers (1-4, denoting increasing
performance; 0 for unknown), based on the number of CPU cores.
The plan is to allow embedders to override this default with more
complicated, implementation-specific behaviour (to be implemented
in a subsequent CL).
Chrome Status entry: https://chromestatus.com/feature/5189864286978048
Explainer: https://github.com/explainers-by-googlers/cpu-performance
Change-Id: Ie711d0de89c44ee621c72271f5a98a0a32d64365
Bug: 449760252
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6780564
Commit-Queue: Nikolaos Papaspyrou <nikolaos@chromium.org>
Reviewed-by: Dominic Farolino <dom@chromium.org>
Reviewed-by: Michael Lippautz <mlippautz@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1527714}
--
wpt-commits: 6cdc155f1d15000fb6e25dcc6d555f0f01e278dd
wpt-pr: 55309
Diffstat:
2 files changed, 10 insertions(+), 0 deletions(-)
diff --git a/testing/web-platform/tests/cpu-performance/META.yml b/testing/web-platform/tests/cpu-performance/META.yml
@@ -0,0 +1,2 @@
+suggested_reviewers:
+ - nickie
diff --git a/testing/web-platform/tests/cpu-performance/cpu-performance.tentative.https.window.js b/testing/web-platform/tests/cpu-performance/cpu-performance.tentative.https.window.js
@@ -0,0 +1,8 @@
+test(function () {
+ assert_equals(typeof navigator.cpuPerformance, "number",
+ "navigator.cpuPerformance returns a number");
+ assert_true(Number.isInteger(navigator.cpuPerformance),
+ "navigator.cpuPerformance returns an integer value");
+ assert_true(navigator.cpuPerformance >= 0,
+ "navigator.cpuPerformance returns a non-negative value");
+}, "navigator.cpuPerformance is valid, if the feature is enabled");