Import Cobalt 21.master.0.276581
diff --git a/src/third_party/web_platform_tests/intersection-observer/isIntersecting-change-events.html b/src/third_party/web_platform_tests/intersection-observer/isIntersecting-change-events.html
index 99bc65b..2021f06 100644
--- a/src/third_party/web_platform_tests/intersection-observer/isIntersecting-change-events.html
+++ b/src/third_party/web_platform_tests/intersection-observer/isIntersecting-change-events.html
@@ -16,7 +16,7 @@
left: 0;
width: 150px;
height: 200px;
- overflow-y: scroll;
+ overflow: scroll;
}
#target1, #target2, #target3, #target4 {
width: 100px;
@@ -45,18 +45,21 @@
<script>
var entries = [];
var observer;
+var target1, target2, target3, target4;
+var root;
runTestCycle(function() {
- var root = document.getElementById('root');
- var target1 = document.getElementById('target1');
- var target2 = document.getElementById('target2');
- var target3 = document.getElementById('target3');
+ root = document.getElementById('root');
+ target1 = document.getElementById('target1');
+ target2 = document.getElementById('target2');
+ target3 = document.getElementById('target3');
assert_true(!!root, "root element exists.");
assert_true(!!target1, "target1 element exists.");
assert_true(!!target2, "target2 element exists.");
assert_true(!!target3, "target3 element exists.");
observer = new IntersectionObserver(function(changes) {
entries = entries.concat(changes);
+ window.testRunner.DoNonMeasuredLayout();
}, { root: root });
observer.observe(target1);
observer.observe(target2);
@@ -65,6 +68,8 @@
assert_equals(entries.length, 0, "No initial notifications.");
runTestCycle(step0, "Rects in initial notifications should report initial positions.");
}, "isIntersecting changes should trigger notifications.");
+window.testRunner.DoNonMeasuredLayout();
+window.testRunner.DoNonMeasuredLayout();
function step0() {
assert_equals(entries.length, 3, "Has 3 initial notifications.");
@@ -78,14 +83,21 @@
assert_equals(entries[2].target.id, 'target3', "Check 3rd entry target id.");
checkIsIntersecting(entries, 2, true);
runTestCycle(step1, "Set scrollTop=100 and check for no new notifications.");
- root.scrollTop = 100;
+ target1.style.marginTop = "-100px";
+ target2.style.marginTop = "-100px";
+ target3.style.marginTop = "-100px";
+ //root.scrollTop = 100;
+ window.testRunner.DoNonMeasuredLayout();
}
function step1() {
assert_equals(entries.length, 3, "Has 3 total notifications because isIntersecting did not change.");
runTestCycle(step2, "Add 4th target.");
- root.scrollTop = 0;
- var target4 = document.createElement('div');
+ target1.style.marginTop = "0px";
+ target2.style.marginTop = "0px";
+ target3.style.marginTop = "0px";
+ //root.scrollTop = 0;
+ target4 = document.createElement('div');
target4.setAttribute('id', 'target4');
root.appendChild(target4);
observer.observe(target4);
@@ -98,12 +110,16 @@
checkIsIntersecting(entries, 3, false);
assert_equals(entries[3].intersectionRatio, 0, 'target4 initially has intersectionRatio of 0.');
runTestCycle(step3, "Set scrollTop=100 and check for one new notification.");
- root.scrollTop = 100;
+ target1.style.marginTop = "-100px";
+ target2.style.marginTop = "-100px";
+ target3.style.marginTop = "-100px";
+ target4.style.marginTop = "-100px";
+ //root.scrollTop = 100;
}
function step3() {
assert_equals(entries.length, 5, "Has 5 total notifications.");
- checkRect(entries[4].boundingClientRect, [0, 100, 200, 300], "Check 5th entry rect");
+ checkRect(entries[4].boundingClientRect, [0, 100, -100, 000], "Check 5th entry rect");
assert_equals(entries[4].target.id, 'target4', "Check 5th entry target id.");
checkIsIntersecting(entries, 4, true);
assert_equals(entries[4].intersectionRatio, 0, 'target4 still has intersectionRatio of 0.');