diff options
Diffstat (limited to 'testing/web-platform/tests/user-timing/user-timing-tojson.html')
-rw-r--r-- | testing/web-platform/tests/user-timing/user-timing-tojson.html | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/testing/web-platform/tests/user-timing/user-timing-tojson.html b/testing/web-platform/tests/user-timing/user-timing-tojson.html new file mode 100644 index 0000000000..6aef7fa904 --- /dev/null +++ b/testing/web-platform/tests/user-timing/user-timing-tojson.html @@ -0,0 +1,44 @@ +<!doctype html> +<html> +<head> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +</head> +<body> +<script> +const keys = [ + 'name', + 'entryType', + 'startTime', + 'duration', +]; +test(() => { + performance.mark('a'); + const markEntries = performance.getEntriesByType('mark'); + assert_equals(1, markEntries.length); + const markEntry = markEntries[0]; + assert_equals(markEntry.entryType, 'mark'); + assert_equals(typeof(markEntry.toJSON), 'function'); + const markJSON = markEntry.toJSON(); + assert_equals(typeof(markJSON), 'object'); + for (const key of keys) { + assert_equals(markJSON[key], markEntry[key], `PerformanceMark ${key} entry does not match its toJSON value`); + } +}, 'Test toJSON() in PerformanceMark'); + +test(() => { + performance.measure('m'); + const measureEntries = performance.getEntriesByType('measure'); + assert_equals(1, measureEntries.length); + const measureEntry = measureEntries[0]; + assert_equals(measureEntry.entryType, 'measure'); + assert_equals(typeof(measureEntry.toJSON), 'function'); + const measureJSON = measureEntry.toJSON(); + assert_equals(typeof(measureJSON), 'object'); + for (const key of keys) { + assert_equals(measureJSON[key], measureEntry[key], `PerformanceMeasure ${key} entry does not match its toJSON value`); + } +}, 'Test toJSON() in PerformanceMeasure'); +</script> +</body> +</html> |