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

Side by Side Diff: third_party/WebKit/LayoutTests/intersection-observer/zero-area-element-visible.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 unified diff | Download patch
OLDNEW
1 <!DOCTYPE html> 1 <!DOCTYPE html>
2 <script src="../resources/intersection-observer-helper-functions.js"></script>
3 <script src="../resources/testharness.js"></script> 2 <script src="../resources/testharness.js"></script>
4 <script src="../resources/testharnessreport.js"></script> 3 <script src="../resources/testharnessreport.js"></script>
4 <script src="./resources/intersection-observer-test-utils.js"></script>
5 5
6 <title>Ensure that a visible zero-area element is given the correct intersection ratio</title> 6 <style>
7 pre, #log {
8 position: absolute;
9 top: 0;
10 left: 200px;
11 }
12 #target {
13 width: 0px;
14 height: 0px;
15 }
16 </style>
7 17
8 <div id='target' style='width: 0px; height: 0px'</div>" 18 <div id='target'></div>
9 19
10 <script> 20 <script>
11 'use strict'; 21 var entries = [];
12 22
13 async_test(t => { 23 runTestCycle(function() {
14 let target = document.getElementById('target'); 24 assert_equals(window.innerWidth, 800, "Window must be 800 pixels wide.");
15 let entries = []; 25 assert_equals(window.innerHeight, 600, "Window must be 600 pixels high.");
16 new IntersectionObserver(changes => { 26
17 entries.push(...changes); 27 var target = document.getElementById('target');
18 }).observe(target); 28 assert_true(!!target, "target exists");
19 waitForNotification(t.step_func_done(() => { 29 var observer = new IntersectionObserver(function(changes) {
20 assert_equals(entries.length, 1); 30 entries = entries.concat(changes)
21 assert_equals(entries[0].intersectionRatio, 1); 31 });
22 })); 32 observer.observe(target);
23 }); 33 entries = entries.concat(observer.takeRecords());
34 assert_equals(entries.length, 0, "No initial notifications.");
35 runTestCycle(step0, "First rAF should generate a notification.");
36 }, "Ensure that a zero-area target intersecting root generates a notification wi th intersectionRatio == 1");
37
38 function step0() {
39 assert_equals(entries.length, 1, "One notification.");
40 assert_equals(entries[0].intersectionRatio, 1, "intersectionRatio == 1");
41 }
24 </script> 42 </script>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698