blob: dd36b203995303f3eebb536e8cc3015c1043deca (
plain)
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
|
<!DOCTYPE html>
<meta charset="utf-8">
<script src="/resources/testharness.js"></script>
<script src="utils.js"></script>
<div id="target" style="width: 100px; height: 100px; position: fixed; top: 0px; left: 0px"></div>
<script>
let next_token = 0;
function init() {
const tokens = parseKeylist();
let observer = new IntersectionObserver((entries) => {
assert_equals(entries.length, 1);
let rect = entries[0].intersectionRect.x + "," +
entries[0].intersectionRect.y + "," +
entries[0].intersectionRect.width + "," +
entries[0].intersectionRect.height + "," +
entries[0].isVisible;
writeValueToServer(tokens[next_token], rect);
next_token = next_token + 1;
if (next_token == tokens.length) {
observer.disconnect();
}
}, {trackVisibility: true, delay: 100, threshold: [0.6, 0.75]});
observer.observe(document.getElementById("target"));
}
init();
</script>
</html>
|