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

Side by Side Diff: third_party/WebKit/LayoutTests/intersection-observer/observer-without-js-reference.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/js-test.js"></script> 2 <script src="../resources/testharness.js"></script>
3 <script src="../resources/gc.js"></script> 3 <script src="../resources/testharnessreport.js"></script>
4 <script src="../resources/intersection-observer-helper-functions.js"></script> 4 <div id="leading-space" style="width:100%; height:700px;"></div>
5 <div style="width:100%; height:700px;"></div>
6 <div id="target" style="background-color: green; width:100px; height:100px"></di v> 5 <div id="target" style="background-color: green; width:100px; height:100px"></di v>
7 <div style="width:100%; height:700px;"></div> 6 <div id="trailing-space" style="width:100%; height:700px;"></div>
8 7
9 <script> 8 <script>
10 description("IntersectionObserver continues to produce notifications when it has no javascript references."); 9 function waitForNotification(f) {
11 var target = document.getElementById("target"); 10 requestAnimationFrame(() => {
12 var entries = []; 11 setTimeout(() => {
13 new IntersectionObserver(function(changes) { 12 setTimeout(f);
14 entries.push(...changes); 13 });
15 }).observe(target); 14 });
16 gc(); 15 }
17 document.scrollingElement.scrollTop = 300; 16
18 waitForNotification(() => { 17 onload = function() {
19 shouldBeEqualToNumber("entries.length", 1); 18 var t = async_test("IntersectionObserver continues to produce notifications wh en it has no javascript references.");
20 finishJSTest(); 19
21 }); 20 test(function() { assert_equals(window.innerWidth, 800) }, "Window must be 800 pixels wide.");
21 test(function() { assert_equals(window.innerHeight, 600) }, "Window must be 60 0 pixels high.");
22
23 var target = document.getElementById("target");
24 var entries = [];
25 function createObserver() {
26 new IntersectionObserver(function(changes) {
27 entries = entries.concat(changes)
28 }).observe(target);
29 }
30
31 createObserver();
32 waitForNotification(step0);
33
34 function step0() {
35 test(function() { assert_equals(entries.length, 0) }, "No notifications.");
36 document.scrollingElement.scrollTop = 300;
37 waitForNotification(step1);
38 }
39
40 function step1() {
41 test(function() { assert_equals(entries.length, 1) }, "One notification.");
42 document.getElementById("leading-space").style.height = "";
43 document.getElementById("trailing-space").style.height = "";
44 t.done();
45 }
46 };
22 </script> 47 </script>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698