forked from mirrors/gecko-dev
Bug 1758062 - Convert parameters upfront - testcase. r=smaug
Differential Revision: https://phabricator.services.mozilla.com/D140360
This commit is contained in:
parent
a5157b246f
commit
c6161f4462
2 changed files with 51 additions and 0 deletions
|
|
@ -54,4 +54,6 @@ support-files = ["file_metaRefresh.xml"]
|
|||
|
||||
["test_parameter.html"]
|
||||
|
||||
["test_parameter_conversion.html"]
|
||||
|
||||
["test_sorting_invalid_lang.html"]
|
||||
|
|
|
|||
49
dom/xslt/tests/mochitest/test_parameter_conversion.html
Normal file
49
dom/xslt/tests/mochitest/test_parameter_conversion.html
Normal file
|
|
@ -0,0 +1,49 @@
|
|||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<head>
|
||||
<title>Test for setParameter conversion to XSLT type</title>
|
||||
<script src="/tests/SimpleTest/SimpleTest.js"></script>
|
||||
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
|
||||
</head>
|
||||
<body>
|
||||
<p id="display"></p>
|
||||
<div id="content" style="display: none"></div>
|
||||
<pre id="test">
|
||||
<script>
|
||||
let parser = new DOMParser();
|
||||
let xml = parser.parseFromString('<?xml version="1.0" encoding="utf-8" ?><root/>', "text/xml");
|
||||
let xslt = parser.parseFromString(`<?xml version="1.0" encoding="utf-8"?>
|
||||
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
|
||||
<xsl:param name="test" />
|
||||
<xsl:template match="/">
|
||||
<xsl:value-of select="$test" />
|
||||
</xsl:template>
|
||||
</xsl:stylesheet>`, "text/xml");
|
||||
|
||||
let processor = new XSLTProcessor();
|
||||
processor.importStylesheet(xslt);
|
||||
|
||||
let callbackCalled = false;
|
||||
let param = {
|
||||
[Symbol.toPrimitive](hint) {
|
||||
callbackCalled = true;
|
||||
processor.removeParameter(null, 'test');
|
||||
if (hint == 'string') {
|
||||
return "Value";
|
||||
}
|
||||
throw new Error("Not converting to string?");
|
||||
}
|
||||
};
|
||||
|
||||
processor.setParameter(null, 'test', param);
|
||||
ok(callbackCalled, "Parameter was converted during call to setParameter.");
|
||||
is(processor.getParameter(null, 'test'), "Value", "processor.removeParameter during string conversion should have no effect.");
|
||||
|
||||
callbackCalled = false;
|
||||
processor.transformToDocument(xml);
|
||||
ok(!callbackCalled, "Parameter was not converted during call to transformToDocument.");
|
||||
is(processor.getParameter(null, 'test'), "Value", "processor.removeParameter during string conversion should have no effect.");
|
||||
</script>
|
||||
</pre>
|
||||
</body>
|
||||
</html>
|
||||
Loading…
Reference in a new issue