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

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: 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 <div style="width:100%; height:700px;"></div> 3 <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> 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 <div style="width:100%; height:700px;"></div> 5 <div style="width:100%; height:700px;"></div>
6 6
7 <script> 7 <script>
8 setPrintTestResultsLazily(); 8 setPrintTestResultsLazily();
9 self.jsTestIsAsync = true; 9 self.jsTestIsAsync = true;
10 10
11 description("Simple intersection observer test with no explicit root and target in a cross-origin iframe."); 11 description("Simple intersection observer test with no explicit root and target in a cross-origin iframe.");
12 12
13 function waitForNotification(f) {
14 requestAnimationFrame(() => {
15 setTimeout(() => {
16 if (self.testRunner)
17 testRunner.runIdleTasks(f);
18 else
19 requestIdleCallback(f);
20 })
Sami 2016/05/18 10:07:23 nit: missing ';' (in other copy too) I guess ther
szager1 2016/05/18 21:25:27 Done.
21 });
22 }
23
13 var iframe = document.getElementById("target-iframe"); 24 var iframe = document.getElementById("target-iframe");
14 var actual; 25 var actual;
15 26
16 function checkData(actualData, expected) { 27 function checkData(actualData, expected) {
17 actual = actualData; 28 actual = actualData;
18 shouldBeEqualToNumber("actual.length", expected.length); 29 shouldBeEqualToNumber("actual.length", expected.length);
19 for (var i = 0; i < actualData.length && i < expected.length; i++) { 30 for (var i = 0; i < actualData.length && i < expected.length; i++) {
20 actual = actualData[i]; 31 actual = actualData[i];
21 shouldBeEqualToNumber("actual.boundingClientRect.left", expected[i].bounding ClientRect.left); 32 shouldBeEqualToNumber("actual.boundingClientRect.left", expected[i].bounding ClientRect.left);
22 shouldBeEqualToNumber("actual.boundingClientRect.top", expected[i].boundingC lientRect.top); 33 shouldBeEqualToNumber("actual.boundingClientRect.top", expected[i].boundingC lientRect.top);
(...skipping 19 matching lines...) Expand all
42 shouldBeEqualToNumber("actual.rootBounds.width", expected[i].rootBounds.wi dth); 53 shouldBeEqualToNumber("actual.rootBounds.width", expected[i].rootBounds.wi dth);
43 shouldBeEqualToNumber("actual.rootBounds.height", expected[i].rootBounds.h eight); 54 shouldBeEqualToNumber("actual.rootBounds.height", expected[i].rootBounds.h eight);
44 } 55 }
45 shouldBeEqualToString("actual.target", expected[i].target); 56 shouldBeEqualToString("actual.target", expected[i].target);
46 } 57 }
47 } 58 }
48 59
49 function handleMessage(event) { 60 function handleMessage(event) {
50 if (event.data.hasOwnProperty('scrollTo')) { 61 if (event.data.hasOwnProperty('scrollTo')) {
51 document.scrollingElement.scrollTop = event.data.scrollTo; 62 document.scrollingElement.scrollTop = event.data.scrollTo;
52 requestAnimationFrame(function () { iframe.contentWindow.postMessage("", "*" ) }); 63 waitForNotification(() => { iframe.contentWindow.postMessage("", "*") });
53 } else if (event.data.hasOwnProperty('actual')) { 64 } else if (event.data.hasOwnProperty('actual')) {
54 checkData(event.data.actual, event.data.expected); 65 checkData(event.data.actual, event.data.expected);
55 } else if (event.data.hasOwnProperty('DONE')) { 66 } else if (event.data.hasOwnProperty('DONE')) {
56 finishJSTest(); 67 finishJSTest();
57 document.scrollingElement.scrollTop = 0; 68 document.scrollingElement.scrollTop = 0;
58 } else { 69 } else {
59 requestAnimationFrame(function () { iframe.contentWindow.postMessage("", "*" ) }); 70 waitForNotification(() => { iframe.contentWindow.postMessage("", "*") });
60 } 71 }
61 } 72 }
62 73
63 window.addEventListener("message", handleMessage); 74 window.addEventListener("message", handleMessage);
64 75
65 iframe.onload = function() { 76 iframe.onload = (() => {
66 // See LayoutTests/intersection-observer/README for explanation of double RAF. 77 waitForNotification(() => { iframe.contentWindow.postMessage("", "*") });
67 requestAnimationFrame(() => { 78 });
68 requestAnimationFrame(() => { iframe.contentWindow.postMessage("", "*") })
69 });
70 }
71 </script> 79 </script>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698