3 <title>Element Timing: toJSON
</title>
5 <script src=
"/resources/testharness.js"></script>
6 <script src=
"/resources/testharnessreport.js"></script>
7 <script src=
"resources/element-timing-helpers.js"></script>
8 <img elementtiming='img'
src=
"resources/square100.png"/>
10 async_test(function (t
) {
11 assert_precondition(window
.PerformanceElementTiming
, "PerformanceElementTiming is not implemented");
12 const observer
= new PerformanceObserver(
13 t
.step_func_done(function(entryList
) {
14 assert_equals(entryList
.getEntries().length
, 1);
15 const entry
= entryList
.getEntries()[0];
16 assert_equals(typeof(entry
.toJSON
), 'function');
17 const json
= entry
.toJSON();
18 assert_equals(typeof(json
), 'object');
25 // PerformanceElementTiming
36 for (const key
of keys
) {
37 assert_equals(json
[key
], entry
[key
],
38 'PerformanceElementTiming ${key} entry does not match its toJSON value');
42 observer
.observe({type
: 'element', buffered
: true});
43 }, 'Test toJSON() in PerformanceElementTiming.');