Bug 1686029 [wpt PR 27131] - Mark performance.measureMemory web-platform tests as...
[gecko.git] / testing / web-platform / tests / measure-memory / randomized-breakdown.https.window.js
blobe3a65c1ba2a6a90c142b9c2da3368fc949c874b7
1 // META: script=/common/get-host-info.sub.js
2 // META: script=./resources/common.js
3 // META: timeout=long
4 'use strict';
6 function indexOfEmptyEntry(result) {
7   return result.breakdown.findIndex(isEmptyBreakdownEntry);
10 assert_true(self.crossOriginIsolated);
11 promise_test(async testCase => {
12   const initial = await performance.measureMemory();
13   let observed_different_order = false;
14   for (let i = 0; i < 100; ++i) {
15     const current = await performance.measureMemory();
16     if (indexOfEmptyEntry(initial) != indexOfEmptyEntry(current)) {
17       observed_different_order = true;
18     }
19   }
20   // The order of the breakdown entries must be randomized.
21   // A conforming implementation may fail the following assert with
22   // the probability of at most 2^-100 since there are at least two
23   // entries in the breakdown.
24   assert_true(observed_different_order);
25 }, 'Well-formed result of performance.measureMemory.');