blob: 4433ecbc5f114604fec821622673ecf15bf6030d [file] [log] [blame]
Nicolás Peña Morenocf8e8812019-04-01 17:12:021<!DOCTYPE HTML>
2<meta charset=utf-8>
3<title>Element Timing: image with rotation.</title>
4<head>
5<style>
6body {
7 margin: 0px;
8}
9.my_div {
10 width: 100px;
11 height: 50px;
12 transform: rotate(45deg);
13 transform-origin: top left;
14}
15</style>
16</head>
17<body>
18<script src="/resources/testharness.js"></script>
19<script src="/resources/testharnessreport.js"></script>
20<script src="resources/element-timing-helpers.js"></script>
21<script>
22 const beforeRender = performance.now();
23 async_test(function (t) {
24 const observer = new PerformanceObserver(
25 t.step_func_done(function(entryList) {
26 assert_equals(entryList.getEntries().length, 1);
27 const entry = entryList.getEntries()[0];
28 const index = window.location.href.lastIndexOf('/');
29 const pathname = window.location.href.substring(0, index - 14) +
30 'images/black-rectangle.png';
Nicolás Peña Moreno66bb6b42019-05-01 17:40:5831 checkElement(entry, pathname, 'rectangle', 'rect_id', beforeRender,
32 document.getElementById('rect_id'));
Nicolás Peña Morenocf8e8812019-04-01 17:12:0233 checkNaturalSize(entry, 100, 50);
34 const rect = entry.intersectionRect;
35 // The div rotates with respect to the origin, so part of it will be invisible.
36 // The width of the visible part will be 100 / sqrt(2) and the height will be
37 // 100 / sqrt(2) + 50 / sqrt(2).
38 assert_equals(rect.left, 0);
39 // Checking precision only to the nearest integer.
40 assert_equals(Math.round(rect.right), 71);
41 assert_equals(rect.top, 0);
42 assert_equals(Math.round(rect.bottom), 106);
43 })
44 );
45 observer.observe({entryTypes: ['element']});
46 }, 'Image intersectionRect is affected by rotation, but not its intrinsic size.');
47</script>
Nicolás Peña Moreno15d28552019-04-01 19:03:0848<div class="my_div" id="div_id">
49 <img src="/images/black-rectangle.png" elementtiming="rectangle" id="rect_id"/>
Nicolás Peña Morenocf8e8812019-04-01 17:12:0250</div>
51</body>