Commit 6580c61f authored by Chris Harrelson's avatar Chris Harrelson Committed by Commit Bot

[IOv2] Add an occlusion test for foreignObject.

Bug: 823796

Change-Id: Id2f733f1823c03300c343386ad01573ff0b6d69f
Reviewed-on: https://chromium-review.googlesource.com/1252326Reviewed-by: default avatarStefan Zager <szager@chromium.org>
Commit-Queue: Chris Harrelson <chrishtr@chromium.org>
Cr-Commit-Position: refs/heads/master@{#595894}
parent bd2bd105
<!DOCTYPE html>
<script src="../../resources/testharness.js"></script>
<script src="../../resources/testharnessreport.js"></script>
<script src="../resources/intersection-observer-test-utils.js"></script>
<style>
body, html {
margin: 0;
}
pre, #log {
position: absolute;
top: 0;
left: 200px;
}
#target {
width: 100px;
height: 100px;
background-color: green;
}
#occluder {
width: 100px;
height: 100px;
background-color: blue;
}
</style>
<div id="target"></div>
<svg id="svg" style="display: block">
<foreignObject>
<div id="occluder"></div>
</foreignObject>
</svg>
<script>
var entries = [];
var target;
var occluder;
if (window.internals) {
internals.DisableIntersectionObserverThrottleDelay();
}
runTestCycle(function() {
target = document.getElementById("target");
occluder = document.getElementById("occluder");
assert_true(!!target, "target exists");
assert_true(!!occluder, "occluder exists");
var observer = new IntersectionObserver(function(changes) {
entries = entries.concat(changes)
}, {trackVisibility: true, delay: 100});
observer.observe(target);
entries = entries.concat(observer.takeRecords());
assert_equals(entries.length, 0, "No initial notifications.");
runTestCycle(step0, "First rAF.");
}, "IntersectionObserverV2 in a single document using the implicit root, with an occluding element.");
function step0() {
svg.style.marginTop = "-10px";
runTestCycle(step1, "svg.style.marginTop = '-10px'");
checkLastEntry(entries, 0, [0, 100, 0, 100, 0, 100, 0, 100, 0, 800, 0, 600, true, true]);
}
function step1() {
// Occluding elements with opacity=0 should not affect target visibility.
svg.style.opacity = "0";
runTestCycle(step2, "occluder.style.opacity = 0");
checkLastEntry(entries, 1, [0, 100, 0, 100, 0, 100, 0, 100, 0, 800, 0, 600, true, false]);
}
function step2() {
checkLastEntry(entries, 2, [0, 100, 0, 100, 0, 100, 0, 100, 0, 800, 0, 600, true, true]);
}
</script>
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment