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

Side by Side Diff: third_party/WebKit/LayoutTests/intersection-observer/zero-area-element-hidden.html

Issue 2560253004: IntersectionObserver: convert tests to testharness.js (Closed)
Patch Set: Address comments Created 3 years, 10 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 hidden zero-area element is treated correctly</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 position: fixed;
16 top: -1000px;
17 }
18 </style>
7 19
8 <div id='target' style='width: 0px; height: 0px; position: fixed; top: -1000px'< /div>" 20 <div id='target'></div>
9 21
10 <script> 22 <script>
11 'use strict'; 23 var entries = [];
12 24
13 async_test(t => { 25 runTestCycle(function() {
14 let target = document.getElementById('target'); 26 assert_equals(window.innerWidth, 800, "Window must be 800 pixels wide.");
15 let entries = []; 27 assert_equals(window.innerHeight, 600, "Window must be 600 pixels high.");
16 new IntersectionObserver(changes => { 28
17 entries.push(...changes); 29 var target = document.getElementById('target');
18 }).observe(target); 30 assert_true(!!target, "target exists");
19 waitForNotification(t.step_func_done(() => { 31 var observer = new IntersectionObserver(function(changes) {
20 // Since the element is initially assumed to be hidden, there are no entries . 32 entries = entries.concat(changes)
21 assert_equals(entries.length, 0); 33 });
22 })); 34 observer.observe(target);
23 }); 35 entries = entries.concat(observer.takeRecords());
36 assert_equals(entries.length, 0, "No initial notifications.");
37 runTestCycle(step0, "First rAF should not generate a notification.");
38 }, "No intersecting observations should be sent for a zero-area hidden target.") ;
39
40 function step0() {
41 assert_equals(entries.length, 0, "No notifications after first rAF.");
42 }
24 </script> 43 </script>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698