Bug 1942639 - Propagate --filter argument from desktop_unittest.py to runreftest...
[gecko.git] / dom / xslt / tests / mochitest / test_parameter_conversion.html
bloba0ea6acce2d9506dfd3de61e706df151531c0396
1 <!DOCTYPE HTML>
2 <html>
3 <head>
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"/>
7 </head>
8 <body>
9 <p id="display"></p>
10 <div id="content" style="display: none"></div>
11 <pre id="test">
12 <script>
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" />
20 </xsl:template>
21 </xsl:stylesheet>`, "text/xml");
23 let processor = new XSLTProcessor();
24 processor.importStylesheet(xslt);
26 let callbackCalled = false;
27 let param = {
28 [Symbol.toPrimitive](hint) {
29 callbackCalled = true;
30 processor.removeParameter(null, 'test');
31 if (hint == 'string') {
32 return "Value";
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.");
46 </script>
47 </pre>
48 </body>
49 </html>