blob: bd7e478aa264a7e48cf799f590387d0509abd6fb [file] [log] [blame]
spanickera5b95cb2017-03-10 22:42:551<!DOCTYPE HTML>
2<meta charset=utf-8>
3<title>LongTask Timing: validate long task attributes</title>
4<body>
5
6<script src="/resources/testharness.js"></script>
7<script src="/resources/testharnessreport.js"></script>
8
9<h1>Long Task Attributes</h1>
10<div id="log"></div>
11<script>
12 async_test(function (t) {
Nicolas Penacd751192018-07-10 21:05:2713 if (typeof PerformanceLongTaskTiming === 'undefined') {
14 assert_unreached("Longtasks are not supported.");
15 t.done();
16 }
npm@chromium.org71ff8882017-08-15 17:22:0117 const observer = new PerformanceObserver(
spanickera5b95cb2017-03-10 22:42:5518 t.step_func(function (entryList) {
npm@chromium.org71ff8882017-08-15 17:22:0119 const entries = entryList.getEntries();
spanickera5b95cb2017-03-10 22:42:5520 assert_equals(entries.length, 1,
npm@chromium.org71ff8882017-08-15 17:22:0121 'Exactly one entry is expected.');
22 const longtask = entries[0];
23 assert_equals(longtask.entryType, 'longtask');
24 assert_equals(longtask.name, 'self');
spanickera5b95cb2017-03-10 22:42:5525 assert_greater_than(longtask.duration, 50);
npm@chromium.org71ff8882017-08-15 17:22:0126 assert_greater_than_equal(longtask.startTime, 0);
27 const currentTime = performance.now();
28 assert_less_than_equal(longtask.startTime, currentTime);
spanickera5b95cb2017-03-10 22:42:5529
30 // Assert the TaskAttributionTiming entry in attribution.
31 assert_equals(longtask.attribution.length, 1,
npm@chromium.org71ff8882017-08-15 17:22:0132 'Exactly one attribution entry is expected');
33 const attribution = longtask.attribution[0];
34 assert_equals(attribution.entryType, 'taskattribution');
35 assert_equals(attribution.name, 'script');
spanickera5b95cb2017-03-10 22:42:5536 assert_equals(attribution.duration, 0);
37 assert_equals(attribution.startTime, 0);
npm@chromium.org71ff8882017-08-15 17:22:0138 assert_equals(attribution.containerId, '');
39 assert_equals(attribution.containerName, '');
40 assert_equals(attribution.containerSrc, '');
spanickera5b95cb2017-03-10 22:42:5541 observer.disconnect();
42 t.done();
43 })
44 );
npm@chromium.org71ff8882017-08-15 17:22:0145 observer.observe({entryTypes: ['longtask']});
spanickera5b95cb2017-03-10 22:42:5546
47 /* Generate a slow task */
npm@chromium.org71ff8882017-08-15 17:22:0148 const begin = window.performance.now();
spanickera5b95cb2017-03-10 22:42:5549 while (window.performance.now() < begin + 51);
50
npm@chromium.org71ff8882017-08-15 17:22:0151}, 'Performance longtask entries are observable.');
spanickera5b95cb2017-03-10 22:42:5552</script>
53
54</body>