Bug 1610669 [wpt PR 21326] - Use assert_precondition in ElementTiming/LargestContentf...
[gecko.git] / testing / web-platform / tests / element-timing / observe-video-poster.html
blobf64da173c6f2daa2a811075a75b997982d0af73d
1 <!DOCTYPE HTML>
2 <meta charset=utf-8>
3 <title>Element Timing: observe video poster image</title>
4 <script src="/resources/testharness.js"></script>
5 <script src="/resources/testharnessreport.js"></script>
6 <script src="resources/element-timing-helpers.js"></script>
7 <script>
8 let beforeRender;
9 async_test(function (t) {
10 assert_precondition(window.PerformanceElementTiming, "PerformanceElementTiming is not implemented");
11 const observer = new PerformanceObserver(
12 t.step_func_done(function(entryList) {
13 assert_equals(entryList.getEntries().length, 1);
14 const entry = entryList.getEntries()[0];
15 const pathname = window.location.origin + '/element-timing/resources/circle.svg';
16 checkElement(entry, pathname, 'my_poster', 'the_poster', beforeRender,
17 document.getElementById('the_poster'));
18 // Assume viewport has size at least 200, so the element is fully visible.
19 checkRect(entry, [0, 200, 0, 200]);
20 checkNaturalSize(entry, 200, 200);
23 observer.observe({entryTypes: ['element']});
24 beforeRender = performance.now();
25 }, "Able to observe a video's poster image.");
26 </script>
27 <style>
28 body {
29 margin: 0;
31 </style>
32 <video elementtiming='my_poster' id='the_poster' src='/media/test.mp4' poster='resources/circle.svg'/>