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

Unified Diff: third_party/WebKit/LayoutTests/resources/intersection-observer-helper-functions.js

Issue 2560253004: IntersectionObserver: convert tests to testharness.js (Closed)
Patch Set: Address comments Created 3 years, 11 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 side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/LayoutTests/resources/intersection-observer-helper-functions.js
diff --git a/third_party/WebKit/LayoutTests/resources/intersection-observer-helper-functions.js b/third_party/WebKit/LayoutTests/resources/intersection-observer-helper-functions.js
deleted file mode 100644
index d0d31fcacb1d58ef7415b1bb7686547358301501..0000000000000000000000000000000000000000
--- a/third_party/WebKit/LayoutTests/resources/intersection-observer-helper-functions.js
+++ /dev/null
@@ -1,99 +0,0 @@
-// Some of the js-test.js boilerplate will add stuff to the top of the document early
-// enough to screw with frame offsets that are measured by the test. Delay all that
-// jazz until the actual test code is finished.
-if (self.isJsTest) {
- setPrintTestResultsLazily();
- self.jsTestIsAsync = true;
-}
-
-// waitForNotification is a setTimeout wrapped in a setTimeout wrapped in a
-// requestAnimationFrame. What in the wide, wide world of sports is going on here?
-//
-// Here's the order of events:
-//
-// - firstTestFunction
-// - Change layout to generate new IntersectionObserver notifications.
-// - waitForNotification(secondTestFunction)
-// - requestAnimationFrame
-// - BeginFrame
-// - requestAnimationFrame handler runs.
-// - queue first setTimeout
-// - FrameView::updateAllLifecyclePhases
-// - IntersectionObserver generates notification based on the new layout.
-// - Post task to deliver notification.
-// - first setTimeout runs.
-// - queue second setTimeout
-// - Posted task runs.
-// - IntersectionObserver notifications are delivered.
-// - second setTimeout runs secondTestFunction
-// - Verify notifications generated by firstTestFunction.
-// - Change layout to generate new IntersectionObserver notifications.
-// - waitForNotification(thirdTestFunction)
-function waitForNotification(f) {
- requestAnimationFrame(() => {
- setTimeout(() => {
- setTimeout(f);
- });
- });
-}
-
-function rectToString(rect) {
- return "[" + rect.left + ", " + rect.right + ", " + rect.top + ", " + rect.bottom + "]";
-}
-
-function entryToString(entry) {
- var ratio = ((entry.intersectionRect.width * entry.intersectionRect.height) /
- (entry.boundingClientRect.width * entry.boundingClientRect.height));
- return (
- "boundingClientRect=" + rectToString(entry.boundingClientRect) + "\n" +
- "intersectionRect=" + rectToString(entry.intersectionRect) + "\n" +
- "visibleRatio=" + ratio + "\n" +
- "rootBounds=" + rectToString(entry.rootBounds) + "\n" +
- "target=" + entry.target + "\n" +
- "time=" + entry.time);
-}
-
-function rectArea(rect) {
- return (rect.left - rect.right) * (rect.bottom - rect.top);
-}
-
-function intersectionRatio(entry) {
- var targetArea = rectArea(entry.boundingClientRect);
- if (!targetArea)
- return 0;
- return rectArea(entry.intersectionRect) / targetArea;
-}
-
-function clientRectToJson(rect) {
- if (!rect)
- return null;
- return {
- top: rect.top,
- right: rect.right,
- bottom: rect.bottom,
- left: rect.left,
- width: rect.width,
- height: rect.height
- };
-}
-
-function coordinatesToClientRectJson(top, right, bottom, left) {
- return {
- top: top,
- right: right,
- bottom: bottom,
- left: left,
- width: right - left,
- height: bottom - top
- };
-}
-
-function entryToJson(entry) {
- return {
- boundingClientRect: clientRectToJson(entry.boundingClientRect),
- intersectionRect: clientRectToJson(entry.intersectionRect),
- rootBounds: clientRectToJson(entry.rootBounds),
- time: entry.time,
- target: entry.target.id
- };
-}

Powered by Google App Engine
This is Rietveld 408576698