forked from web-platform-tests/wpt
-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathroot-is-table-with-overflow-scroll.html
More file actions
73 lines (68 loc) · 2.39 KB
/
root-is-table-with-overflow-scroll.html
File metadata and controls
73 lines (68 loc) · 2.39 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
<!DOCTYPE html>
<title>IntersectionObserver observing table with border and overflow scroll</title>
<link rel="author" href="mailto:steven.novaryo@gmail.com" title="Steven Novaryo">
<link rel="help" href="https://w3c.github.io/IntersectionObserver/#intersectionobserver-root-intersection-rectangle">
<link rel="help" href="https://drafts.csswg.org/css-tables/#global-style-overrides">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="./resources/intersection-observer-test-utils.js"></script>
<style>
#root {
box-sizing: border-box;
overflow: scroll;
border: 50px solid black;
will-change: transform;
}
#target {
display: inline-block;
width: 50px;
height: 50px;
position: absolute;
top: 300px;
left: 300px;
background-color: green;
}
</style>
<table id="root">
<tr>
<td>
<span id="target"></span>
</td>
</tr>
</table>
<script>
var entries = [];
var rootRect = root.getBoundingClientRect();
runTestCycle(function() {
assert_true(!!target, "target exists");
var observer = new IntersectionObserver(function(changes) {
entries = entries.concat(changes)
}, { root: root });
observer.observe(target);
entries = entries.concat(observer.takeRecords());
assert_equals(entries.length, 0, "No initial notifications.");
runTestCycle(step0, "First rAF.");
}, "IntersectionObserver observing an element inside a root table.");
function step0() {
// To reduce the inconsistencies of the layout within different UAs we are calculating the offset dynamically.
var targetRect = target.getBoundingClientRect();
target.style.top = `${300 - (targetRect.top - rootRect.bottom + 50)}px`;
target.style.left = `${300 - (targetRect.left - rootRect.right + 50)}px`;
runTestCycle(step1, "Moving the target to the right bottom corner of the table.");
checkLastEntry(entries, 0, [
targetRect.left, targetRect.right, targetRect.top, targetRect.bottom,
0, 0, 0, 0,
rootRect.left, rootRect.right, rootRect.top, rootRect.bottom,
false
]);
}
function step1() {
var targetRect = target.getBoundingClientRect();
checkLastEntry(entries, 1, [
targetRect.left, targetRect.right, targetRect.top, targetRect.bottom,
targetRect.left, targetRect.right, targetRect.top, targetRect.bottom,
rootRect.left, rootRect.right, rootRect.top, rootRect.bottom,
true
]);
}
</script>