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

Unified Diff: third_party/WebKit/LayoutTests/intersection-observer/zero-area-element-visible.html

Issue 2560253004: IntersectionObserver: convert tests to testharness.js (Closed)
Patch Set: rebase Created 4 years 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/intersection-observer/zero-area-element-visible.html
diff --git a/third_party/WebKit/LayoutTests/intersection-observer/zero-area-element-visible.html b/third_party/WebKit/LayoutTests/intersection-observer/zero-area-element-visible.html
index 1bc785f2ab7a99b2ea69ffbb0a1b04b127aa4f0b..679fe113ecc7bbd08a91b3547a6d5233b56c9a28 100644
--- a/third_party/WebKit/LayoutTests/intersection-observer/zero-area-element-visible.html
+++ b/third_party/WebKit/LayoutTests/intersection-observer/zero-area-element-visible.html
@@ -1,24 +1,39 @@
<!DOCTYPE html>
-<script src="../resources/intersection-observer-helper-functions.js"></script>
<script src="../resources/testharness.js"></script>
<script src="../resources/testharnessreport.js"></script>
-<title>Ensure that a visible zero-area element is given the correct intersection ratio</title>
-
-<div id='target' style='width: 0px; height: 0px'</div>"
+<div id='target' style='width: 0px; height: 0px'</div>
<script>
-'use strict';
+function waitForNotification(f) {
+ requestAnimationFrame(() => {
+ setTimeout(() => {
+ setTimeout(f);
+ });
+ });
+}
+
+onload = function() {
+ var t = async_test("Ensure that a visible zero-area element is given the correct intersection ratio.");
+
+ test(function() { assert_equals(window.innerWidth, 800) }, "Window must be 800 pixels wide.");
+ test(function() { assert_equals(window.innerHeight, 600) }, "Window must be 600 pixels high.");
+
+ var target = document.getElementById('target');
+ var entries = [];
+ var observer = new IntersectionObserver(changes => {
+ entries = entries.concat(changes)
+ });
+ observer.observe(target);
+ entries = entries.concat(observer.takeRecords());
+ test(function() { assert_equals(entries.length, 0) }, "No initial notifications.");
+ waitForNotification(step0);
-async_test(t => {
- let target = document.getElementById('target');
- let entries = [];
- new IntersectionObserver(changes => {
- entries.push(...changes);
- }).observe(target);
- waitForNotification(t.step_func_done(() => {
- assert_equals(entries.length, 1);
- assert_equals(entries[0].intersectionRatio, 1);
- }));
-});
+ function step0() {
+ test(function() { assert_equals(entries.length, 1) }, "One notification.");
+ if (entries.length)
+ test(function() { assert_equals(entries[0].intersectionRatio, 1) }, "intersectionRatio == 1");
+ t.done();
+ }
+};
</script>

Powered by Google App Engine
This is Rietveld 408576698