| OLD | NEW |
| (Empty) | |
| 1 <!DOCTYPE html> |
| 2 <script src="../resources/testharness.js"></script> |
| 3 <script src="../resources/testharnessreport.js"></script> |
| 4 |
| 5 <style> |
| 6 pre, #log { |
| 7 position: absolute; |
| 8 top: 0; |
| 9 left: 200px; |
| 10 } |
| 11 iframe { |
| 12 width: 200px; |
| 13 height: 140px; |
| 14 overflow-y: hidden; |
| 15 } |
| 16 .spacer { |
| 17 height: 700px; |
| 18 } |
| 19 </style> |
| 20 |
| 21 <div class="spacer"></div> |
| 22 <iframe src="http://localhost:8080/intersection-observer/resources/nesting-cross
-origin-subframe.html"></iframe> |
| 23 <div class="spacer"></div> |
| 24 |
| 25 <script> |
| 26 |
| 27 // These helper functions are taken from |
| 28 // intersection-observer/resources/intersection-observer-test-utils.js, |
| 29 // which isn't available to http tests. |
| 30 function waitForNotification(f) { |
| 31 requestAnimationFrame(function () { |
| 32 setTimeout(function () { setTimeout(f); }); |
| 33 }); |
| 34 } |
| 35 |
| 36 function checkRect(actual, expected, description) { |
| 37 if (!expected.length) |
| 38 return; |
| 39 assert_equals(actual.left, expected[0], description + '.left'); |
| 40 assert_equals(actual.right, expected[1], description + '.right'); |
| 41 assert_equals(actual.top, expected[2], description + '.top'); |
| 42 assert_equals(actual.bottom, expected[3], description + '.bottom'); |
| 43 } |
| 44 |
| 45 function checkJsonEntry(actual, expected) { |
| 46 checkRect( |
| 47 actual.boundingClientRect, expected.boundingClientRect, |
| 48 'entry.boundingClientRect'); |
| 49 checkRect( |
| 50 actual.intersectionRect, expected.intersectionRect, |
| 51 'entry.intersectionRect'); |
| 52 if (actual.rootBounds == 'null') |
| 53 assert_equals(expected.rootBounds, 'null', 'rootBounds is null'); |
| 54 else |
| 55 checkRect(actual.rootBounds, expected.rootBounds, 'entry.rootBounds'); |
| 56 assert_equals(actual.target, expected.target); |
| 57 } |
| 58 |
| 59 function checkJsonEntries(actual, expected, description) { |
| 60 test(function () { |
| 61 assert_equals(actual.length, expected.length); |
| 62 for (var i = 0; i < actual.length; i++) |
| 63 checkJsonEntry(actual[i], expected[i]); |
| 64 }, description); |
| 65 } |
| 66 |
| 67 async_test(function(t) { |
| 68 var iframe = document.querySelector("iframe"); |
| 69 |
| 70 assert_equals(window.innerWidth, 800, "Window must be 800 pixels wide."); |
| 71 assert_equals(window.innerHeight, 600, "Window must be 600 pixels high."); |
| 72 |
| 73 function handleMessage(event) { |
| 74 if (event.data.hasOwnProperty('ACK')) { |
| 75 waitForNotification(function () { iframe.contentWindow.postMessage({ ACK:
1 }, "*"); }, |
| 76 "Message acknowledged"); |
| 77 } else if (event.data.hasOwnProperty('scrollTo')) { |
| 78 document.scrollingElement.scrollTop = event.data.scrollTo; |
| 79 waitForNotification(function() { iframe.contentWindow.postMessage("", "*")
; }, |
| 80 "document.scrollingElement.scrollTop = " + event.data.scrollTo); |
| 81 } else if (event.data.hasOwnProperty('actual')) { |
| 82 checkJsonEntries(event.data.actual, event.data.expected, event.data.descri
ption); |
| 83 } else if (event.data.hasOwnProperty('DONE')) { |
| 84 document.scrollingElement.scrollTop = 0; |
| 85 t.done(); |
| 86 } else { |
| 87 var description = event.data.description; |
| 88 waitForNotification(function() { iframe.contentWindow.postMessage("", "*")
; }, description); |
| 89 } |
| 90 } |
| 91 |
| 92 window.addEventListener("message", t.step_func(handleMessage)); |
| 93 |
| 94 iframe.onload = t.step_func(function() { |
| 95 waitForNotification(function() { iframe.contentWindow.postMessage("", "*") }
, "setup"); |
| 96 }); |
| 97 }, "Intersection observer test with target in nested cross-origin subframes, pot
entially rendered in other processes."); |
| 98 </script> |
| OLD | NEW |