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

Side by Side Diff: third_party/WebKit/LayoutTests/intersection-observer/helper-functions.js

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
(Empty)
1 // Some of the js-test.js boilerplate will add stuff to the top of the document early
2 // enough to screw with frame offsets that are measured by the test. Delay all that
3 // jazz until the actual test code is finished.
4 setPrintTestResultsLazily();
5 self.jsTestIsAsync = true;
6
7 function rectArea(rect) {
8 return (rect.left - rect.right) * (rect.bottom - rect.top);
9 }
10
11 function rectToString(rect) {
12 return "[" + rect.left + ", " + rect.right + ", " + rect.top + ", " + rect.bot tom + "]";
13 }
14
15 function entryToString(entry) {
16 var ratio = ((entry.intersectionRect.width * entry.intersectionRect.height) /
17 (entry.boundingClientRect.width * entry.boundingClientRect.height ));
18 return (
19 "boundingClientRect=" + rectToString(entry.boundingClientRect) + "\n" +
20 "intersectionRect=" + rectToString(entry.intersectionRect) + "\n" +
21 "visibleRatio=" + ratio + "\n" +
22 "rootBounds=" + rectToString(entry.rootBounds) + "\n" +
23 "target=" + entry.target + "\n" +
24 "time=" + entry.time);
25 }
26
27 function intersectionRatio(entry) {
28 var targetArea = rectArea(entry.boundingClientRect);
29 if (!targetArea)
30 return 0;
31 return rectArea(entry.intersectionRect) / targetArea;
32 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698