summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/svg/scripted
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/svg/scripted
parentInitial commit. (diff)
downloadfirefox-43a97878ce14b72f0981164f87f2e35e14151312.tar.xz
firefox-43a97878ce14b72f0981164f87f2e35e14151312.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/svg/scripted')
-rw-r--r--testing/web-platform/tests/svg/scripted/script-runs-in-shadow-tree.html15
-rw-r--r--testing/web-platform/tests/svg/scripted/script-style-attribute-csp-ref.html3
-rw-r--r--testing/web-platform/tests/svg/scripted/script-style-attribute-csp.html22
-rw-r--r--testing/web-platform/tests/svg/scripted/text-attrs-dxdy-have-length.svg23
-rw-r--r--testing/web-platform/tests/svg/scripted/text-attrs-xyrotate-have-length.svg24
-rw-r--r--testing/web-platform/tests/svg/scripted/text-tspan-attrs-have-length.svg44
-rw-r--r--testing/web-platform/tests/svg/scripted/text-tspan-attrs-indexed-access.svg33
-rw-r--r--testing/web-platform/tests/svg/scripted/tspan-attrs-dxdy-have-length.svg24
-rw-r--r--testing/web-platform/tests/svg/scripted/tspan-attrs-xyrotate-have-length.svg24
9 files changed, 212 insertions, 0 deletions
diff --git a/testing/web-platform/tests/svg/scripted/script-runs-in-shadow-tree.html b/testing/web-platform/tests/svg/scripted/script-runs-in-shadow-tree.html
new file mode 100644
index 0000000000..9693db333f
--- /dev/null
+++ b/testing/web-platform/tests/svg/scripted/script-runs-in-shadow-tree.html
@@ -0,0 +1,15 @@
+<!doctype html>
+<link rel="author" href="mailto:emilio@crisal.io" title="Emilio Cobos Álvarez">
+<link rel="author" href="https://mozilla.org" title="Mozilla">
+<link rel="help" href="https://bugzilla.mozilla.org/show_bug.cgi?id=1555949">
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<div id="host"></div>
+<script>
+ let svgScript = document.createElementNS("http://www.w3.org/2000/svg", "script");
+ svgScript.innerHTML = "window.scriptRan = true";
+ document.getElementById("host").attachShadow({ mode: "open" }).appendChild(svgScript);
+ test(function() {
+ assert_true(window.scriptRan);
+ }, "svg:script runs correctly in a shadow tree");
+</script>
diff --git a/testing/web-platform/tests/svg/scripted/script-style-attribute-csp-ref.html b/testing/web-platform/tests/svg/scripted/script-style-attribute-csp-ref.html
new file mode 100644
index 0000000000..a7316213f1
--- /dev/null
+++ b/testing/web-platform/tests/svg/scripted/script-style-attribute-csp-ref.html
@@ -0,0 +1,3 @@
+<!doctype html>
+<meta charset="UTF-8">
+<svg style="width: 100px; height: 100px; background-color: green"></svg>
diff --git a/testing/web-platform/tests/svg/scripted/script-style-attribute-csp.html b/testing/web-platform/tests/svg/scripted/script-style-attribute-csp.html
new file mode 100644
index 0000000000..a70138d98a
--- /dev/null
+++ b/testing/web-platform/tests/svg/scripted/script-style-attribute-csp.html
@@ -0,0 +1,22 @@
+<!doctype html>
+<meta charset="UTF-8">
+<!--
+ Allow scripts, but don't allow inline styles.
+ This does allow scripts to *set* inline styles via the .style attribute.
+-->
+<title>Setting style setters via script for an SVG element outside of the document should work</title>
+<meta http-equiv="Content-Security-Policy" content="
+ script-src 'unsafe-inline';
+ style-src 'none';
+">
+<link rel="match" href="script-style-attribute-csp-ref.html">
+<link rel="author" title="Emilio Cobos Álvarez" href="mailto:emilio@crisal.io">
+<link rel="help" href="https://bugzilla.mozilla.org/show_bug.cgi?id=1494356">
+<body>
+<script>
+ const element = document.createElementNS('http://www.w3.org/2000/svg', 'svg');
+ element.style.width = '100px';
+ element.style.height = '100px';
+ element.style.backgroundColor = 'green';
+ document.body.appendChild(element);
+</script>
diff --git a/testing/web-platform/tests/svg/scripted/text-attrs-dxdy-have-length.svg b/testing/web-platform/tests/svg/scripted/text-attrs-dxdy-have-length.svg
new file mode 100644
index 0000000000..a5f07e29a1
--- /dev/null
+++ b/testing/web-platform/tests/svg/scripted/text-attrs-dxdy-have-length.svg
@@ -0,0 +1,23 @@
+<?xml version="1.0" standalone="no"?>
+<svg xmlns="http://www.w3.org/2000/svg"
+ xmlns:h="http://www.w3.org/1999/xhtml">
+ <metadata>
+ <h:link rel="help" href="https://svgwg.org/svg2-draft/single-page.html#text-TSpanNotes"/>
+ <h:meta name="assert" content="dx and dy attributes on text elements are lists that support length()"/>
+</metadata>
+ <text id="text" font-family="Verdana" font-size="55" fill="blue"
+ y="150"
+ x="120"
+ dx="60 90 -30 120 60 -257"
+ dy="0 12 24 12 0 -12 -24 -12 0"
+ >His socks are black.</text>
+ <h:script src="/resources/testharness.js"/>
+ <h:script src="/resources/testharnessreport.js"/>
+ <script><![CDATA[
+ test(function() {
+ var text = document.getElementById('text');
+ assert_equals(text.dx.baseVal.length, 6);
+ assert_equals(text.dy.baseVal.length, 9);
+ });
+ ]]></script>
+</svg>
diff --git a/testing/web-platform/tests/svg/scripted/text-attrs-xyrotate-have-length.svg b/testing/web-platform/tests/svg/scripted/text-attrs-xyrotate-have-length.svg
new file mode 100644
index 0000000000..79d365ddec
--- /dev/null
+++ b/testing/web-platform/tests/svg/scripted/text-attrs-xyrotate-have-length.svg
@@ -0,0 +1,24 @@
+<?xml version="1.0" standalone="no"?>
+<svg xmlns="http://www.w3.org/2000/svg"
+ xmlns:h="http://www.w3.org/1999/xhtml">
+ <metadata>
+ <h:link rel="help" href="https://svgwg.org/svg2-draft/single-page.html#text-TSpanNotes"/>
+ <h:meta name="assert" content="x y and rotate attributes on text elements are lists that support length()"/>
+</metadata>
+ <text id="text" font-family="Verdana" font-size="55" fill="blue"
+ y="150 130 160"
+ x="120 160 200 240"
+ rotate="0 0 10, -10, 0"
+ >My socks are blue.</text>
+ <h:script src="/resources/testharness.js"/>
+ <h:script src="/resources/testharnessreport.js"/>
+ <script><![CDATA[
+ /* The SVG spec requires (at least) readonly support for length */
+ test(function() {
+ var text = document.getElementById('text');
+ assert_equals(text.y.baseVal.length, 3);
+ assert_equals(text.x.baseVal.length, 4);
+ assert_equals(text.rotate.baseVal.length, 5);
+ });
+ ]]></script>
+</svg>
diff --git a/testing/web-platform/tests/svg/scripted/text-tspan-attrs-have-length.svg b/testing/web-platform/tests/svg/scripted/text-tspan-attrs-have-length.svg
new file mode 100644
index 0000000000..d189b531d7
--- /dev/null
+++ b/testing/web-platform/tests/svg/scripted/text-tspan-attrs-have-length.svg
@@ -0,0 +1,44 @@
+<?xml version="1.0" standalone="no"?>
+<svg xmlns="http://www.w3.org/2000/svg"
+ xmlns:h="http://www.w3.org/1999/xhtml">
+ <metadata>
+ <h:link rel="help" href="https://svgwg.org/svg2-draft/single-page.html#text-TSpanNotes"/>
+ <h:meta name="assert" content="x y dx dy and rotate attributes on text and tspan elements are lists that support length()"/>
+</metadata>
+ <text id="text" font-family="Verdana" font-size="55" fill="blue"
+ y="150 130 160" x="120 160 200 240" rotate="0 0 10, -10, 0">
+ My <tspan id="tspan" x="280 325" y="150 155 160 165 170" rotate="-30,0,30">socks</tspan>
+ are blue.
+ </text>
+ <h:script src="/resources/testharness.js"/>
+ <h:script src="/resources/testharnessreport.js"/>
+ <script><![CDATA[
+ test(function() {
+ /* Make sure that text.y is a list, (presumably
+ * SVGAnimatedLengthList) and that the list has a
+ * length() method and that it returns the right thing.
+ *
+ * This test is for a change in SVG for 2.0, since 1.x, to add
+ * a length property.
+ */
+ var text = document.getElementById('text');
+ assert_equals(text.y.baseVal.length, 3);
+ assert_equals(text.x.baseVal.length, 4);
+ assert_equals(text.rotate.baseVal.length, 5);
+
+ /* same for tspan */
+ var tspan = document.getElementById('tspan');
+ assert_equals(tspan.x.baseVal.length, 2);
+ assert_equals(tspan.y.baseVal.length, 5);
+ assert_equals(tspan.rotate.baseVal.length, 3);
+
+ /* Note, we only have to test that the length property
+ * is there (and interoperable) when there is a list given;
+ * in practice it's there with value 0 when the attributes are
+ * absent, but that's not required, the attribute could be implemented
+ * as a plain string in that case, or absent entirely, I think
+ * - Liam Quin 2018
+ */
+ });
+ ]]></script>
+</svg>
diff --git a/testing/web-platform/tests/svg/scripted/text-tspan-attrs-indexed-access.svg b/testing/web-platform/tests/svg/scripted/text-tspan-attrs-indexed-access.svg
new file mode 100644
index 0000000000..b14b6bfc28
--- /dev/null
+++ b/testing/web-platform/tests/svg/scripted/text-tspan-attrs-indexed-access.svg
@@ -0,0 +1,33 @@
+<?xml version="1.0" standalone="no"?>
+<svg xmlns="http://www.w3.org/2000/svg"
+ xmlns:h="http://www.w3.org/1999/xhtml">
+ <metadata>
+ <h:link rel="help" href="https://svgwg.org/svg2-draft/single-page.html#text-TSpanNotes"/>
+ <h:meta name="assert" content="x y dx dy and rotate attributes on text and tspan elements are lists that support length()"/>
+</metadata>
+ <text id="text" font-family="Verdana" font-size="55" fill="blue"
+ y="150 130 160" x="120 160 200 240" rotate="0 0 10, -10, 0">
+ My <tspan id="tspan" x="280 325" y="150 155 160 165 170" rotate="-30,0,30">socks</tspan>
+ are blue.
+ </text>
+ <h:script src="/resources/testharness.js"/>
+ <h:script src="/resources/testharnessreport.js"/>
+ <script><![CDATA[
+ test(function() {
+ /* Make sure that we can get at list items with indexed access.
+ */
+ var text = document.getElementById('text');
+ assert_equals(text.x.baseVal[0].value, 120);
+ assert_equals(text.y.baseVal[2].value, 160);
+ assert_equals(text.rotate.baseVal[3].value, -10);
+ assert_equals(text.rotate.baseVal[0].value, 0);
+
+ /* same for tspan */
+ var tspan = document.getElementById('tspan');
+ assert_equals(tspan.x.baseVal[1].value, 325);
+ assert_equals(tspan.y.baseVal[4].value, 170);
+ assert_equals(tspan.rotate.baseVal[0].value, -30);
+ });
+
+ ]]></script>
+</svg>
diff --git a/testing/web-platform/tests/svg/scripted/tspan-attrs-dxdy-have-length.svg b/testing/web-platform/tests/svg/scripted/tspan-attrs-dxdy-have-length.svg
new file mode 100644
index 0000000000..c8d002f1ce
--- /dev/null
+++ b/testing/web-platform/tests/svg/scripted/tspan-attrs-dxdy-have-length.svg
@@ -0,0 +1,24 @@
+<?xml version="1.0" standalone="no"?>
+<svg xmlns="http://www.w3.org/2000/svg"
+ xmlns:h="http://www.w3.org/1999/xhtml">
+ <metadata>
+ <h:link rel="help" href="https://svgwg.org/svg2-draft/single-page.html#text-TSpanNotes"/>
+ <h:meta name="assert" content="dx, dy attrs on tspan support length()"/>
+</metadata>
+ <text id="text" font-family="Verdana" font-size="55" fill="blue"
+ y="150"
+ x="120"
+ >His socks are <tspan id="tsp"
+ dx="60 90 -30 120 60 -257"
+ dy="0 12 24 12 0 -12 -24 -12 0"
+ >very</tspan> clean.</text>
+ <h:script src="/resources/testharness.js"/>
+ <h:script src="/resources/testharnessreport.js"/>
+ <script><![CDATA[
+ test(function() {
+ var tspan = document.getElementById('tsp');
+ assert_equals(tspan.dx.baseVal.length, 6);
+ assert_equals(tspan.dy.baseVal.length, 9);
+ });
+ ]]></script>
+</svg>
diff --git a/testing/web-platform/tests/svg/scripted/tspan-attrs-xyrotate-have-length.svg b/testing/web-platform/tests/svg/scripted/tspan-attrs-xyrotate-have-length.svg
new file mode 100644
index 0000000000..11086aa198
--- /dev/null
+++ b/testing/web-platform/tests/svg/scripted/tspan-attrs-xyrotate-have-length.svg
@@ -0,0 +1,24 @@
+<?xml version="1.0" standalone="no"?>
+<svg xmlns="http://www.w3.org/2000/svg"
+ xmlns:h="http://www.w3.org/1999/xhtml">
+ <metadata>
+ <h:link rel="help" href="https://svgwg.org/svg2-draft/single-page.html#text-TSpanNotes"/>
+ <h:meta name="assert" content="dx and dy attributes on text elements are lists that support length()"/>
+</metadata>
+ <text id="text" font-family="Verdana" font-size="55" fill="blue"
+ y="150"
+ x="120"
+ >Her socks were <tspan id="tsp"
+ x="280 325" y="150 155 160 165 170" rotate="-30,0,30"
+ >stained</tspan> with blood.</text>
+ <h:script src="/resources/testharness.js"/>
+ <h:script src="/resources/testharnessreport.js"/>
+ <script><![CDATA[
+ test(function() {
+ var tspan = document.getElementById('tsp');
+ assert_equals(tspan.x.baseVal.length, 2);
+ assert_equals(tspan.y.baseVal.length, 5);
+ assert_equals(tspan.rotate.baseVal.length, 3);
+ });
+ ]]></script>
+</svg>