| <script src="../resources/js-test.js"></script> |
| <div id="testDiv">test</div> |
| description("Tests that an observation is received after disconnecting a visible target"); |
| let receivedInitialObservation = false; |
| let intersectionObserver = new IntersectionObserver((_observations) => { |
| observations = _observations; |
| shouldBe("observations.length", "1"); |
| shouldBeEqualToString("observations[0].target.tagName", "DIV"); |
| shouldBe("observations[0].target.foo", "1"); |
| if (!receivedInitialObservation) { |
| receivedInitialObservation = true; |
| shouldBeTrue("observations[0].isIntersecting"); |
| debug("* Removing target from document"); |
| document.getElementById("testDiv").remove(); |
| shouldBeFalse("observations[0].isIntersecting"); |
| setTimeout(finishJSTest, 100); |
| let div = document.getElementById("testDiv"); |
| intersectionObserver.observe(div); |