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

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

Issue 1983383002: Convert IntersectionObserver tests to use testRunner.runIdleTasks. (Closed) Base URL: https://chromium.googlesource.com/chromium/src@master
Patch Set: rebase Created 4 years, 7 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
1 <!DOCTYPE html> 1 <!DOCTYPE html>
2 <script src="/js-test-resources/js-test.js"></script> 2 <script src="/js-test-resources/js-test.js"></script>
3 <script src="/js-test-resources/intersection-observer-helper-functions.js"></scr ipt>
3 <div style="width:100%; height:700px;"></div> 4 <div style="width:100%; height:700px;"></div>
4 <iframe id="target-iframe" src="http://localhost:8080/intersection-observer/reso urces/cross-origin-subframe.html" style="height: 100px; overflow-y: scroll"></if rame> 5 <iframe id="target-iframe" src="http://localhost:8080/intersection-observer/reso urces/cross-origin-subframe.html" style="height: 100px; overflow-y: scroll"></if rame>
5 <div style="width:100%; height:700px;"></div> 6 <div style="width:100%; height:700px;"></div>
6 7
7 <script> 8 <script>
8 setPrintTestResultsLazily();
9 self.jsTestIsAsync = true;
10
11 description("Simple intersection observer test with no explicit root and target in a cross-origin iframe."); 9 description("Simple intersection observer test with no explicit root and target in a cross-origin iframe.");
12 10
13 var iframe = document.getElementById("target-iframe"); 11 var iframe = document.getElementById("target-iframe");
14 var actual; 12 var actual;
15 13
16 function checkData(actualData, expected) { 14 function checkData(actualData, expected) {
17 actual = actualData; 15 actual = actualData;
18 shouldBeEqualToNumber("actual.length", expected.length); 16 shouldBeEqualToNumber("actual.length", expected.length);
19 for (var i = 0; i < actualData.length && i < expected.length; i++) { 17 for (var i = 0; i < actualData.length && i < expected.length; i++) {
20 actual = actualData[i]; 18 actual = actualData[i];
(...skipping 21 matching lines...) Expand all
42 shouldBeEqualToNumber("actual.rootBounds.width", expected[i].rootBounds.wi dth); 40 shouldBeEqualToNumber("actual.rootBounds.width", expected[i].rootBounds.wi dth);
43 shouldBeEqualToNumber("actual.rootBounds.height", expected[i].rootBounds.h eight); 41 shouldBeEqualToNumber("actual.rootBounds.height", expected[i].rootBounds.h eight);
44 } 42 }
45 shouldBeEqualToString("actual.target", expected[i].target); 43 shouldBeEqualToString("actual.target", expected[i].target);
46 } 44 }
47 } 45 }
48 46
49 function handleMessage(event) { 47 function handleMessage(event) {
50 if (event.data.hasOwnProperty('scrollTo')) { 48 if (event.data.hasOwnProperty('scrollTo')) {
51 document.scrollingElement.scrollTop = event.data.scrollTo; 49 document.scrollingElement.scrollTop = event.data.scrollTo;
52 requestAnimationFrame(function () { iframe.contentWindow.postMessage("", "*" ) }); 50 waitForNotification(() => { iframe.contentWindow.postMessage("", "*") });
53 } else if (event.data.hasOwnProperty('actual')) { 51 } else if (event.data.hasOwnProperty('actual')) {
54 checkData(event.data.actual, event.data.expected); 52 checkData(event.data.actual, event.data.expected);
55 } else if (event.data.hasOwnProperty('DONE')) { 53 } else if (event.data.hasOwnProperty('DONE')) {
56 finishJSTest(); 54 finishJSTest();
57 document.scrollingElement.scrollTop = 0; 55 document.scrollingElement.scrollTop = 0;
58 } else { 56 } else {
59 requestAnimationFrame(function () { iframe.contentWindow.postMessage("", "*" ) }); 57 waitForNotification(() => { iframe.contentWindow.postMessage("", "*") });
60 } 58 }
61 } 59 }
62 60
63 window.addEventListener("message", handleMessage); 61 window.addEventListener("message", handleMessage);
64 62
65 iframe.onload = function() { 63 iframe.onload = (() => {
66 // See LayoutTests/intersection-observer/README for explanation of double RAF. 64 waitForNotification(() => { iframe.contentWindow.postMessage("", "*") });
67 requestAnimationFrame(() => { 65 });
68 requestAnimationFrame(() => { iframe.contentWindow.postMessage("", "*") })
69 });
70 }
71 </script> 66 </script>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698