11cb0ef41Sopenharmony_ci<!doctype html>
21cb0ef41Sopenharmony_ci<html>
31cb0ef41Sopenharmony_ci<head>
41cb0ef41Sopenharmony_ci<script src="/resources/testharness.js"></script>
51cb0ef41Sopenharmony_ci<script src="/resources/testharnessreport.js"></script>
61cb0ef41Sopenharmony_ci</head>
71cb0ef41Sopenharmony_ci<body>
81cb0ef41Sopenharmony_ci<script>
91cb0ef41Sopenharmony_ciconst keys = [
101cb0ef41Sopenharmony_ci  'name',
111cb0ef41Sopenharmony_ci  'entryType',
121cb0ef41Sopenharmony_ci  'startTime',
131cb0ef41Sopenharmony_ci  'duration',
141cb0ef41Sopenharmony_ci];
151cb0ef41Sopenharmony_citest(() => {
161cb0ef41Sopenharmony_ci  performance.mark('a');
171cb0ef41Sopenharmony_ci  const markEntries = performance.getEntriesByType('mark');
181cb0ef41Sopenharmony_ci  assert_equals(1, markEntries.length);
191cb0ef41Sopenharmony_ci  const markEntry = markEntries[0];
201cb0ef41Sopenharmony_ci  assert_equals(markEntry.entryType, 'mark');
211cb0ef41Sopenharmony_ci  assert_equals(typeof(markEntry.toJSON), 'function');
221cb0ef41Sopenharmony_ci  const markJSON = markEntry.toJSON();
231cb0ef41Sopenharmony_ci  assert_equals(typeof(markJSON), 'object');
241cb0ef41Sopenharmony_ci  for (const key of keys) {
251cb0ef41Sopenharmony_ci    assert_equals(markJSON[key], markEntry[key], `PerformanceMark ${key} entry does not match its toJSON value`);
261cb0ef41Sopenharmony_ci  }
271cb0ef41Sopenharmony_ci}, 'Test toJSON() in PerformanceMark');
281cb0ef41Sopenharmony_ci
291cb0ef41Sopenharmony_citest(() => {
301cb0ef41Sopenharmony_ci  performance.measure('m');
311cb0ef41Sopenharmony_ci  const measureEntries = performance.getEntriesByType('measure');
321cb0ef41Sopenharmony_ci  assert_equals(1, measureEntries.length);
331cb0ef41Sopenharmony_ci  const measureEntry = measureEntries[0];
341cb0ef41Sopenharmony_ci  assert_equals(measureEntry.entryType, 'measure');
351cb0ef41Sopenharmony_ci  assert_equals(typeof(measureEntry.toJSON), 'function');
361cb0ef41Sopenharmony_ci  const measureJSON = measureEntry.toJSON();
371cb0ef41Sopenharmony_ci  assert_equals(typeof(measureJSON), 'object');
381cb0ef41Sopenharmony_ci  for (const key of keys) {
391cb0ef41Sopenharmony_ci    assert_equals(measureJSON[key], measureEntry[key], `PerformanceMeasure ${key} entry does not match its toJSON value`);
401cb0ef41Sopenharmony_ci  }
411cb0ef41Sopenharmony_ci}, 'Test toJSON() in PerformanceMeasure');
421cb0ef41Sopenharmony_ci</script>
431cb0ef41Sopenharmony_ci</body>
441cb0ef41Sopenharmony_ci</html>
45