[webkit-changes] cvs commit: LayoutTests/fast/xsl xslt-processer-expected.txt xslt-processer.html

Eric eseidel at opensource.apple.com
Thu Oct 27 15:42:32 PDT 2005


eseidel     05/10/27 15:42:32

  Modified:    .        ChangeLog
  Added:       fast/xsl xslt-processer-expected.txt xslt-processer.html
  Log:
  Bug #: 3275
  Submitted by: eseidel
  Reviewed by: darin
          Test cases for the new XSLTProcessor JS object.
          http://bugzilla.opendarwin.org/show_bug.cgi?id=3275
  
          * fast/xsl/xslt-processer-expected.txt: Added.
          * fast/xsl/xslt-processer.html: Added.
  
  Revision  Changes    Path
  1.61      +10 -0     LayoutTests/ChangeLog
  
  Index: ChangeLog
  ===================================================================
  RCS file: /cvs/root/LayoutTests/ChangeLog,v
  retrieving revision 1.60
  retrieving revision 1.61
  diff -u -r1.60 -r1.61
  --- ChangeLog	27 Oct 2005 06:31:58 -0000	1.60
  +++ ChangeLog	27 Oct 2005 22:42:31 -0000	1.61
  @@ -1,3 +1,13 @@
  +2005-10-27  Eric Seidel  <eseidel at apple.com>
  +
  +        Reviewed by darin.
  +
  +        Test cases for the new XSLTProcessor JS object.
  +        http://bugzilla.opendarwin.org/show_bug.cgi?id=3275
  +
  +        * fast/xsl/xslt-processer-expected.txt: Added.
  +        * fast/xsl/xslt-processer.html: Added.
  +
   2005-10-26  Eric Seidel  <eseidel at apple.com>
   
           Reviewed by mjs & darin.
  
  
  
  1.1                  LayoutTests/fast/xsl/xslt-processer-expected.txt
  
  Index: xslt-processer-expected.txt
  ===================================================================
  0.1 original xml:
  <?xml-stylesheet type="text/xsl" href="xslt-text.xsl"?><TEST>SOURCE XML: <<<&тест&>>></TEST>
  0.2 xsl1:
  <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
  
  <xsl:output method="text" encoding="KOI8-R" />
  <xsl:template match="TEST">CHARACTERS IN XSLT: <<<&тест&>>>
  <xsl:apply-templates /><xsl:text>
  </xsl:text></xsl:template>
  
  <xsl:template>
  		<xsl:value-of select="." />
  </xsl:template>
  
  </xsl:stylesheet>
  0.3 xsl2:
  <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
      <xsl:output method="html" encoding="UTF-8" />
      <xsl:template match="TEST">
          <html xmlns="http://www.w3.org/1999/xhtml">
              <head>
                  <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
              </head>  
              <body>
                CHARACTERS IN XSLT: ééééééééééé <br /> <xsl:apply-templates />
              </body>
          </html>
    </xsl:template>
  
  <xsl:template>
  		<xsl:value-of select="." />
  </xsl:template>
  
  </xsl:stylesheet>
  
  1.0 void importStylesheet(in DOMNode style):
  
  1.1 Import two different stylesheets:
  <HTML xmlns="http://www.w3.org/1999/xhtml"><HEAD><META http-equiv="Content-Type" content="text/html; charset=UTF-8"></HEAD><BODY>
                CHARACTERS IN XSLT: ééééééééééé <BR><BR>SOURCE XML: <<<&тест&>>>
  </BODY></HTML>
  1.2 Import same stylesheet twice:
  <html xmlns="http://www.w3.org/1999/xhtml">
  <head><title /></head>
  <body>
  <pre>CHARACTERS IN XSLT: <<<&тест&>>>
  SOURCE XML: <<<&тест&>>>
  </pre>
  </body>
  </html>
  1.3 Import undefined stylesheet:
  ****Failure**** (expected exception, instead got result: "undefined")
  1.4 Import undefined stylesheet:
  ****Failure**** (expected exception, instead got result: "undefined")
  1.5 Don't import stylesheet:
  undefined
  
  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
  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">
  <head><title /></head>
  <body>
  <pre>CHARACTERS IN XSLT: <<<&тест&>>>
  SOURCE XML: <<<&тест&>>>
  </pre>
  </body>
  </html>
  
  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>
  
  4.0 void setParameter(in DOMString namespaceURI, in DOMString localName, in Value value):
  
  4.1 pass setParameter same localname, different namespaces:
  ****Failure**** (expected: "Success" actual: "Failure")
  4.2 pass undefined namespace:
  Success
  4.3 pass setParameter an undefined name:
  ****Failure**** (expected exception, instead got result: "undefined")
  4.4 pass unsupported value to setParameter:
  ****Failure**** (expected exception, instead got result: "undefined")
  
  5.0 Value getParameter(in DOMString namespaceURI, in DOMString localName):
  
  5.1 pass getParameter an undefined name:
  ****Failure**** (expected exception, instead got result: "undefined")
  5.2 pass getParameter a name which has not been set:
  Success
  5.3 verify getParameter actually gets (and set sets):
  Success
  
  6.0 void removeParameter(in DOMString namespaceURI, in DOMString localName):
  
  6.1 pass removeParameter same localname, different namespaces:
  ****Failure**** (expected: "Success" actual: "Failure")
  6.2 verify removeParameter actually removes using undefined namespace:
  Success
  6.3 pass removeParameter undefined name:
  Success
  6.4 pass removeParameter a name which has not been set:
  Success
  6.5 verify removeParameter actually removes:
  Success
  
  7.0 void clearParameters():
  
  7.1 verify that clearParameters does:
  Success
  
  8.0 void reset():
  
  8.1 verify that parameters have been cleared:
  Success
  8.2 verify that stylesheet has been cleared:
  Success
  
  
  
  
  1.1                  LayoutTests/fast/xsl/xslt-processer.html
  
  Index: xslt-processer.html
  ===================================================================
  <html>
  <head>
  <STYLE>
      pre { border:1px solid blue }
      span { font-weight: bold }
  </STYLE>
  </head>
  <body id="body">
  
  <script>
  if (window.layoutTestController)
  	layoutTestController.dumpAsText();
  
  var requester = new XMLHttpRequest();
  var processor = new XSLTProcessor();
  var serializer = new XMLSerializer();
  
  var sectionId = 0;
  var testId = 0;
  
  function addSectionHeader(name) {
  	sectionId++;
  	document.writeln("<br><span>" + sectionId + ".0 " + name + ":</span><br><br>");
  	testId = 0;
  }
  
  function addResultExpectException(name, func) {
  	try {
  		var result = func();
  		addStringResult(testname, "****Failure**** (expected exception, instead got result: \"" + result + "\")");
  	} catch (e) {
  		// FIXME: probably should check exception type
  		addStringResult(testname, "Success");
  	}
  }
  
  function addResultExpectValueWhenSerialized(name, value, expectedValue) {
  	var serializedValue;
  	if (value)
  		serializedValue = serializer.serializeToString(value);
  	if (value == expectedValue)
  		addStringResult(name, "Success");
  	else
  		addStringResult(name, "****Failure**** (expected: \"" + expectedValue + "\" actual: \"" + serializedValue + "\")");
  }
  
  
  function addResultExpectValue(name, value, expectedValue) {
  	if (value == expectedValue)
  		addStringResult(name, "Success");
  	else
  		addStringResult(name, "****Failure**** (expected: \"" + expectedValue + "\" actual: \"" + value + "\")");
  }
  
  function getXMLDocument(name)
  {
  	requester.open("GET", name, false);
  	requester.send(null);
  	return requester.responseXML;
  }
  
  function addStringResult(name, result)
  {
  	testId++;
  	var testNumberString = "" + sectionId + "." + testId
  	var testIdString = "id" + testNumberString;
  	document.writeln("<span>" + testNumberString + " " + name + ":</span>");
  	document.writeln("<pre id=\"" + testIdString + "\">@@NO VALUE@@</pre>");
  	document.getElementById(testIdString).firstChild.nodeValue = result;
  }
  
  function addXMLResult(name, result)
  {
  	var str;
  	if (result)
  		str = serializer.serializeToString(result);
  	addStringResult(name, str);
  }
  
  var xml = getXMLDocument("xslt-text.xml");
  addXMLResult("original xml", xml);
  var xsl1 = getXMLDocument("xslt-text.xsl");
  addXMLResult("xsl1", xsl1);
  var xsl2 = getXMLDocument("resources/xslt-enc.xsl");
  addXMLResult("xsl2", xsl2);
  
  
  
  // 1.0 void importStylesheet(in DOMNode style);
  addSectionHeader("void importStylesheet(in DOMNode style)");
  // 1.1 Import two different stylesheets (last one wins)
  
  processor.importStylesheet(xsl1);
  processor.importStylesheet(xsl2);
  var newXML = processor.transformToDocument(xml);
  addXMLResult("Import two different stylesheets", newXML);
  
  // 1.2 Import same stylesheet twice
  
  processor.reset();
  processor.importStylesheet(xsl1);
  processor.importStylesheet(xsl1);
  
  var newXML = processor.transformToDocument(xml);
  addXMLResult("Import same stylesheet twice", newXML);
  
  // 1.3 Import undefined stylesheet
  
  processor.reset();
  var testname = "Import undefined stylesheet";
  addResultExpectException(testname, function () { return processor.importStylesheet(undefined); } );
  
  // 1.4 Import invalid stylesheet (not wellformed xlst)
  
  processor.reset();
  var testName = "Import invalid stylesheet";
  addResultExpectException(testname, function () { return processor.importStylesheet(xml); } );
  
  // 1.5 Don't import stylesheet
  
  processor.reset();
  var newXML = processor.transformToDocument(xml);
  addXMLResult("Don't import stylesheet", newXML);
  
  
  
  // 2.0 DOMDocumentFragment transformToFragment(in DOMNode source, in DOMDocument output);
  addSectionHeader("DOMDocumentFragment transformToFragment(in DOMNode source, in DOMDocument output)");
  // 2.1 fragment with undefined source
  
  processor.reset();
  processor.importStylesheet(xsl1);
  var ownerDocument = document.implementation.createDocument("", "test", null);
  var testname = "fragment with undefined source";
  addResultExpectException(testname, function () { return processor.transformToFragment(undefined, ownerDocument); } );
  
  // 2.2 fragment with undefined output document
  
  ownerDocument = document.implementation.createDocument("", "test", null);
  newFragment = processor.transformToFragment(xml, undefined);
  addXMLResult("fragment with undefined output document", newFragment);
  
  // 2.3 use non-DOMDocument output parameter
  
  var testname = "use non-DOMDocument output parameter";
  addResultExpectException(testname, function () { return processor.transformToFragment(xml, "error"); } );
  
  // 2.4 transform to same fragment twice
  
  ownerDocument = document.implementation.createDocument("", "test", null);
  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);
  
  
  
  // 3.0 DOMDocument transformToDocument(in DOMNode source);
  addSectionHeader("DOMDocument transformToDocument(in DOMNode source)");
  
  // 3.1 document from undefined source
  
  processor.reset();
  processor.importStylesheet(xsl1);
  addResultExpectException(testname, 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);
  
  
  
  
  // 4.0 void setParameter(in DOMString namespaceURI, in DOMString localName, in Value value);
  addSectionHeader("void setParameter(in DOMString namespaceURI, in DOMString localName, in Value value)");
  processor.reset();
  
  // 4.1 pass setParameter same localname, different namespaces
  processor.setParameter("foo", "foo", "Success");
  processor.setParameter("bar", "foo", "Failure");
  var testname = "pass setParameter same localname, different namespaces";
  addResultExpectValue(testname, processor.getParameter("foo", "foo"), "Success");
  
  // 4.2 pass undefined namespace
  
  processor.setParameter(undefined, "foo", "Success");
  addStringResult("pass undefined namespace", processor.getParameter(undefined, "foo"));
  
  // 4.3 pass setParameter an undefined name
  
  var testname = "pass setParameter an undefined name";
  addResultExpectException(testname, function () { return processor.setParameter(undefined, undefined , "Success"); } );
  
  // 4.4 pass undefined value
  
  processor.setParameter(undefined, "foo", undefined);
  var testname = "pass undefined value";
  
  
  // 4.5 pass unsupported value to setParameter (object, for instance?)
  
  var testname = "pass unsupported value to setParameter";
  addResultExpectException(testname, function () { return processor.setParameter(undefined, "invalid" , new Array()); } );
  
  
  // 5.0 Value getParameter(in DOMString namespaceURI, in DOMString localName);
  addSectionHeader("Value getParameter(in DOMString namespaceURI, in DOMString localName)");
  
  // 5.1 pass undefined name
  
  var testname = "pass getParameter an undefined name";
  addResultExpectException(testname, function () { return processor.getParameter(undefined, undefined); } );
  
  // 5.2 pass getParameter a name which has not been set
  
  var testname = "pass getParameter a name which has not been set";
  addResultExpectValue(testname, processor.getParameter(undefined, "hasnotbeenset"), undefined);
  
  // 5.3 verify getParameter actually gets (and set sets)
  processor.setParameter(null, "test", "testValue");
  var testname = "verify getParameter actually gets (and set sets)";
  addResultExpectValue(testname, processor.getParameter(null, "test"), "testValue");
  
  
  
  // 6.0 void removeParameter(in DOMString namespaceURI, in DOMString localName);
  addSectionHeader("void removeParameter(in DOMString namespaceURI, in DOMString localName)");
  // 6.1 pass removeParameter same localname, different namespaces
  
  processor.setParameter("foo", "foo", "Success");
  processor.setParameter("bar", "foo", "Failure");
  var testname = "pass removeParameter same localname, different namespaces";
  addResultExpectValue(testname, processor.getParameter("foo", "foo"), "Success");
  
  // 6.2 pass undefined namespace
  
  processor.setParameter(undefined, "test", "testValue");
  processor.removeParameter(undefined, "test");
  var testname = "verify removeParameter actually removes using undefined namespace";	
  addResultExpectValue(testname, processor.getParameter(null, "test"), undefined);
  
  // 6.3 pass removeParameter undefined name
  
  processor.setParameter(undefined, "undefined", "Success");
  processor.removeParameter(undefined, undefined);
  var testname = "pass removeParameter undefined name";
  addResultExpectValue(testname, processor.getParameter(undefined, "undefined"), "Success");
  
  // 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");
  
  // 6.5 verify removeParameter actually removes
  processor.setParameter(null, "test", "testValue");
  processor.removeParameter(null, "test");
  var testname = "verify removeParameter actually removes";
  addResultExpectValue(testname, processor.getParameter(null, "test"), undefined);
  
  
  
  // 7.0 void clearParameters();
  addSectionHeader("void clearParameters()");
  
  // 7.1 call, verify that parameters have been cleared
  processor.setParameter(null, "test", "testValue");
  processor.clearParameters();
  var testname = "verify that clearParameters does";
  addResultExpectValue(testname, processor.getParameter(null, "test"), undefined);
  
  
  // 8.0 void reset();
  addSectionHeader("void reset()");
  processor = new XSLTProcessor();
  processor.importStylesheet(xsl1);
  processor.setParameter(null, "test", "testValue");
  processor.reset();
  
  // 8.1 call, verify that parameters are cleared after reset()
  var testname = "verify that parameters have been cleared";
  addResultExpectValue(testname, processor.getParameter(null, "test"), undefined);
  
  // 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");
  
  </script>
  
  </body>
  </html>
  
  



More information about the webkit-changes mailing list