diff options
Diffstat (limited to 'testing/web-platform/tests/intersection-observer/svg-stroke-change.html')
-rw-r--r-- | testing/web-platform/tests/intersection-observer/svg-stroke-change.html | 51 |
1 files changed, 51 insertions, 0 deletions
diff --git a/testing/web-platform/tests/intersection-observer/svg-stroke-change.html b/testing/web-platform/tests/intersection-observer/svg-stroke-change.html new file mode 100644 index 0000000000..3f01a2a23d --- /dev/null +++ b/testing/web-platform/tests/intersection-observer/svg-stroke-change.html @@ -0,0 +1,51 @@ +<!DOCTYPE html> +<title>IntersectionObserver observing an SVG element while its stroke is changed</title> +<meta name="viewport" content="width=device-width,initial-scale=1"> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<script src="resources/intersection-observer-test-utils.js"></script> +<svg width="400" height="10000"> + <!-- Ensure the svg bounds are unchanged with a white fill --> + <rect x="-5000" y="-5000" width="10000" height="10000" fill="white"/> + <rect id="target" x="0" y="100vh" width="100px" height="100px" stroke="green" stroke-width="0"/> +</svg> +<script> +const viewportWidth = document.documentElement.clientWidth; +const viewportHeight = document.documentElement.clientHeight; +setup(() => { + window.entries = []; + window.target = document.getElementById("target"); + window.targetRect = target.getBoundingClientRect(); +}); +runTestCycle(function() { + assert_true(!!target, "target exists"); + const observer = new IntersectionObserver(function(changes) { + entries = entries.concat(changes); + }); + observer.observe(target); + entries = entries.concat(observer.takeRecords()); + assert_equals(entries.length, 0, "No initial notifications"); + runTestCycle(step0, "First rAF."); +}); +function step0() { + target.setAttribute('stroke-width', '30'); + runTestCycle(step1, "change stroke"); + // The numbers in brackets are target client rect; intersection rect; + // and root bounds. + checkLastEntry(entries, 0, [ + 8, 8 + targetRect.width, viewportHeight+8, viewportHeight+8 + targetRect.height, + 0, 0, 0, 0, + 0, viewportWidth, 0, viewportHeight, + false, + ]); +} +function step1() { + checkLastEntry(entries, 1, [ + // The stroke width is divided by 2, as half of the stroke is inside the shape + 8-30/2, 8 + targetRect.width + 30/2, viewportHeight+8 -30/2, viewportHeight+8 + targetRect.height + 30/2, + 8, 8 + targetRect.width + 30/2, viewportHeight-7, viewportHeight, + 0, viewportWidth, 0, viewportHeight, + true, + ]); +} +</script> |