Files
sousa-gecko/testing/web-platform/tests/device-memory/device-memory.https.any.js
T
Barry Pollard 1d96042631 Bug 2011719 [wpt PR 57280] - Update DeviceMemory thresholds, a=testonly
Automatic update from web-platform-tests
Update DeviceMemory thresholds

I2S: https://groups.google.com/a/chromium.org/g/blink-dev/c/vXtAmrVZeDk
Change-Id: I3d54bb17743517a8e34078ef28dacc2774037380
Bug: 454354290
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/7410045
Commit-Queue: Barry Pollard <barrypollard@chromium.org>
Reviewed-by: Yoav Weiss (@Shopify) <yoavweiss@chromium.org>
Reviewed-by: Michal Mocny <mmocny@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1573800}

--

wpt-commits: 3fd3ec14179d4301a47953f947e0686649db65d9
wpt-pr: 57280
2026-01-27 08:12:39 +00:00

18 lines
767 B
JavaScript

function isPowerOfTwo(n) {
const log2 = Math.log2(n);
return log2 == Math.ceil(log2);
}
// Note the spec suggests applying implementation-defined min and max limits
// to reduce fingerprinting risk for less common memory configurations.
// However, it does not recommend limits so these are not tested in WPT.
// These should be tested by implementors.
test(function() {
assert_equals(typeof navigator.deviceMemory, "number",
"navigator.deviceMemory returns a number");
assert_true(navigator.deviceMemory >= 0,
"navigator.deviceMemory returns a positive value");
assert_true(isPowerOfTwo(navigator.deviceMemory),
"navigator.deviceMemory returns a power of 2");
}, "navigator.deviceMemory is a positive number, a power of 2");