[webkit-changes] cvs commit: LayoutTests/fast/xsl/resources xslt-param.xml xslt-param.xsl

Eric eseidel at opensource.apple.com
Wed Dec 21 02:44:41 PST 2005


eseidel     05/12/21 02:44:40

  Modified:    .        ChangeLog
               fast/xsl xslt-processer-expected.txt xslt-processer.html
  Added:       fast/xsl/resources xslt-param.xml xslt-param.xsl
  Log:
  Bug #: none
  Submitted by: eseidel
  Reviewed by: mjs
          Beef up our XSLT processor tests to include a test which passes
          a parameter into the transform.  I also took this opportunity
          to clean up the output a bit, and in the process found another
          bug and file: http://bugzilla.opendarwin.org/show_bug.cgi?id=6180
  
          * fast/xsl/resources/xslt-param.xml: Added.
          * fast/xsl/resources/xslt-param.xsl: Added.
          * fast/xsl/xslt-processer-expected.txt:
          * fast/xsl/xslt-processer.html:
  
  Revision  Changes    Path
  1.176     +14 -0     LayoutTests/ChangeLog
  
  Index: ChangeLog
  ===================================================================
  RCS file: /cvs/root/LayoutTests/ChangeLog,v
  retrieving revision 1.175
  retrieving revision 1.176
  diff -u -r1.175 -r1.176
  --- ChangeLog	21 Dec 2005 02:06:17 -0000	1.175
  +++ ChangeLog	21 Dec 2005 10:44:39 -0000	1.176
  @@ -1,3 +1,17 @@
  +2005-12-21  Eric Seidel  <eseidel at apple.com>
  +
  +        Reviewed by mjs.
  +
  +        Beef up our XSLT processor tests to include a test which passes
  +        a parameter into the transform.  I also took this opportunity
  +        to clean up the output a bit, and in the process found another
  +        bug and file: http://bugzilla.opendarwin.org/show_bug.cgi?id=6180 
  +
  +        * fast/xsl/resources/xslt-param.xml: Added.
  +        * fast/xsl/resources/xslt-param.xsl: Added.
  +        * fast/xsl/xslt-processer-expected.txt:
  +        * fast/xsl/xslt-processer.html:
  +
   2005-12-20  Justin Garcia  <justin.garcia at apple.com>
   
           Reviewed by justin
  
  
  
  1.2       +13 -16    LayoutTests/fast/xsl/xslt-processer-expected.txt
  
  Index: xslt-processer-expected.txt
  ===================================================================
  RCS file: /cvs/root/LayoutTests/fast/xsl/xslt-processer-expected.txt,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- xslt-processer-expected.txt	27 Oct 2005 22:42:31 -0000	1.1
  +++ xslt-processer-expected.txt	21 Dec 2005 10:44:39 -0000	1.2
  @@ -53,39 +53,36 @@
   1.4 Import undefined stylesheet:
   ****Failure**** (expected exception, instead got result: "undefined")
   1.5 Don't import stylesheet:
  -undefined
  +Success
   
   2.0 DOMDocumentFragment transformToFragment(in DOMNode source, in DOMDocument output):
   
   2.1 fragment with undefined source:
   ****Failure**** (expected exception, instead got result: "undefined")
   2.2 fragment with undefined output document:
  -undefined
  +Success
   2.3 use non-DOMDocument output parameter:
   ****Failure**** (expected exception, instead got result: "undefined")
   2.4 transform to same fragment twice:
  -<html xmlns="http://www.w3.org/1999/xhtml">
  +Success
  +2.5 transformed fragment containing only text:
  +****Failure**** (expected: "SUCCESS" actual: "<html xmlns="http://www.w3.org/1999/xhtml">
   <head><title /></head>
   <body>
  -<pre>CHARACTERS IN XSLT: <<<&тест&>>>
  -SOURCE XML: <<<&тест&>>>
  -</pre>
  +<pre>
  +    	FAILURE
  +	</pre>
   </body>
  -</html>
  +</html>")
  +2.6 fragment using passed parameters:
  +****Failure**** (expected: "SUCCESS" actual: "null")
   
   3.0 DOMDocument transformToDocument(in DOMNode source):
   
   3.1 use non-DOMDocument output parameter:
   ****Failure**** (expected exception, instead got result: "undefined")
  -3.2 document from undefined source:
  -<html xmlns="http://www.w3.org/1999/xhtml">
  -<head><title /></head>
  -<body>
  -<pre>CHARACTERS IN XSLT: <<<&тест&>>>
  -SOURCE XML: <<<&тест&>>>
  -</pre>
  -</body>
  -</html>
  +3.2 transform twice:
  +Success
   
   4.0 void setParameter(in DOMString namespaceURI, in DOMString localName, in Value value):
   
  
  
  
  1.2       +47 -24    LayoutTests/fast/xsl/xslt-processer.html
  
  Index: xslt-processer.html
  ===================================================================
  RCS file: /cvs/root/LayoutTests/fast/xsl/xslt-processer.html,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- xslt-processer.html	27 Oct 2005 22:42:31 -0000	1.1
  +++ xslt-processer.html	21 Dec 2005 10:44:39 -0000	1.2
  @@ -1,8 +1,10 @@
   <html>
   <head>
   <STYLE>
  -    pre { border:1px solid blue }
  -    span { font-weight: bold }
  +pre { border:1px solid blue }
  +span { font-weight: bold }
  +.success { color: green; }
  +.failure { color: red; }
   </STYLE>
   </head>
   <body id="body">
  @@ -27,10 +29,10 @@
   function addResultExpectException(name, func) {
   	try {
   		var result = func();
  -		addStringResult(testname, "****Failure**** (expected exception, instead got result: \"" + result + "\")");
  +		addStringResult(testname, "****Failure**** (expected exception, instead got result: \"" + result + "\")", "failure");
   	} catch (e) {
   		// FIXME: probably should check exception type
  -		addStringResult(testname, "Success");
  +		addSuccessResult(testname);
   	}
   }
   
  @@ -38,18 +40,17 @@
   	var serializedValue;
   	if (value)
   		serializedValue = serializer.serializeToString(value);
  -	if (value == expectedValue)
  -		addStringResult(name, "Success");
  +	if (serializedValue == expectedValue)
  +		addSuccessResult(name);
   	else
  -		addStringResult(name, "****Failure**** (expected: \"" + expectedValue + "\" actual: \"" + serializedValue + "\")");
  +		addFailureResult(name, expectedValue, serializedValue);
   }
   
  -
   function addResultExpectValue(name, value, expectedValue) {
   	if (value == expectedValue)
  -		addStringResult(name, "Success");
  +		addSuccessResult(name);
   	else
  -		addStringResult(name, "****Failure**** (expected: \"" + expectedValue + "\" actual: \"" + value + "\")");
  +		addFailureResult(name, expectedValue, value);
   }
   
   function getXMLDocument(name)
  @@ -59,16 +60,26 @@
   	return requester.responseXML;
   }
   
  -function addStringResult(name, result)
  +function addStringResult(name, result, cssClass)
   {
   	testId++;
   	var testNumberString = "" + sectionId + "." + testId
   	var testIdString = "id" + testNumberString;
   	document.writeln("<span>" + testNumberString + " " + name + ":</span>");
  -	document.writeln("<pre id=\"" + testIdString + "\">@@NO VALUE@@</pre>");
  +	document.writeln("<pre id=\"" + testIdString + "\" class=\"" + cssClass + "\">@@NO VALUE@@</pre>");
   	document.getElementById(testIdString).firstChild.nodeValue = result;
   }
   
  +function addFailureResult(name, expectedValue, actual)
  +{
  +	addStringResult(name, "****Failure**** (expected: \"" + expectedValue + "\" actual: \"" + actual + "\")", "failure");
  +}
  +
  +function addSuccessResult(name)
  +{
  +	addStringResult(name, "Success", "success");
  +}
  +
   function addXMLResult(name, result)
   {
   	var str;
  @@ -120,7 +131,7 @@
   
   processor.reset();
   var newXML = processor.transformToDocument(xml);
  -addXMLResult("Don't import stylesheet", newXML);
  +addResultExpectValueWhenSerialized("Don't import stylesheet", newXML, undefined);
   
   
   
  @@ -138,7 +149,7 @@
   
   ownerDocument = document.implementation.createDocument("", "test", null);
   newFragment = processor.transformToFragment(xml, undefined);
  -addXMLResult("fragment with undefined output document", newFragment);
  +addResultExpectValueWhenSerialized("fragment with undefined output document", newFragment, undefined);
   
   // 2.3 use non-DOMDocument output parameter
   
  @@ -151,7 +162,22 @@
   var secondDocument = document.implementation.createDocument("", "test", null);
   newFragment = processor.transformToFragment(xml, ownerDocument);
   var secondFragment = processor.transformToFragment(xml, secondDocument);
  -addXMLResult("transform to same fragment twice", secondFragment);
  +addResultExpectValueWhenSerialized("transform to same fragment twice", secondFragment, serializer.serializeToString(newFragment));
  +
  +
  +// 2.5 transform to text
  +// 2.6 fragment using passed parameters
  +var paramXSL = getXMLDocument("resources/xslt-param.xsl");
  +var paramXML = getXMLDocument("resources/xslt-param.xml");
  +
  +var paramProcessor = new XSLTProcessor;
  +paramProcessor.importStylesheet(paramXSL);
  +paramProcessor.setParameter(null, "param", "SUCCESS");
  +
  +var ownerDocument = document.implementation.createDocument("", "test", null);
  +var fragment = paramProcessor.transformToFragment(paramXML, ownerDocument);
  +addResultExpectValueWhenSerialized("transformed fragment containing only text", fragment, "SUCCESS");
  +addResultExpectValue("fragment using passed parameters", fragment.firstChild.nodeValue, "SUCCESS");
   
   
   
  @@ -162,15 +188,15 @@
   
   processor.reset();
   processor.importStylesheet(xsl1);
  -addResultExpectException(testname, function () { return processor.transformToDocument(undefined); } );
  +addResultExpectException("document from undefined source", function () { return processor.transformToDocument(undefined); } );
   
   // 3.2 transform twice
   
   processor.reset();
   processor.importStylesheet(xsl1);
   var newXML = processor.transformToDocument(xml);
  -var newXML = processor.transformToDocument(xml);
  -addXMLResult("document from undefined source", newXML);
  +var newerXML = processor.transformToDocument(xml);
  +addResultExpectValueWhenSerialized("transform twice", newXML, serializer.serializeToString(newerXML));
   
   
   
  @@ -188,7 +214,7 @@
   // 4.2 pass undefined namespace
   
   processor.setParameter(undefined, "foo", "Success");
  -addStringResult("pass undefined namespace", processor.getParameter(undefined, "foo"));
  +addResultExpectValue("pass undefined namespace", processor.getParameter(undefined, "foo"), "Success");
   
   // 4.3 pass setParameter an undefined name
   
  @@ -253,7 +279,7 @@
   // 6.4 pass removeParameter a name which has not been set
   
   processor.removeParameter(undefined, "neverbeensetforremove");
  -addStringResult("pass removeParameter a name which has not been set", "Success");
  +addResultExpectValue("pass removeParameter a name which has not been set", "Success", "Success");
   
   // 6.5 verify removeParameter actually removes
   processor.setParameter(null, "test", "testValue");
  @@ -287,10 +313,7 @@
   // 8.2 call, verify that stylesheet has been cleared after reset()
   var testname = "verify that stylesheet has been cleared";
   var resultDocument = processor.transformToDocument(xml);
  -if (resultDocument)
  -	addStringResult(testname, "****Failure**** (actual: " + serializer.serializeToString(resultDocument) + ")");
  -else
  -	addStringResult(testname, "Success");
  +addResultExpectValueWhenSerialized(testname, resultDocument, undefined);
   
   </script>
   
  
  
  
  1.1                  LayoutTests/fast/xsl/resources/xslt-param.xml
  
  Index: xslt-param.xml
  ===================================================================
  <?xml version="1.0"?>
  <TEST>FAILURE</TEST>
  
  
  
  1.1                  LayoutTests/fast/xsl/resources/xslt-param.xsl
  
  Index: xslt-param.xsl
  ===================================================================
  <?xml version="1.0" encoding="UTF-8"?>
  <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
  	<xsl:output method="text" encoding="UTF-8" />
      <xsl:param name="param">
      	FAILURE
  	</xsl:param>
  	<xsl:template match="TEST">
  		<xsl:value-of select="$param" />
  	</xsl:template>
  </xsl:stylesheet>
  
  
  



More information about the webkit-changes mailing list