summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/resize-observer/svg-with-css-box-001.html
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 09:22:09 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 09:22:09 +0000
commit43a97878ce14b72f0981164f87f2e35e14151312 (patch)
tree620249daf56c0258faa40cbdcf9cfba06de2a846 /testing/web-platform/tests/resize-observer/svg-with-css-box-001.html
parentInitial commit. (diff)
downloadfirefox-upstream.tar.xz
firefox-upstream.zip
Adding upstream version 110.0.1.upstream/110.0.1upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'testing/web-platform/tests/resize-observer/svg-with-css-box-001.html')
-rw-r--r--testing/web-platform/tests/resize-observer/svg-with-css-box-001.html91
1 files changed, 91 insertions, 0 deletions
diff --git a/testing/web-platform/tests/resize-observer/svg-with-css-box-001.html b/testing/web-platform/tests/resize-observer/svg-with-css-box-001.html
new file mode 100644
index 0000000000..4ec0a7de72
--- /dev/null
+++ b/testing/web-platform/tests/resize-observer/svg-with-css-box-001.html
@@ -0,0 +1,91 @@
+<!doctype html>
+<title>ResizeObserver for SVG elements with CSS box.</title>
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<script src="./resources/resizeTestHelper.js"></script>
+<div id="container" style="width: 500px; height: 500px;">
+<svg id="svg" width="100%" viewBox="0 0 100 100">
+ <circle cx="50" cy="50" r="45" style="fill:orange;stroke:black;stroke-width:1" />
+ <foreignObject id="foreign" x="0" y="0" width="100" height="100">
+ <svg xmlns="http://www.w3.org/2000/svg"
+ width="100%" height="100%"
+ viewBox="0 0 100 100"
+ id="foreign-svg">
+ <circle cx="50" cy="50" r="45" style="fill:orange;stroke:black;stroke-width:1" />
+ </svg>
+ </foreignObject>
+</svg>
+<script>
+'use strict';
+
+function test0() {
+ let targetWidth = 150;
+ let target = document.getElementById('foreign-svg');
+ let container = document.getElementById('foreign');
+ let helper = new ResizeTestHelper(
+ "test0: observe `foreignObject` SVG in HTML document",
+ [
+ {
+ setup: observer => {
+ observer.observe(target);
+ },
+ notify: (entries, observer) => {
+ return true; // Delay next step
+ }
+ },
+ {
+ setup: observer => {
+ target.setAttribute('width', targetWidth);
+ },
+ notify: entries => {
+ assert_equals(entries.length, 1);
+ const entry = entries[0];
+ assert_equals(entry.target, target);
+ assert_equals(entry.contentBoxSize[0].inlineSize, targetWidth);
+ },
+ }
+ ]);
+ return helper.start();
+}
+
+function test1() {
+ let targetWidth = 400;
+ let target = document.getElementById('svg');
+ let container = document.getElementById('container');
+ let helper = new ResizeTestHelper(
+ "test1: observe inline SVG in HTML",
+ [
+ {
+ setup: observer => {
+ observer.observe(target);
+ },
+ notify: (entries, observer) => {
+ return true; // Delay next step
+ }
+ },
+ {
+ setup: observer => {
+ target.style.width = targetWidth + 'px';
+ },
+ notify: (entries, observer) => {
+ assert_equals(entries.length, 1);
+ const entry = entries[0];
+ assert_equals(entry.target, target);
+ assert_equals(entry.contentBoxSize[0].inlineSize, targetWidth);
+ }
+ }
+ ]);
+ return helper.start();
+}
+
+let guard;
+test(_ => {
+ assert_implements(window.ResizeObserver);
+ guard = async_test('guard');
+}, "ResizeObserver implemented")
+
+test0()
+ .then(() => { test1(); })
+ .then(() => { guard.done(); });
+
+</script>