summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/performance-timeline/performanceentry-tojson.any.js
blob: 44f0156eec19241970028c28e5897be4d6f1cb81 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
test(() => {
  performance.mark('markName');
  performance.measure('measureName');

  const entries = performance.getEntries();
  const performanceEntryKeys = [
    'name',
    'entryType',
    'startTime',
    'duration'
  ];
  for (let i = 0; i < entries.length; ++i) {
    assert_equals(typeof(entries[i].toJSON), 'function');
    const json = entries[i].toJSON();
    assert_equals(typeof(json), 'object');
    for (const key of performanceEntryKeys) {
      assert_equals(json[key], entries[i][key],
        `entries[${i}].toJSON().${key} should match entries[${i}].${key}`);
    }
  }
}, 'Test toJSON() in PerformanceEntry');