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

Unified Diff: third_party/WebKit/LayoutTests/intersection-observer/same-document-no-root.html

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/intersection-observer/same-document-no-root.html
diff --git a/third_party/WebKit/LayoutTests/intersection-observer/same-document-no-root.html b/third_party/WebKit/LayoutTests/intersection-observer/same-document-no-root.html
index 607d70c0d167e2165a6cf5ad6abe3e5c2a4b97f1..27464d8f04d3aefe50b53eeedbfb3161f9122cb9 100644
--- a/third_party/WebKit/LayoutTests/intersection-observer/same-document-no-root.html
+++ b/third_party/WebKit/LayoutTests/intersection-observer/same-document-no-root.html
@@ -1,69 +1,61 @@
<!DOCTYPE html>
-<script src="../resources/js-test.js"></script>
-<script src="../resources/intersection-observer-helper-functions.js"></script>
-<div style="width:100%; height:700px;"></div>
-<div id="target" style="background-color: green; width:100px; height:100px"></div>
-<div style="width:100%; height:700px;"></div>
+<script src="../resources/testharness.js"></script>
+<script src="../resources/testharnessreport.js"></script>
+<script src="./resources/intersection-observer-test-utils.js"></script>
+
+<style>
+pre, #log {
+ position: absolute;
+ top: 0;
+ left: 200px;
+}
+.spacer {
+ height: 700px;
+}
+#target {
+ width: 100px;
+ height: 100px;
+ background-color: green;
+}
+</style>
+
+<div class="spacer"></div>
+<div id="target"></div>
+<div class="spacer"></div>
<script>
-description("Simple intersection observer test with no explicit root and one document.");
-var target = document.getElementById("target");
var entries = [];
-var observer = new IntersectionObserver(changes => { entries = entries.concat(changes) });
+var target;
-onload = function() {
+runTestCycle(function() {
+ assert_equals(window.innerWidth, 800, "Window must be 800 pixels wide.");
+ assert_equals(window.innerHeight, 600, "Window must be 600 pixels high.");
+
+ target = document.getElementById("target");
+ assert_true(!!target, "target exists");
+ var observer = new IntersectionObserver(function(changes) {
+ entries = entries.concat(changes)
+ });
observer.observe(target);
entries = entries.concat(observer.takeRecords());
- shouldBeEqualToNumber("entries.length", 0);
+ assert_equals(entries.length, 0, "No initial notifications.");
+ runTestCycle(step0, "First rAF.");
+}, "IntersectionObserver in a single document using the implicit root.");
+
+function step0() {
document.scrollingElement.scrollTop = 300;
- waitForNotification(step1);
-};
+ runTestCycle(step1, "document.scrollingElement.scrollTop = 300");
+ assert_equals(entries.length, 0, "No notifications after first rAF.");
+}
function step1() {
- shouldBeEqualToNumber("entries.length", 1);
- if (entries.length > 0) {
- shouldBeEqualToNumber("entries[0].boundingClientRect.left", 8);
- shouldBeEqualToNumber("entries[0].boundingClientRect.right", 108);
- shouldBeEqualToNumber("entries[0].boundingClientRect.top", 408);
- shouldBeEqualToNumber("entries[0].boundingClientRect.bottom", 508);
- shouldBeEqualToNumber("entries[0].intersectionRect.left", 8);
- shouldBeEqualToNumber("entries[0].intersectionRect.right", 108);
- shouldBeEqualToNumber("entries[0].intersectionRect.top", 408);
- shouldBeEqualToNumber("entries[0].intersectionRect.bottom", 508);
- shouldBeEqualToNumber("entries[0].rootBounds.left", 0);
- shouldBeEqualToNumber("entries[0].rootBounds.right", 785);
- shouldBeEqualToNumber("entries[0].rootBounds.top", 0);
- shouldBeEqualToNumber("entries[0].rootBounds.bottom", 600);
- shouldEvaluateToSameObject("entries[0].target", target);
-
- // ClientRect members of IntersectionObserverEntry should be stable.
- shouldEvaluateToSameObject("entries[0].boundingClientRect", entries[0].boundingClientRect);
- shouldEvaluateToSameObject("entries[0].intersectionRect", entries[0].intersectionRect);
- shouldEvaluateToSameObject("entries[0].rootBounds", entries[0].rootBounds);
- }
document.scrollingElement.scrollTop = 100;
- waitForNotification(step2);
+ runTestCycle(step2, "document.scrollingElement.scrollTop = 100");
+ checkLastEntry(entries, 0, [8, 108, 408, 508, 8, 108, 408, 508, 0, 785, 0, 600, target]);
}
function step2() {
- shouldBeEqualToNumber("entries.length", 2);
- if (entries.length > 1) {
- shouldBeEqualToNumber("entries[1].boundingClientRect.left", 8);
- shouldBeEqualToNumber("entries[1].boundingClientRect.right", 108);
- shouldBeEqualToNumber("entries[1].boundingClientRect.top", 608);
- shouldBeEqualToNumber("entries[1].boundingClientRect.bottom", 708);
- shouldBeEqualToNumber("entries[1].intersectionRect.left", 0);
- shouldBeEqualToNumber("entries[1].intersectionRect.right", 0);
- shouldBeEqualToNumber("entries[1].intersectionRect.top", 0);
- shouldBeEqualToNumber("entries[1].intersectionRect.bottom", 0);
- shouldBeEqualToNumber("entries[1].rootBounds.left", 0);
- shouldBeEqualToNumber("entries[1].rootBounds.right", 785);
- shouldBeEqualToNumber("entries[1].rootBounds.top", 0);
- shouldBeEqualToNumber("entries[1].rootBounds.bottom", 600);
- shouldEvaluateToSameObject("entries[1].target", target);
- }
- finishJSTest();
document.scrollingElement.scrollTop = 0;
+ checkLastEntry(entries, 1, [8, 108, 608, 708, 0, 0, 0, 0, 0, 785, 0, 600, target]);
}
-
</script>

Powered by Google App Engine
This is Rietveld 408576698