Skip to content

Commit

Permalink
Fix more IntersectionObserver issues.
Browse files Browse the repository at this point in the history
Two spec issues here.

w3c/IntersectionObserver#457: I think this is
just a spec bug and I've made us match other browsers, but since the
tests don't match the spec for now I've added them as .tentative.html

w3c/IntersectionObserver#456: I've aligned
with WebKit here. There was a (disabled) test for this which tests
chrome behavior and which after this patch shouldn't be flaky. This is
what was causing the assertion.

Differential Revision: https://phabricator.services.mozilla.com/D93166

bugzilla-url: https://bugzilla.mozilla.org/show_bug.cgi?id=1670327
gecko-commit: 2906a77771b3abcc15c2859052c0d170b263133d
gecko-reviewers: hiro
  • Loading branch information
emilio authored and moz-wptsync-bot committed Oct 22, 2020
1 parent 3dbd045 commit 6860d7a
Show file tree
Hide file tree
Showing 3 changed files with 56 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<!doctype html>
<meta name="viewport" content="width=device-width,initial-scale=1">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<link rel="help" href="https://github.com/w3c/IntersectionObserver/issues/457">
<style>
div {
width: 100px;
height: 100px;
background: blue;
margin: 10px
}
</style>
<div id="root"></div>
<script>
let t = async_test("IntersectionObserver reports a (non-intersecting) entry if different-document from the doc");
let doc = document.implementation.createHTMLDocument("");
let target = doc.createElement("div");
doc.body.appendChild(target);
new IntersectionObserver(
t.step_func_done(function(records) {
assert_equals(records.length, 1);
assert_false(records[0].isIntersecting);
}),
{ root: document.querySelector("#root") }
).observe(target);
</script>
25 changes: 25 additions & 0 deletions intersection-observer/not-in-containing-block-chain.tentative.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<!doctype html>
<meta name="viewport" content="width=device-width,initial-scale=1">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<link rel="help" href="https://github.com/w3c/IntersectionObserver/issues/457">
<style>
div {
width: 100px;
height: 100px;
background: blue;
margin: 10px
}
</style>
<div id="target"></div>
<div id="root"></div>
<script>
let t = async_test("IntersectionObserver reports a (non-intersecting) entry even if not in the containing block chain");
new IntersectionObserver(
t.step_func_done(function(records) {
assert_equals(records.length, 1);
assert_false(records[0].isIntersecting);
}),
{ root: document.querySelector("#root") }
).observe(document.querySelector("#target"));
</script>
4 changes: 4 additions & 0 deletions intersection-observer/target-in-different-window.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
<!DOCTYPE html>
<meta name="viewport" content="width=device-width,initial-scale=1">
<!--
NOTE(emilio): This tests Chrome's behavior but it's not clear that's what the
spec asks for, see https://github.com/w3c/IntersectionObserver/issues/456
-->
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="./resources/intersection-observer-test-utils.js"></script>
Expand Down

0 comments on commit 6860d7a

Please sign in to comment.