summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/dom/xslt
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/dom/xslt
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/dom/xslt')
-rw-r--r--testing/web-platform/tests/dom/xslt/README.md11
-rw-r--r--testing/web-platform/tests/dom/xslt/externalScript.js1
-rw-r--r--testing/web-platform/tests/dom/xslt/invalid-output-encoding-crash.html26
-rw-r--r--testing/web-platform/tests/dom/xslt/sort-ref.html10
-rw-r--r--testing/web-platform/tests/dom/xslt/sort.html48
-rw-r--r--testing/web-platform/tests/dom/xslt/strip-space-crash.xml33
-rw-r--r--testing/web-platform/tests/dom/xslt/transformToFragment-on-node-from-inactive-document-crash.html11
-rw-r--r--testing/web-platform/tests/dom/xslt/transformToFragment.tentative.window.js39
8 files changed, 179 insertions, 0 deletions
diff --git a/testing/web-platform/tests/dom/xslt/README.md b/testing/web-platform/tests/dom/xslt/README.md
new file mode 100644
index 0000000000..ac713ce179
--- /dev/null
+++ b/testing/web-platform/tests/dom/xslt/README.md
@@ -0,0 +1,11 @@
+# XSLT
+
+This directory contains tentative tests for [XSLT](https://dom.spec.whatwg.org/#xslt).
+
+See [whatwg/dom#181](https://github.com/whatwg/dom/issues/181) for getting XSLT
+better specified.
+
+There are additional details on XSLT in HTML:
+- [Interactions with XPath and XSLT](https://html.spec.whatwg.org/multipage/infrastructure.html#interactions-with-xpath-and-xslt)
+- [Interaction of `script` elements and XSLT](https://html.spec.whatwg.org/multipage/scripting.html#scriptTagXSLT) (non-normative)
+- [Interaction of `template` elements with XSLT and XPath](https://html.spec.whatwg.org/multipage/scripting.html#template-XSLT-XPath) (non-normative)
diff --git a/testing/web-platform/tests/dom/xslt/externalScript.js b/testing/web-platform/tests/dom/xslt/externalScript.js
new file mode 100644
index 0000000000..7a2bf36225
--- /dev/null
+++ b/testing/web-platform/tests/dom/xslt/externalScript.js
@@ -0,0 +1 @@
+window.externalScript = true;
diff --git a/testing/web-platform/tests/dom/xslt/invalid-output-encoding-crash.html b/testing/web-platform/tests/dom/xslt/invalid-output-encoding-crash.html
new file mode 100644
index 0000000000..d84bb5b3c3
--- /dev/null
+++ b/testing/web-platform/tests/dom/xslt/invalid-output-encoding-crash.html
@@ -0,0 +1,26 @@
+<body>
+
+<script id=o_xml type="text/plain">
+ <?xml version="1.0" encoding="UTF-8"?>
+</script>
+
+<script id=o_xslt type="text/plain"><?xml version="1.0" encoding="UTF-8"?>
+ <xsl:transform version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
+ <xsl:output indent="no" omit-xml-declaration="no" encoding="bad-encoding" standalone="yes" />
+ </xsl:transform>
+</script>
+
+<script>
+addEventListener("load", function() {
+ const doc = new DOMParser();
+ const xml = doc.parseFromString(o_xml.textContent, "text/xml");
+ const xsl = doc.parseFromString(o_xslt.textContent, "text/xml");
+ const xsltPrs = new XSLTProcessor();
+ xsltPrs.importStylesheet(xsl);
+ xsltPrs.transformToDocument(xml);
+
+ document.body.appendChild(document.createTextNode("PASS: renderer didn't crash"));
+});
+</script>
+
+</body>
diff --git a/testing/web-platform/tests/dom/xslt/sort-ref.html b/testing/web-platform/tests/dom/xslt/sort-ref.html
new file mode 100644
index 0000000000..163002d0d0
--- /dev/null
+++ b/testing/web-platform/tests/dom/xslt/sort-ref.html
@@ -0,0 +1,10 @@
+<!DOCTYPE html>
+<link rel=author href="mailto:jarhar@chromium.org">
+<link rel=help href="https://bugs.chromium.org/p/chromium/issues/detail?id=1399858">
+
+<div>
+ <div>1</div>
+ <div>2</div>
+ <div>3</div>
+ <div>7</div>
+</div>
diff --git a/testing/web-platform/tests/dom/xslt/sort.html b/testing/web-platform/tests/dom/xslt/sort.html
new file mode 100644
index 0000000000..631c3edd6a
--- /dev/null
+++ b/testing/web-platform/tests/dom/xslt/sort.html
@@ -0,0 +1,48 @@
+<!DOCTYPE html>
+<link rel=match href="sort-ref.html">
+
+<body>
+ <div id="container"></div>
+</body>
+
+<script type="text/xml" id="sampleXml">
+ <root>
+ <node id="1" />
+ <node id="7" />
+ <node id="3" />
+ <node id="2" />
+ </root>
+</script>
+
+<script type="text/xml" id="sampleXsl">
+ <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:msxsl="urn:schemas-microsoft-com:xslt">
+
+ <xsl:template match="/">
+ <xsl:apply-templates select="//node">
+ <xsl:sort select="@id" data-type="number" />
+ </xsl:apply-templates>
+ </xsl:template>
+
+ <xsl:template match="node">
+ <div>
+ <xsl:value-of select="@id"/>
+ </div>
+ </xsl:template>
+
+ </xsl:stylesheet>
+</script>
+
+<script>
+ let parser = new DOMParser();
+ const xslStyleSheet = parser.parseFromString(document.getElementById('sampleXsl').textContent, 'text/xml');
+
+ const xsltProcessor = new XSLTProcessor();
+ xsltProcessor.importStylesheet(xslStyleSheet);
+
+ parser = new DOMParser();
+ const xmlDoc = parser.parseFromString(document.getElementById('sampleXml').textContent, 'text/xml');
+
+ const fragment = xsltProcessor.transformToFragment(xmlDoc, document);
+
+ document.getElementById('container').appendChild(fragment);
+</script>
diff --git a/testing/web-platform/tests/dom/xslt/strip-space-crash.xml b/testing/web-platform/tests/dom/xslt/strip-space-crash.xml
new file mode 100644
index 0000000000..61a906a5e7
--- /dev/null
+++ b/testing/web-platform/tests/dom/xslt/strip-space-crash.xml
@@ -0,0 +1,33 @@
+<?xml-stylesheet type="text/xsl" href="#style"?>
+<xsl:stylesheet
+ version="1.0"
+ xml:id="style"
+ xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
+ xmlns:exsl="http://exslt.org/common"
+ extension-element-prefixes="exsl"
+>
+ <xsl:strip-space elements="s"/>
+
+ <xsl:template match="/">
+ <xsl:variable name="space">
+ <s>
+ <xsl:text> </xsl:text>
+ <e/>
+ <xsl:text> </xsl:text>
+ <e/>
+ <xsl:text> </xsl:text>
+ </s>
+ </xsl:variable>
+ <xsl:apply-templates select="exsl:node-set($space)/s"/>
+ </xsl:template>
+
+ <xsl:template match="s">
+ <r>
+ <xsl:variable name="text-nodes" select="text()"/>
+ <xsl:apply-templates/>
+ <xsl:copy-of select="$text-nodes"/>
+ </r>
+ </xsl:template>
+
+ <xsl:template match="node()"/>
+</xsl:stylesheet>
diff --git a/testing/web-platform/tests/dom/xslt/transformToFragment-on-node-from-inactive-document-crash.html b/testing/web-platform/tests/dom/xslt/transformToFragment-on-node-from-inactive-document-crash.html
new file mode 100644
index 0000000000..38a62a0a9d
--- /dev/null
+++ b/testing/web-platform/tests/dom/xslt/transformToFragment-on-node-from-inactive-document-crash.html
@@ -0,0 +1,11 @@
+<body>
+<iframe id=i></iframe>
+<script>
+var el = i.contentDocument.documentElement;
+i.remove()
+var x = new XSLTProcessor();
+var xsl =new DOMParser().parseFromString('<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"/>','application/xml');
+x.importStylesheet(xsl);
+x.transformToDocument(el);
+</script>
+</body>
diff --git a/testing/web-platform/tests/dom/xslt/transformToFragment.tentative.window.js b/testing/web-platform/tests/dom/xslt/transformToFragment.tentative.window.js
new file mode 100644
index 0000000000..7bb6a56855
--- /dev/null
+++ b/testing/web-platform/tests/dom/xslt/transformToFragment.tentative.window.js
@@ -0,0 +1,39 @@
+const cases = {
+ internal: '<script>window.internalScript = true;</script>',
+ external: '<script src="externalScript.js"></script>',
+};
+
+const loaded = new Promise(resolve => {
+ window.addEventListener('load', resolve);
+});
+
+Object.entries(cases).forEach(([k, v]) => {
+ const xsltSrc = `<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
+<xsl:output method="html" encoding="utf-8" version="5"/>
+<xsl:template match="/">
+ <section>
+ ${v}
+ </section>
+</xsl:template>
+</xsl:stylesheet>`;
+
+ const processor = new XSLTProcessor();
+ const parser = new DOMParser();
+ processor.importStylesheet(
+ parser.parseFromString(xsltSrc, 'application/xml')
+ );
+ document.body.appendChild(
+ processor.transformToFragment(
+ parser.parseFromString('<x/>', 'application/xml'),
+ document
+ )
+ );
+
+ promise_test(async () => {
+ await loaded;
+ assert_true(
+ window[`${k}Script`],
+ 'script element from XSLTProcessor.transformToFragment() is evaluated'
+ );
+ }, `${k} script`);
+})