4 <title>Test for setParameter conversion to XSLT type
</title>
5 <script src=
"/tests/SimpleTest/SimpleTest.js"></script>
6 <link rel=
"stylesheet" type=
"text/css" href=
"/tests/SimpleTest/test.css"/>
10 <div id=
"content" style=
"display: none"></div>
13 let parser
= new DOMParser();
14 let xml
= parser
.parseFromString('<?xml version="1.0" encoding="utf-8" ?><root/>', "text/xml");
15 let xslt
= parser
.parseFromString(`<?xml version="1.0" encoding="utf-8"?>
16 <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
17 <xsl:param name="test" />
18 <xsl:template match="/">
19 <xsl:value-of select="$test" />
21 </xsl:stylesheet>`, "text/xml");
23 let processor
= new XSLTProcessor();
24 processor
.importStylesheet(xslt
);
26 let callbackCalled
= false;
28 [Symbol
.toPrimitive
](hint
) {
29 callbackCalled
= true;
30 processor
.removeParameter(null, 'test');
31 if (hint
== 'string') {
34 throw new Error("Not converting to string?");
38 processor
.setParameter(null, 'test', param
);
39 ok(callbackCalled
, "Parameter was converted during call to setParameter.");
40 is(processor
.getParameter(null, 'test'), "Value", "processor.removeParameter during string conversion should have no effect.");
42 callbackCalled
= false;
43 processor
.transformToDocument(xml
);
44 ok(!callbackCalled
, "Parameter was not converted during call to transformToDocument.");
45 is(processor
.getParameter(null, 'test'), "Value", "processor.removeParameter during string conversion should have no effect.");