summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/intersection-observer/resources/v2-subframe.html
diff options
context:
space:
mode:
Diffstat (limited to 'testing/web-platform/tests/intersection-observer/resources/v2-subframe.html')
-rw-r--r--testing/web-platform/tests/intersection-observer/resources/v2-subframe.html32
1 files changed, 32 insertions, 0 deletions
diff --git a/testing/web-platform/tests/intersection-observer/resources/v2-subframe.html b/testing/web-platform/tests/intersection-observer/resources/v2-subframe.html
new file mode 100644
index 0000000000..295bbf047e
--- /dev/null
+++ b/testing/web-platform/tests/intersection-observer/resources/v2-subframe.html
@@ -0,0 +1,32 @@
+<!DOCTYPE html>
+<div id="target">target</div>
+<script>
+var delay = 100;
+var results = [];
+
+function waitForNotification(f) {
+ setTimeout(() => {
+ requestAnimationFrame(function () {
+ requestAnimationFrame(function () {
+ setTimeout(f)
+ })
+ })
+ }, delay)
+}
+
+window.addEventListener("message", event => {
+ waitForNotification(() => {
+ window.parent.postMessage(results.map(e => e.isVisible), "*");
+ results = [];
+ });
+});
+
+onload = () => {
+ var target = document.getElementById("target");
+ var observer = new IntersectionObserver(entries => {
+ results = entries;
+ }, {trackVisibility: true, delay: delay});
+ observer.observe(document.getElementById("target"));
+ window.parent.postMessage("", "*");
+};
+</script>