|
| 1 | +<!DOCTYPE html> |
| 2 | +<meta name="viewport" content="width=device-width,initial-scale=1"> |
| 3 | +<script src="/resources/testharness.js"></script> |
| 4 | +<script src="/resources/testharnessreport.js"></script> |
| 5 | +<script src="./resources/intersection-observer-test-utils.js"></script> |
| 6 | + |
| 7 | +<style> |
| 8 | +pre, #log { |
| 9 | + position: absolute; |
| 10 | + top: 0; |
| 11 | + left: 200px; |
| 12 | +} |
| 13 | +iframe { |
| 14 | + width: 160px; |
| 15 | + height: 100px; |
| 16 | + overflow-y: scroll; |
| 17 | +} |
| 18 | +.spacer { |
| 19 | + height: calc(100vh + 100px); |
| 20 | +} |
| 21 | +</style> |
| 22 | + |
| 23 | +<div class="spacer"></div> |
| 24 | +<iframe src="http://{{hosts[][www1]}}:{{ports[http][0]}}/intersection-observer/resources/cross-origin-subframe.html" sandbox="allow-scripts"></iframe> |
| 25 | +<div class="spacer"></div> |
| 26 | + |
| 27 | +<script> |
| 28 | +async_test(function(t) { |
| 29 | + var iframe = document.querySelector("iframe"); |
| 30 | + |
| 31 | + function handleMessage(event) { |
| 32 | + if (event.data.hasOwnProperty('scrollTo')) { |
| 33 | + document.scrollingElement.scrollTop = event.data.scrollTo; |
| 34 | + waitForNotification(t, function() { iframe.contentWindow.postMessage("", "*"); }, |
| 35 | + "document.scrollingElement.scrollTop = " + event.data.scrollTo); |
| 36 | + } else if (event.data.hasOwnProperty('actual')) { |
| 37 | + checkJsonEntries(event.data.actual, event.data.expected, event.data.description); |
| 38 | + } else if (event.data.hasOwnProperty('DONE')) { |
| 39 | + document.scrollingElement.scrollTop = 0; |
| 40 | + t.done(); |
| 41 | + } else { |
| 42 | + var description = event.data.description; |
| 43 | + waitForNotification(t, function() { iframe.contentWindow.postMessage("", "*"); }, description); |
| 44 | + } |
| 45 | + } |
| 46 | + |
| 47 | + window.addEventListener("message", t.step_func(handleMessage)); |
| 48 | + |
| 49 | + iframe.onload = t.step_func(function() { |
| 50 | + waitForNotification(t, function() { iframe.contentWindow.postMessage("", "*") }, "setup"); |
| 51 | + }); |
| 52 | +}, "Intersection observer test with no explicit root and target in a cross-origin iframe."); |
| 53 | +</script> |
0 commit comments