Fix for bug 551654 (The EXSLT node-set function fails to convert number, boolean and string values to text nodes). r=peterv.
authorAndreas Wictor <andreas.wictor@xcerion.com>
Tue, 04 May 2010 12:10:44 +0200
changeset 41758 c8c9454755d331bcd958faa2b2abb91b7f0d591e
parent 41757 5d60184d9e988e404541c3333ee0e916c08f1dec
child 41759 764614e8e92f40cf707ce7cabd54d2444256868e
push id13119
push userpvanderbeken@mozilla.com
push dateTue, 04 May 2010 13:10:26 +0000
treeherdermozilla-central@c8c9454755d3 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerspeterv
bugs551654
milestone1.9.3a5pre
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
Fix for bug 551654 (The EXSLT node-set function fails to convert number, boolean and string values to text nodes). r=peterv.
content/xslt/src/xslt/txEXSLTFunctions.cpp
content/xslt/tests/mochitest/Makefile.in
content/xslt/tests/mochitest/test_bug551654.html
--- a/content/xslt/src/xslt/txEXSLTFunctions.cpp
+++ b/content/xslt/src/xslt/txEXSLTFunctions.cpp
@@ -125,16 +125,19 @@ createTextNode(txIEvalContext *aContext,
 #ifdef TX_EXE
     return NS_ERROR_NOT_IMPLEMENTED;
 #else
     nsIDocument *doc = txXPathNativeNode::getDocument(document);
     nsCOMPtr<nsIContent> text;
     nsresult rv = NS_NewTextNode(getter_AddRefs(text), doc->NodeInfoManager());
     NS_ENSURE_SUCCESS(rv, rv);
 
+    rv = text->SetText(aValue, PR_FALSE);
+    NS_ENSURE_SUCCESS(rv, rv);
+
     *aResult = txXPathNativeNode::createXPathNode(text, PR_TRUE);
     NS_ENSURE_TRUE(*aResult, NS_ERROR_OUT_OF_MEMORY);
 
     return NS_OK;
 #endif
 }
 
 #ifndef TX_EXE
--- a/content/xslt/tests/mochitest/Makefile.in
+++ b/content/xslt/tests/mochitest/Makefile.in
@@ -46,12 +46,13 @@ include $(topsrcdir)/config/rules.mk
 
 _TEST_FILES = 	test_bug319374.xhtml \
 		test_bug440974.html \
 		test_bug427060.html \
 		test_bug468208.html \
 		test_bug453441.html \
 		test_bug511487.html \
 		test_bug551412.html \
+		test_bug551654.html \
 		$(NULL)
 
 libs:: $(_TEST_FILES)
 	$(INSTALL) $(foreach f,$^,"$f") $(DEPTH)/_tests/testing/mochitest/tests/$(relativesrcdir)
new file mode 100644
--- /dev/null
+++ b/content/xslt/tests/mochitest/test_bug551654.html
@@ -0,0 +1,50 @@
+<!DOCTYPE HTML>
+<html>
+<!--
+https://bugzilla.mozilla.org/show_bug.cgi?id=551654
+-->
+<head>
+  <title>Test for Bug 551654</title>
+  <script type="application/javascript" src="/MochiKit/packed.js"></script>
+  <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
+  <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
+</head>
+<body>
+<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=551654">Mozilla Bug 551654</a>
+<p id="display"></p>
+<div id="content" style="display: none">
+  
+</div>
+<pre id="test">
+<script type="application/javascript">
+
+/** Test for Bug 551654 **/
+
+  var didTransform = false;
+  var processor = new XSLTProcessor();
+  var style =
+    '<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"' +
+                    'xmlns:exsl="http://exslt.org/common"' +
+                    'version="1.0">' +
+      '<xsl:output method="html"/>' +
+      '<xsl:template match="/">' +
+        '<xsl:copy-of select="exsl:node-set(42)"/>' +
+      '</xsl:template>' +
+    '</xsl:stylesheet>';
+  var styleDoc = new DOMParser().parseFromString (style, "text/xml");
+
+  var data =
+    '<root/>';
+  var originalDoc = new DOMParser().parseFromString(data, "text/xml");
+
+  processor.importStylesheet(styleDoc);
+  var fragment = processor.transformToFragment(originalDoc, document);
+  is(content.firstChild.nodeType, Node.TEXT_NODE,
+     "Result of transform should be a textnode");
+  is(content.firstChild.nodeValue, "42",
+     "Result of transform should be a textnode with value '42'");
+
+</script>
+</pre>
+</body>
+</html>