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

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: 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 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>
5 4
6 <title>Ensure that a hidden zero-area element is treated correctly</title> 5 <div id='target' style='width: 0px; height: 0px; position: fixed; top: -1000px'< /div>
7
8 <div id='target' style='width: 0px; height: 0px; position: fixed; top: -1000px'< /div>"
9 6
10 <script> 7 <script>
11 'use strict'; 8 function waitForNotification(f) {
9 requestAnimationFrame(() => {
10 setTimeout(() => {
11 setTimeout(f);
12 });
13 });
14 }
12 15
13 async_test(t => { 16 onload = function() {
14 let target = document.getElementById('target'); 17 var t = async_test("Ensure that a hidden zero-area element is treated correctl y.");
15 let entries = []; 18
16 new IntersectionObserver(changes => { 19 test(function() { assert_equals(window.innerWidth, 800) }, "Window must be 800 pixels wide.");
17 entries.push(...changes); 20 test(function() { assert_equals(window.innerHeight, 600) }, "Window must be 60 0 pixels high.");
18 }).observe(target); 21
19 waitForNotification(t.step_func_done(() => { 22 var target = document.getElementById('target');
20 // Since the element is initially assumed to be hidden, there are no entries . 23 var entries = [];
21 assert_equals(entries.length, 0); 24 var observer = new IntersectionObserver(changes => {
22 })); 25 entries = entries.concat(changes)
23 }); 26 });
27 observer.observe(target);
28 entries = entries.concat(observer.takeRecords());
29 test(function() { assert_equals(entries.length, 0) }, "No initial notification s.");
30 waitForNotification(step0);
31
32 function step0() {
33 test(function() { assert_equals(entries.length, 0) }, "No notifications afte r first rAF.");
34 t.done();
35 }
36 };
24 </script> 37 </script>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698