Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(3)

Side by Side Diff: third_party/WebKit/LayoutTests/http/tests/intersection-observer/resources/cross-origin-subframe.html

Issue 1615573002: Set rootBounds to null for cross-origin observations. (Closed) Base URL: https://chromium.googlesource.com/chromium/src@master
Patch Set: Get rid of js-test.js monkey patching Created 4 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
1 <!DOCTYPE html>
2 <script src="helper-functions.js"></script>
3 <div style="height: 200px; width: 100px;"></div>
4 <div id="target" style="background-color: green; width:100px; height:100px"></di v>
5 <div style="height: 200px; width: 100px;"></div>
6 <script>
7 var port;
8 var entries = [];
9 var target = document.getElementById('target');
10 var scroller = document.scrollingElement;
11 var nextStep;
12
13 // Note that we never use RAF in this code, because this frame might get render- throttled.
14 // Instead of RAF-ing, we just post an empty message to the parent window, which will
15 // RAF when it is received, and then send us a message to cause the next step to run.
16
17 function observer_callback(changes) {
18 for (var i in changes)
19 entries.push(changes[i]);
20 }
21 var observer = new IntersectionObserver(observer_callback, {});
22 observer.observe(target);
23
24 function step0() {
25 setTimeout(function() {
26 nextStep = step1;
27 port.postMessage({actual: entries.map(entryToJson), expected: []}, "*");
28 entries = [];
29 port.postMessage({scrollTo: 200}, "*");
30 });
31 }
32
33 function step1() {
34 setTimeout(function() {
35 port.postMessage({actual: entries.map(entryToJson), expected: []}, "*");
36 entries = [];
37 scroller.scrollTop = 250;
38 nextStep = step2;
39 port.postMessage({}, "*");
40 });
41 }
42
43 function step2() {
44 setTimeout(function() {
45 var expected = [{
46 boundingClientRect: coordinatesToClientRectJson(468, 118, 568, 18),
47 intersectionRect: coordinatesToClientRectJson(510, 118, 568, 18),
48 rootBounds: "null",
49 target: target.id
50 }];
51 port.postMessage({actual: entries.map(entryToJson), expected: expected}, "*" );
52 entries = [];
53 nextStep = step3;
54 port.postMessage({scrollTo: 100}, "*");
55 });
56 }
57
58 function step3() {
59 setTimeout(function() {
60 var expected = [{
61 boundingClientRect: coordinatesToClientRectJson(568, 118, 668, 18),
62 intersectionRect: coordinatesToClientRectJson(0, 0, 0, 0),
63 rootBounds: "null",
64 target: target.id
65 }];
66 port.postMessage({actual: entries.map(entryToJson), expected: expected}, "*" );
67 port.postMessage({DONE: 1}, "*");
68 });
69 }
70
71 function handleMessage(event)
72 {
73 port = event.source;
74 nextStep();
75 }
76
77 nextStep = step0;
78 window.addEventListener("message", handleMessage);
79 </script>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698