Quellcodebibliothek Statistik Leitseite products/Sources/formale Sprachen/C/Firefox/dom/base/test/   (Browser von der Mozilla Stiftung Version 136.0.1©)  Datei vom 10.2.2025 mit Größe 5 kB image not shown  

Quelle  test_bug541937.html   Sprache: HTML

 
 products/Sources/formale Sprachen/C/Firefox/dom/base/test/test_bug541937.html


<!DOCTYPE HTML>
<html>
<!--
-->

<head>
  <title>Test for XHTML serializer, bug 541937</title>
  <script 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=541937">Mozilla Bug </a>
<p id="display"></p>
<div id="content" style="display: none">
  <iframe id="testframe" src="file_bug541937.html">
  </iframe>
  <iframe id="testframe2" src="file_bug541937.xhtml">
  </iframe>
</div>

<pre id="test">
<script class="testbody" type="text/javascript">

function testSerializer () {
  const de = SpecialPowers.Ci.nsIDocumentEncoder;
  var encoder = SpecialPowers.Cu.createDocumentEncoder("text/html");

  var parser = new DOMParser();
  var serializer = new XMLSerializer();

  // with content
  var str = '\n \n\n';
  var expected = '\n\n \n\n';

  var doc = parser.parseFromString(str,"application/xml");
  var result = serializer.serializeToString(doc);
  result = result.replace(/\r\n/mg, "\n");
  is(result, expected, "serialization of a link element inside an xml document with children");

  // with only whitespaces
  str = '\n \n \n';
  expected = '\n\n \n \n';  

  doc = parser.parseFromString(str,"application/xml");
  result = serializer.serializeToString(doc);
  result = result.replace(/\r\n/mg, "\n");
  is(result, expected, "serialization of a link element with only whitespaces as content, inside an xml document");
  
  // with only one space as content
  str = '\n \n';
  expected = '\n\n \n';  

  doc = parser.parseFromString(str,"application/xml");
  result = serializer.serializeToString(doc);
  result = result.replace(/\r\n/mg, "\n");
  is(result, expected, "serialization of a link element with only one space as content, inside an xml document");
  
  // let's remove the content
  str = '\n \ndeleted content \n';
  expected = '\n\n\n';  

  doc = parser.parseFromString(str,"application/xml");
  doc.documentElement.firstElementChild.textContent = '';
  result = serializer.serializeToString(doc);
  result = result.replace(/\r\n/mg, "\n");
  is(result, expected, "serialization of a link element on which we removed dynamically the content, inside an xml document");
  
  // with no content but an ended tag
  str = '\n\n';
  expected = '\n\n\n';  

  doc = parser.parseFromString(str,"application/xml");
  result = serializer.serializeToString(doc);
  result = result.replace(/\r\n/mg, "\n");
  is(result, expected, "serialization of a link element with no content but with an ended tag, inside an xml document");
  
  // with no content
  str = '\n\n';
  expected = '\n\n\n';  

  doc = parser.parseFromString(str,"application/xml");
  result = serializer.serializeToString(doc);
  result = result.replace(/\r\n/mg, "\n");
  is(result, expected, "serialization of a link element with no content, inside an xml document");
  
  
  doc = $("testframe").contentDocument;
  encoder.init(doc, "text/html", de.OutputLFLineBreak);
  encoder.setCharset("UTF-8");
  result = encoder.encodeToString();
  expected = '\n Test\n';
  expected += ' ';
  expected += ' foo \n\n\n

Hello world

\n'
;
  is(result, expected, "serialization of a link element with content, inside an html document");

  doc = $("testframe2").contentDocument;
  encoder.init(doc, "application/xhtml+xml", de.OutputLFLineBreak);
  encoder.setCharset("UTF-8");
  result = encoder.encodeToString();
  expected = 'http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">\n';
  expected += '\n\n \n Test\n';
  expected += ' foo \n';
  expected += '\n\n\n

Hello world

\n\n'
;
  is(result, expected, "serialization of a link element with content, inside an xhtml document");

  SimpleTest.finish();
}


SimpleTest.waitForExplicitFinish();

addLoadEvent(testSerializer);

</script>
</pre>
</body>
</html>



Messung V0.5
C=98 H=100 G=98

¤ Dauer der Verarbeitung: 0.2 Sekunden  ¤

*© Formatika GbR, Deutschland






Wurzel

Suchen

Beweissystem der NASA

Beweissystem Isabelle

NIST Cobol Testsuite

Cephes Mathematical Library

Wiener Entwicklungsmethode

Haftungshinweis

Die Informationen auf dieser Webseite wurden nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit, noch Qualität der bereit gestellten Informationen zugesichert.

Bemerkung:

Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.